Rakshithn123 commited on
Commit
75d8194
·
1 Parent(s): afd71c6

chore: clean up empty code change sections in the changes log

Browse files
Files changed (6) hide show
  1. .gitignore +4 -1
  2. Dockerfile +36 -0
  3. pyproject.toml +3 -0
  4. server/Dockerfile +0 -80
  5. server/app.py +17 -4
  6. uv.lock +0 -0
.gitignore CHANGED
@@ -153,4 +153,7 @@ logs/
153
  *.temp
154
 
155
  # Docker (if building locally)
156
- .dockerignore
 
 
 
 
153
  *.temp
154
 
155
  # Docker (if building locally)
156
+ .dockerignore
157
+
158
+ # OpenEnv specific
159
+ outputs/
Dockerfile ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && \
7
+ apt-get install -y --no-install-recommends curl git && \
8
+ rm -rf /var/lib/apt/lists/*
9
+
10
+ # Copy everything from root into /app
11
+ COPY . /app
12
+
13
+ # Install Python dependencies
14
+ RUN pip install --no-cache-dir \
15
+ openenv-core \
16
+ fastapi \
17
+ "uvicorn[standard]" \
18
+ pydantic \
19
+ websockets \
20
+ openai
21
+
22
+ # Set PYTHONPATH so all imports resolve correctly
23
+ # /app → models.py, client.py, __init__.py
24
+ # /app/server → app.py, data.py, second_brain_env_environment.py
25
+ ENV PYTHONPATH="/app:/app/server"
26
+ ENV TASK_NAME=note_categorization
27
+ ENV PORT=8000
28
+
29
+ EXPOSE 8000
30
+
31
+ # Health check
32
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
33
+ CMD curl -f http://localhost:8000/health || exit 1
34
+
35
+ # Run server
36
+ CMD ["sh", "-c", "cd /app && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
pyproject.toml CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  [build-system]
2
  requires = ["hatchling"]
3
  build-backend = "hatchling.build"
 
1
+ [project.scripts]
2
+ server = "server.app:main"
3
+
4
  [build-system]
5
  requires = ["hatchling"]
6
  build-backend = "hatchling.build"
server/Dockerfile DELETED
@@ -1,80 +0,0 @@
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
- # Multi-stage build using openenv-base
8
- # This Dockerfile is flexible and works for both:
9
- # - In-repo environments (with local OpenEnv sources)
10
- # - Standalone environments (with openenv from PyPI/Git)
11
- # The build script (openenv build) handles context detection and sets appropriate build args.
12
-
13
- ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
14
- FROM ${BASE_IMAGE} AS builder
15
-
16
- WORKDIR /app
17
-
18
- # Ensure git is available (required for installing dependencies from VCS)
19
- RUN apt-get update && \
20
- apt-get install -y --no-install-recommends git && \
21
- rm -rf /var/lib/apt/lists/*
22
-
23
- # Build argument to control whether we're building standalone or in-repo
24
- ARG BUILD_MODE=in-repo
25
- ARG ENV_NAME=second_brain_env
26
-
27
- # Copy environment code (always at root of build context)
28
- COPY . /app/env
29
-
30
- # For in-repo builds, openenv is already vendored in the build context
31
- # For standalone builds, openenv will be installed via pyproject.toml
32
- WORKDIR /app/env
33
-
34
- # Ensure uv is available (for local builds where base image lacks it)
35
- RUN if ! command -v uv >/dev/null 2>&1; then \
36
- curl -LsSf https://astral.sh/uv/install.sh | sh && \
37
- mv /root/.local/bin/uv /usr/local/bin/uv && \
38
- mv /root/.local/bin/uvx /usr/local/bin/uvx; \
39
- fi
40
-
41
- # Install dependencies using uv sync
42
- # If uv.lock exists, use it; otherwise resolve on the fly
43
- RUN --mount=type=cache,target=/root/.cache/uv \
44
- if [ -f uv.lock ]; then \
45
- uv sync --frozen --no-install-project --no-editable; \
46
- else \
47
- uv sync --no-install-project --no-editable; \
48
- fi
49
-
50
- RUN --mount=type=cache,target=/root/.cache/uv \
51
- if [ -f uv.lock ]; then \
52
- uv sync --frozen --no-editable; \
53
- else \
54
- uv sync --no-editable; \
55
- fi
56
-
57
- # Final runtime stage
58
- FROM ${BASE_IMAGE}
59
-
60
- WORKDIR /app
61
-
62
- # Copy the virtual environment from builder
63
- COPY --from=builder /app/env/.venv /app/.venv
64
-
65
- # Copy the environment code
66
- COPY --from=builder /app/env /app/env
67
-
68
- # Set PATH to use the virtual environment
69
- ENV PATH="/app/.venv/bin:$PATH"
70
-
71
- # Set PYTHONPATH so imports work correctly
72
- ENV PYTHONPATH="/app/env:$PYTHONPATH"
73
-
74
- # Health check
75
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
76
- CMD curl -f http://localhost:8000/health || exit 1
77
-
78
- # Run the FastAPI server
79
- # The module path is constructed to work with the /app/env structure
80
- CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
server/app.py CHANGED
@@ -3,11 +3,12 @@ FastAPI server for Second Brain OpenEnv environment.
3
  Exposes reset(), step(), state() over HTTP + WebSocket.
4
  """
5
  import os
6
- from fastapi import FastAPI
 
7
  from openenv.core.env_server import create_app
8
 
9
  from second_brain_env_environment import SecondBrainEnvironment
10
- from models import SecondBrainAction
11
 
12
  import sys
13
  sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -16,8 +17,11 @@ VALID_TASKS = ["note_categorization", "memory_retrieval", "knowledge_synthesis"]
16
 
17
 
18
  def make_app(task_name: str = "note_categorization") -> FastAPI:
19
- env = SecondBrainEnvironment(task_name=task_name)
20
- app = create_app(env, action_type=SecondBrainAction)
 
 
 
21
  return app
22
 
23
 
@@ -59,3 +63,12 @@ def list_tasks():
59
  @app.get("/health")
60
  def health():
61
  return {"status": "ok", "environment": "second_brain_env"}
 
 
 
 
 
 
 
 
 
 
3
  Exposes reset(), step(), state() over HTTP + WebSocket.
4
  """
5
  import os
6
+ from typing import Optional
7
+ from fastapi import FastAPI, Query
8
  from openenv.core.env_server import create_app
9
 
10
  from second_brain_env_environment import SecondBrainEnvironment
11
+ from models import SecondBrainAction, SecondBrainObservation
12
 
13
  import sys
14
  sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
17
 
18
 
19
  def make_app(task_name: str = "note_categorization") -> FastAPI:
20
+ app = create_app(
21
+ SecondBrainEnvironment,
22
+ action_cls=SecondBrainAction,
23
+ observation_cls=SecondBrainObservation
24
+ )
25
  return app
26
 
27
 
 
63
  @app.get("/health")
64
  def health():
65
  return {"status": "ok", "environment": "second_brain_env"}
66
+
67
+
68
+ def main():
69
+ import uvicorn
70
+ uvicorn.run("app:app", host="0.0.0.0", port=8000, workers=2)
71
+
72
+
73
+ if __name__ == "__main__":
74
+ main()
uv.lock ADDED
The diff for this file is too large to render. See raw diff