Atharva commited on
Commit
b05fe7b
·
1 Parent(s): d79b1d2

Ignore local WolfeClick space clone

Browse files
Files changed (12) hide show
  1. .gitignore +1 -0
  2. Dockerfile +34 -0
  3. README.md +13 -0
  4. __init__.py +7 -0
  5. client.py +38 -0
  6. models.py +13 -0
  7. openenv.yaml +7 -0
  8. pyproject.toml +5 -4
  9. server/Dockerfile +34 -0
  10. server/__init__.py +2 -0
  11. server/app.py +23 -0
  12. uv.lock +0 -0
.gitignore CHANGED
@@ -19,3 +19,4 @@ env/
19
  # IDE / OS
20
  .idea/
21
  .DS_Store
 
 
19
  # IDE / OS
20
  .idea/
21
  .DS_Store
22
+ WolfeClick
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies: git, curl for healthcheck, and Node.js for Pokemon Showdown
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ git \
8
+ curl \
9
+ nodejs \
10
+ npm \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Clone Pokemon Showdown so poke-env can connect to a local server
14
+ RUN git clone https://github.com/smogon/pokemon-showdown.git /opt/pokemon-showdown
15
+
16
+ # Copy the entire repo into the image (includes smogon_rl and env server)
17
+ COPY . /app
18
+
19
+ # Install Python dependencies, including OpenEnv core 0.2.1
20
+ RUN pip install --no-cache-dir \
21
+ \"openenv-core==0.2.1\" \
22
+ \"poke-env>=0.8.0,<0.9.0\" \
23
+ \"numpy>=1.24.0\" \
24
+ \"pydantic>=2.0.0\"
25
+
26
+ ENV SHOWDOWN_DIR=/opt/pokemon-showdown
27
+
28
+ # Basic healthcheck against the FastAPI app port
29
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
30
+ CMD curl -f http://localhost:8001/health || exit 1
31
+
32
+ # Start Pokemon Showdown on port 8000 (for poke-env) and the OpenEnv FastAPI app on port 8001
33
+ CMD bash -lc \"cd /opt/pokemon-showdown && node pokemon-showdown start --no-security --port 8000 & uvicorn env.server.app:app --host 0.0.0.0 --port 8001\"
34
+
README.md CHANGED
@@ -1,3 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # OpenEnv-WolfeClick
2
 
3
  OpenEnv-WolfeClick is a reinforcement learning environment and training workflow for competitive Pokemon battles with large language models.
 
1
+ ---
2
+ title: OpenEnv-WolfeClick Environment
3
+ emoji: 🎮
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 8001
8
+ tags:
9
+ - openenv
10
+ - pokemon
11
+ - rl
12
+ ---
13
+
14
  # OpenEnv-WolfeClick
15
 
16
  OpenEnv-WolfeClick is a reinforcement learning environment and training workflow for competitive Pokemon battles with large language models.
__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ """
2
+ Package marker for the OpenEnv-WolfeClick environment repository.
3
+
4
+ This file exists so the project root can be treated as a valid
5
+ OpenEnv environment package when using `openenv push`.
6
+ """
7
+
client.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Dict
4
+
5
+ from openenv.core import EnvClient
6
+ from openenv.core.client_types import StepResult
7
+
8
+ from env.models import WolfeClickAction, WolfeClickObservation, WolfeClickState
9
+
10
+
11
+ class WolfeClickEnv(EnvClient[WolfeClickAction, WolfeClickObservation, WolfeClickState]):
12
+ """HTTP/WebSocket client for the WolfeClick OpenEnv environment."""
13
+
14
+ def _step_payload(self, action: WolfeClickAction) -> Dict[str, Any]:
15
+ # Matches the action schema expected by WolfeClickEnvironment.step.
16
+ return {"action_json": action.action_json}
17
+
18
+ def _parse_result(self, payload: Dict[str, Any]) -> StepResult[WolfeClickObservation]:
19
+ obs_payload = payload.get("observation", {})
20
+ obs = WolfeClickObservation(
21
+ state_markdown=obs_payload.get("state_markdown", ""),
22
+ done=bool(obs_payload.get("done", payload.get("done", False))),
23
+ reward=float(payload.get("reward", 0.0)),
24
+ metadata=obs_payload.get("metadata") or {},
25
+ )
26
+ return StepResult(
27
+ observation=obs,
28
+ reward=payload.get("reward"),
29
+ done=payload.get("done", obs.done),
30
+ )
31
+
32
+ def _parse_state(self, payload: Dict[str, Any]) -> WolfeClickState:
33
+ # Base State already defines episode_id and step_count; we pass through the payload.
34
+ return WolfeClickState(**payload)
35
+
36
+
37
+ __all__ = ["WolfeClickEnv"]
38
+
models.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ """
4
+ Top-level models shim for the WolfeClick OpenEnv environment.
5
+
6
+ Exposes the same types as `env.models` so tools expecting a standard
7
+ OpenEnv layout (client.py, models.py, server/app.py) can import them.
8
+ """
9
+
10
+ from env.models import WolfeClickAction, WolfeClickObservation, WolfeClickState
11
+
12
+ __all__ = ["WolfeClickAction", "WolfeClickObservation", "WolfeClickState"]
13
+
openenv.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ spec_version: 1
2
+ name: openenv-wolfeclick
3
+ type: space
4
+ runtime: fastapi
5
+ app: env.server.app:app
6
+ port: 8001
7
+
pyproject.toml CHANGED
@@ -11,8 +11,12 @@ dependencies = [
11
  "poke-env>=0.8.0,<0.9.0",
12
  "numpy>=1.24.0",
13
  "pydantic>=2.0.0",
 
14
  ]
