tejadhith commited on
Commit
923d2e5
·
verified ·
1 Parent(s): d8d1099

Remove external data download — curated tasks embedded in code

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -6
  2. server/Dockerfile +64 -0
  3. server/environment.py +5 -1
Dockerfile CHANGED
@@ -49,15 +49,10 @@ RUN apt-get update && \
49
  COPY --from=builder /app/env/.venv /app/.venv
50
  COPY --from=builder /app/env /app/env
51
 
52
- # Extract shaders21k corpus
53
- # Priority: bundled zip > already extracted > download from HF Space
54
  RUN if [ -f /app/env/shader_data.zip ]; then \
55
  python3 -c "import zipfile; zipfile.ZipFile('/app/env/shader_data.zip').extractall('/app/env')" && \
56
  rm /app/env/shader_data.zip; \
57
- elif [ ! -d /app/env/data/shadertoy ]; then \
58
- curl -fSL "https://huggingface.co/spaces/tejadhith/shader/resolve/main/shader_data.zip" -o /tmp/shader_data.zip && \
59
- python3 -c "import zipfile; zipfile.ZipFile('/tmp/shader_data.zip').extractall('/app/env')" && \
60
- rm /tmp/shader_data.zip; \
61
  fi
62
 
63
  ENV PATH="/app/.venv/bin:$PATH"
 
49
  COPY --from=builder /app/env/.venv /app/.venv
50
  COPY --from=builder /app/env /app/env
51
 
52
+ # Extract shaders21k corpus if bundled; otherwise curated tasks suffice
 
53
  RUN if [ -f /app/env/shader_data.zip ]; then \
54
  python3 -c "import zipfile; zipfile.ZipFile('/app/env/shader_data.zip').extractall('/app/env')" && \
55
  rm /app/env/shader_data.zip; \
 
 
 
 
56
  fi
57
 
58
  ENV PATH="/app/.venv/bin:$PATH"
server/Dockerfile ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multi-stage build for the shader environment.
2
+ # Requires EGL for headless OpenGL rendering.
3
+
4
+ ARG BASE_IMAGE=ghcr.io/meta-pytorch/openenv-base:latest
5
+ FROM ${BASE_IMAGE} AS builder
6
+
7
+ WORKDIR /app
8
+
9
+ RUN apt-get update && \
10
+ apt-get install -y --no-install-recommends git && \
11
+ rm -rf /var/lib/apt/lists/*
12
+
13
+ ARG BUILD_MODE=in-repo
14
+ ARG ENV_NAME=shader
15
+
16
+ COPY . /app/env
17
+
18
+ WORKDIR /app/env
19
+
20
+ RUN if ! command -v uv >/dev/null 2>&1; then \
21
+ curl -LsSf https://astral.sh/uv/install.sh | sh && \
22
+ mv /root/.local/bin/uv /usr/local/bin/uv && \
23
+ mv /root/.local/bin/uvx /usr/local/bin/uvx; \
24
+ fi
25
+
26
+ RUN if [ -f uv.lock ]; then \
27
+ uv sync --frozen --no-install-project --no-editable; \
28
+ else \
29
+ uv sync --no-install-project --no-editable; \
30
+ fi
31
+
32
+ RUN if [ -f uv.lock ]; then \
33
+ uv sync --frozen --no-editable; \
34
+ else \
35
+ uv sync --no-editable; \
36
+ fi
37
+
38
+ # Final runtime stage
39
+ FROM ${BASE_IMAGE}
40
+
41
+ WORKDIR /app
42
+
43
+ # EGL support for headless OpenGL rendering
44
+ RUN apt-get update && \
45
+ apt-get install -y --no-install-recommends \
46
+ libegl1 libgl1 libgles2 libgl1-mesa-dri && \
47
+ rm -rf /var/lib/apt/lists/*
48
+
49
+ COPY --from=builder /app/env/.venv /app/.venv
50
+ COPY --from=builder /app/env /app/env
51
+
52
+ # Extract shaders21k corpus if bundled; otherwise curated tasks suffice
53
+ RUN if [ -f /app/env/shader_data.zip ]; then \
54
+ python3 -c "import zipfile; zipfile.ZipFile('/app/env/shader_data.zip').extractall('/app/env')" && \
55
+ rm /app/env/shader_data.zip; \
56
+ fi
57
+
58
+ ENV PATH="/app/.venv/bin:$PATH"
59
+ ENV PYTHONPATH="/app/env:$PYTHONPATH"
60
+
61
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
62
+ CMD curl -f http://localhost:8000/health || exit 1
63
+
64
+ CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
server/environment.py CHANGED
@@ -40,7 +40,11 @@ class ShaderEnvironment(Environment):
40
  self._budget = budget
41
  self._rng = random.Random(seed)
42
  if ShaderEnvironment._tasks is None:
43
- ShaderEnvironment._tasks = load_tasks()
 
 
 
 
44
  self._state = State(episode_id=None, step_count=0)
45
 
46
  # Episode state
 
40
  self._budget = budget
41
  self._rng = random.Random(seed)
42
  if ShaderEnvironment._tasks is None:
43
+ try:
44
+ ShaderEnvironment._tasks = load_tasks()
45
+ except FileNotFoundError:
46
+ # Corpus not available — use curated tasks only
47
+ ShaderEnvironment._tasks = list(CURATED)
48
  self._state = State(episode_id=None, step_count=0)
49
 
50
  # Episode state