Skip to content

Commit 178a30d

Browse files
committed
chore: migrate to new cli
1 parent 0ca4d8e commit 178a30d

File tree

7 files changed

+47
-26
lines changed

7 files changed

+47
-26
lines changed

src/envs/websearch_env/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
"""WebSearch Env Environment - A simple test environment for HTTP server."""
7+
"""WebSearch Env Environment - A web search environment that uses Google Search API (via Serper.dev)."""
88

99
from .client import WebSearchEnv
1010
from .models import WebSearchAction, WebSearchObservation
1111

1212
__all__ = ["WebSearchAction", "WebSearchObservation", "WebSearchEnv"]
13-

src/envs/websearch_env/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
from typing import Dict
1515

16-
from core.client_types import StepResult
17-
from core.env_server.types import State
18-
from core.http_env_client import HTTPEnvClient
16+
from openenv_core.client_types import StepResult
17+
from openenv_core.env_server.types import State
18+
from openenv_core.http_env_client import HTTPEnvClient
1919

2020
from .models import WebSearchAction, WebSearchObservation
2121

src/envs/websearch_env/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"""
88
Data models for the WebSearch Env Environment.
99
10-
The WebSearch_env environment is a simple test environment that echoes back messages.
10+
The WebSearch Env environment is an environment that searches the web with Google Search API (via Serper API).
1111
"""
1212

1313
from __future__ import annotations
1414

1515
# Use pydantic dataclass for validation
1616
from pydantic.dataclasses import dataclass
1717
from pydantic import Field
18-
from core.env_server.types import Action, Observation
18+
from openenv_core.env_server.types import Action, Observation
1919

2020

2121
@dataclass(kw_only=True)

src/envs/websearch_env/server/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
"""WebSearch Env environment server components."""
7+
"""WebSearch Env Environment server components."""
88

99
from .websearch_env_environment import WebSearchEnvironment
1010

1111
__all__ = ["WebSearchEnvironment"]
12-

src/envs/websearch_env/server/app.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# LICENSE file in the root directory of this source tree.
66

77
"""
8-
FastAPI application for the WebSearch Env Environment.
8+
FastAPI application for the Websearch Env Environment.
99
1010
This module creates an HTTP server that exposes the WebSearchEnvironment
1111
over HTTP endpoints, making it compatible with HTTPEnvClient.
@@ -22,24 +22,49 @@
2222
"""
2323

2424
try:
25-
from core.env_server.http_server import create_app
25+
from openenv_core.env_server.http_server import create_app
2626
except Exception as e: # pragma: no cover
2727
raise ImportError(
28-
"openenv_core is required for the web interface. Install template deps with '\n"
29-
" pip install -r server/requirements.txt\n'"
28+
"openenv_core is required for the web interface. Install dependencies with '\n"
29+
" uv sync\n'"
3030
) from e
3131

3232
from .websearch_env_environment import WebSearchEnvironment
33-
from ..models import WebSearchAction, WebSearchObservation
33+
from models import WebSearchAction, WebSearchObservation
3434

3535
# Create the environment instance
3636
env = WebSearchEnvironment()
3737

3838
# Create the app with web interface and README integration
39-
app = create_app(env, WebSearchAction, WebSearchObservation, env_name="websearch_env")
39+
app = create_app(
40+
env,
41+
WebSearchAction,
42+
WebSearchObservation,
43+
env_name="websearch_env",
44+
)
4045

4146

42-
if __name__ == "__main__":
47+
def main(host: str = "0.0.0.0", port: int = 8000):
48+
"""
49+
Entry point for direct execution via uv run or python -m.
50+
51+
This function enables running the server without Docker:
52+
uv run --project . server
53+
uv run --project . server --port 8001
54+
python -m websearch_env.server.app
55+
56+
Args:
57+
host: Host address to bind to (default: "0.0.0.0")
58+
port: Port number to listen on (default: 8000)
59+
60+
For production deployments, consider using uvicorn directly with
61+
multiple workers:
62+
uvicorn websearch_env.server.app:app --workers 4
63+
"""
4364
import uvicorn
4465

45-
uvicorn.run(app, host="0.0.0.0", port=8000)
66+
uvicorn.run(app, host=host, port=port)
67+
68+
69+
if __name__ == "__main__":
70+
main()

src/envs/websearch_env/server/websearch_env_environment.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@
55
# LICENSE file in the root directory of this source tree.
66

77
"""
8-
WebSearch Env Environment Implementation (inspired by Search-R1).
8+
Websearch Env Environment Implementation.
99
10-
A web search environment that uses the google search API (via Serper.dev) to search the web.
11-
It maintains minimal state and simply returns the search results.
10+
A web search environment that uses the google search API (via Serper API) to search the web.
1211
"""
1312

1413
from __future__ import annotations
1514
import asyncio
1615
import os
1716
from uuid import uuid4
1817

19-
from core.env_server.interfaces import Environment
20-
from core.env_server.types import State
21-
22-
from ..models import WebSearchAction, WebSearchObservation
23-
from .websearch_tool import WebSearchTool
18+
from models import WebSearchAction, WebSearchObservation
19+
from openenv_core.env_server.interfaces import Environment
20+
from openenv_core.env_server.types import State
21+
from websearch_tool import WebSearchTool
2422

2523

2624
class WebSearchEnvironment(Environment):

src/envs/websearch_env/server/websearch_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import aiohttp
2121
import chardet
2222

23-
from ..models import WebContent, WebSearchAction, WebSearchObservation
23+
from models import WebContent, WebSearchAction, WebSearchObservation
2424

2525

2626
class WebSearchTool:

0 commit comments

Comments
 (0)