15
 
 
 
 
16
  [project.optional-dependencies]
17
  dev = [
18
  "pytest>=7.0.0",
@@ -24,7 +28,4 @@ requires = ["hatchling"]
24
  build-backend = "hatchling.build"
25
 
26
  [tool.uv]
27
- package = "smogon-rl"
28
-
29
- [tool.uv.sources]
30
-
 
11
  "poke-env>=0.8.0,<0.9.0",
12
  "numpy>=1.24.0",
13
  "pydantic>=2.0.0",
14
+ "openenv-core>=0.2.1",
15
  ]
16
 
17
+ [project.scripts]
18
+ server = "env.server.app:main"
19
+
20
  [project.optional-dependencies]
21
  dev = [
22
  "pytest>=7.0.0",
 
28
  build-backend = "hatchling.build"
29
 
30
  [tool.uv]
31
+ package = true
 
 
 
server/Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies: git, curl for healthcheck, and Node.js for Pokemon Showdown
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ git \
8
+ curl \
9
+ nodejs \
10
+ npm \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Clone Pokemon Showdown so poke-env can connect to a local server
14
+ RUN git clone https://github.com/smogon/pokemon-showdown.git /opt/pokemon-showdown
15
+
16
+ # Copy the entire repo into the image (includes smogon_rl and env server)
17
+ COPY . /app
18
+
19
+ # Install Python dependencies, including OpenEnv core 0.2.1
20
+ RUN pip install --no-cache-dir \
21
+ "openenv-core==0.2.1" \
22
+ "poke-env>=0.8.0,<0.9.0" \
23
+ "numpy>=1.24.0" \
24
+ "pydantic>=2.0.0"
25
+
26
+ ENV SHOWDOWN_DIR=/opt/pokemon-showdown
27
+
28
+ # Basic healthcheck against the FastAPI app port
29
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
30
+ CMD curl -f http://localhost:8001/health || exit 1
31
+
32
+ # Start Pokemon Showdown on port 8000 (for poke-env) and the OpenEnv FastAPI app on port 8001
33
+ CMD bash -lc "cd /opt/pokemon-showdown && node pokemon-showdown start --no-security --port 8000 & uvicorn env.server.app:app --host 0.0.0.0 --port 8001"
34
+
server/__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ """Server package for the WolfeClick OpenEnv environment."""
2
+
server/app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ """
4
+ Thin wrapper so `openenv` and `uv run server` can find the ASGI app.
5
+ """
6
+
7
+ from env.server.app import app as _inner_app
8
+ from env.server.app import main as _inner_main
9
+
10
+ app = _inner_app
11
+
12
+
13
+ def main() -> None:
14
+ _inner_main()
15
+
16
+
17
+ __all__ = ["app", "main"]
18
+
19
+
20
+ if __name__ == "__main__":
21
+ main()
22
+
23
+
uv.lock ADDED
The diff for this file is too large to render. See raw diff