From bb76742e4639e31cdba51465127e4fecf407da28 Mon Sep 17 00:00:00 2001 From: OfficialAbhinavSingh Date: Thu, 3 Sep 2026 02:04:22 +0530 Subject: [PATCH] fix(space): install only what the server imports, and declare the right port The Space image installed torch, transformers, trl, datasets and matplotlib. No served module imports any of them: the whole dependency closure reachable from server/app.py is fastapi, uvicorn, pydantic and duckdb, plus the standard library. They are training dependencies, used by train.py and scripts/ablation.py, and the image never runs either. Measured before and after, same Dockerfile otherwise: the image now builds in 17 seconds at 633 MB, where before it was still installing after five minutes. requirements-serve.txt holds that serving set and requirements.txt includes it with -r rather than repeating it, so the image and the full install cannot disagree about a version. Everything else stays declared exactly as it was. The front matter also said app_file: server/app.py. app_file is a Gradio and Streamlit field and is ignored when sdk is docker, so the port was never declared at all -- it only worked because 7860 happens to be the default and the Dockerfile serves there. It now says app_port: 7860, matching openenv.yaml's deployment.port and the Dockerfile's EXPOSE. Adds the agent-environment and rl-environment tags, which is how the OpenEnv catalog and the Spaces filter find community environments. Checked against three published community environments, which all carry both. --- Dockerfile | 4 ++-- README.md | 4 +++- requirements-serve.txt | 7 +++++++ requirements.txt | 14 +++++++++----- 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 requirements-serve.txt diff --git a/Dockerfile b/Dockerfile index 4b123d7..0ab5993 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,8 @@ RUN apt-get update && apt-get install -y \ gcc \ && rm -rf /var/lib/apt/lists/* -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +COPY requirements-serve.txt . +RUN pip install --no-cache-dir -r requirements-serve.txt COPY . . diff --git a/README.md b/README.md index 453d566..6123f6d 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,12 @@ emoji: 🗄️ colorFrom: indigo colorTo: blue sdk: docker -app_file: server/app.py +app_port: 7860 pinned: false tags: - openenv + - agent-environment + - rl-environment - sql - world-modeling - llm-training diff --git a/requirements-serve.txt b/requirements-serve.txt new file mode 100644 index 0000000..ff1b87e --- /dev/null +++ b/requirements-serve.txt @@ -0,0 +1,7 @@ +# What the environment server actually imports. Installed into the Space image. +# Kept as its own file, and included by requirements.txt below, so the two +# cannot drift: the image and the full install share one definition of these. +fastapi==0.115.0 +uvicorn[standard]==0.30.6 +pydantic==2.8.2 +duckdb>=0.10.0 diff --git a/requirements.txt b/requirements.txt index 21b2095..6496057 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,16 @@ -fastapi==0.115.0 -uvicorn[standard]==0.30.6 -pydantic==2.8.2 +# Serving dependencies, shared with the Space image. One definition, included +# rather than repeated. +-r requirements-serve.txt + +# Client and evaluation scripts (inference.py, baseline_runner.py). openai>=1.0.0 pyyaml==6.0.2 requests==2.32.3 openenv-core>=0.2.0 -duckdb>=0.10.0 -# Training dependencies + +# Training only (train.py, scripts/ablation.py). Deliberately absent from the +# Space image: no served module imports any of these, and installing torch into +# the image took minutes and gigabytes for code the server never runs. trl>=0.8.0 transformers>=4.40.0 torch>=2.1.0