zkwentz commited on
Commit
7b3bda1
·
verified ·
1 Parent(s): 26f7cfe

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. README.md +4 -4
  2. pyproject.toml +42 -0
  3. server/Dockerfile +35 -8
  4. server/app.py +23 -2
  5. server/myenv_environment.py +1 -1
  6. uv.lock +0 -0
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: Myenv Environment Server
3
- emoji: 🎻
4
- colorFrom: purple
5
- colorTo: pink
6
  sdk: docker
7
  pinned: false
8
  app_port: 8000
@@ -126,7 +126,7 @@ The deployed space includes:
126
  - `echoed_message` (str) - The message echoed back
127
  - `message_length` (int) - Length of the message
128
  - `reward` (float) - Reward based on message length (length × 0.1)
129
- - `done` (bool) - Always False for myenv
130
  - `metadata` (dict) - Additional info like step count
131
 
132
  ### Reward
 
1
  ---
2
  title: Myenv Environment Server
3
+ emoji: 🎪
4
+ colorFrom: indigo
5
+ colorTo: yellow
6
  sdk: docker
7
  pinned: false
8
  app_port: 8000
 
126
  - `echoed_message` (str) - The message echoed back
127
  - `message_length` (int) - Length of the message
128
  - `reward` (float) - Reward based on message length (length × 0.1)
129
+ - `done` (bool) - Always False for echo environment
130
  - `metadata` (dict) - Additional info like step count
131
 
132
  ### Reward
pyproject.toml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the BSD-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ [build-system]
8
+ requires = ["setuptools>=45", "wheel"]
9
+ build-backend = "setuptools.build_meta"
10
+
11
+ [project]
12
+ name = "openenv-myenv"
13
+ version = "0.1.0"
14
+ description = "Myenv environment for OpenEnv"
15
+ requires-python = ">=3.10"
16
+ dependencies = [
17
+ # Core OpenEnv dependencies
18
+ "fastapi>=0.115.0",
19
+ "pydantic>=2.0.0",
20
+ "uvicorn>=0.24.0",
21
+ "requests>=2.31.0",
22
+ # Add your environment-specific dependencies here
23
+ # Example:
24
+ # "numpy",
25
+ # "torch",
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ dev = [
30
+ "pytest>=8.0.0",
31
+ "pytest-cov>=4.0.0",
32
+ ]
33
+
34
+ [project.scripts]
35
+ server = "envs.myenv_env.server.app:main"
36
+
37
+ [tool.setuptools]
38
+ package-dir = {"" = "."}
39
+
40
+ [tool.setuptools.packages.find]
41
+ where = ["."]
42
+
server/Dockerfile CHANGED
@@ -4,15 +4,43 @@
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
- # Use the standard openenv base image
8
- ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  FROM ${BASE_IMAGE}
10
 
11
- # Copy only what's needed for this environment
12
- COPY . /app/src/envs/myenv/
 
 
 
 
 
13
 
14
- # Install dependencies
15
- RUN pip install --no-cache-dir -r /app/src/envs/myenv/server/requirements.txt && rm /app/src/envs/myenv/server/requirements.txt
 
 
 
16
 
17
  # Health check
18
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
@@ -20,5 +48,4 @@ ENV ENABLE_WEB_INTERFACE=true
20
  CMD curl -f http://localhost:8000/health || exit 1
21
 
22
  # Run the FastAPI server
23
- CMD ["uvicorn", "envs.myenv.server.app:app", "--host", "0.0.0.0", "--port", "8000"]
24
-
 
4
  # This source code is licensed under the BSD-style license found in the
5
  # LICENSE file in the root directory of this source tree.
6
 
7
+ # Multi-stage build using openenv-base
8
+ # Build from repo root: docker build -t myenv_env:latest -f src/envs/myenv_env/server/Dockerfile .
9
+ ARG BASE_IMAGE=openenv-base:latest
10
+ FROM ${BASE_IMAGE} AS builder
11
+
12
+ WORKDIR /app
13
+
14
+ # Copy core module (needed by myenv_env)
15
+ COPY src/core /app/src/core
16
+
17
+ # Copy environment
18
+ COPY src/envs/myenv_env /app/src/envs/myenv_env
19
+
20
+ # Install dependencies using uv sync
21
+ WORKDIR /app/src/envs/myenv_env
22
+ RUN --mount=type=cache,target=/root/.cache/uv \
23
+ uv sync --locked --no-install-project --no-editable
24
+
25
+ RUN --mount=type=cache,target=/root/.cache/uv \
26
+ uv sync --locked --no-editable
27
+
28
+ # Final runtime stage
29
  FROM ${BASE_IMAGE}
30
 
31
+ WORKDIR /app
32
+
33
+ # Copy core module
34
+ COPY --from=builder /app/src/core /app/src/core
35
+
36
+ # Copy the virtual environment from builder
37
+ COPY --from=builder /app/src/envs/myenv_env/.venv /app/.venv
38
 
39
+ # Copy the environment code
40
+ COPY --from=builder /app/src/envs/myenv_env /app/src/envs/myenv_env
41
+
42
+ # Set PATH to use the virtual environment
43
+ ENV PATH="/app/.venv/bin:$PATH"
44
 
45
  # Health check
46
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
 
48
  CMD curl -f http://localhost:8000/health || exit 1
49
 
50
  # Run the FastAPI server
51
+ CMD ["uvicorn", "envs.myenv_env.server.app:app", "--host", "0.0.0.0", "--port", "8000"]
 
server/app.py CHANGED
@@ -36,10 +36,31 @@ from myenv.models import MyenvAction, MyenvObservation
36
  env = MyenvEnvironment()
37
 
38
  # Create the app with web interface and README integration
39
- app = create_app(env, MyenvAction, MyenvObservation, env_name="myenv")
 
 
 
 
 
40
 
41
 
42
- if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
43
  import uvicorn
44
 
45
  uvicorn.run(app, host="0.0.0.0", port=8000)
 
 
 
 
 
36
  env = MyenvEnvironment()
37
 
38
  # Create the app with web interface and README integration
39
+ app = create_app(
40
+ env,
41
+ MyenvAction,
42
+ MyenvObservation,
43
+ env_name="myenv",
44
+ )
45
 
46
 
47
+ def main():
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
+ python -m server.app
54
+ openenv serve myenv
55
+
56
+ For production deployments, consider using uvicorn directly with
57
+ multiple workers:
58
+ uvicorn server.app:app --workers 4
59
+ """
60
  import uvicorn
61
 
62
  uvicorn.run(app, host="0.0.0.0", port=8000)
63
+
64
+
65
+ if __name__ == "__main__":
66
+ main()
server/myenv_environment.py CHANGED
@@ -21,7 +21,7 @@ from myenv.models import MyenvAction, MyenvObservation
21
 
22
  class MyenvEnvironment(Environment):
23
  """
24
- A simple myenv that echoes back messages.
25
 
26
  This environment is designed for testing the HTTP server infrastructure.
27
  It maintains minimal state and simply echoes back whatever message it receives.
 
21
 
22
  class MyenvEnvironment(Environment):
23
  """
24
+ A simple echo environment that echoes back messages.
25
 
26
  This environment is designed for testing the HTTP server infrastructure.
27
  It maintains minimal state and simply echoes back whatever message it receives.
uv.lock ADDED
The diff for this file is too large to render. See raw diff