Skip to content

Conversation

@Mortimerp9
Copy link
Contributor

Refactored the OpenEnv Docker deployment architecture to eliminate code duplication between GHCR and Hugging Face Spaces deployments. Introduced standard Python dependency management patterns and fully collocated environment configuration.

Problem

Previously, dependencies and deployment configuration were duplicated across:

  1. Static Dockerfiles (for GHCR deployment)
  2. HF deployment script with hardcoded case statements
  3. Dynamic Dockerfile generation for HF Spaces

This created:

  • Maintenance burden: Changes required updating multiple files
  • Drift risk: Dependencies could get out of sync between deployment methods
  • Poor scalability: Adding new environments required modifying central deployment script
  • Unclear ownership: Configuration scattered across codebase

Solution

1. Introduced Standard Dependency Files

Each environment now uses familiar Python patterns:

requirements.txt - Standard Python dependencies (most common)

src/envs/coding_env/server/requirements.txt
src/envs/atari_env/server/requirements.txt
src/envs/chat_env/server/requirements.txt

install_deps.sh - Optional bash script for complex setup beyond pip

src/envs/chat_env/server/install_deps.sh

prepare_hf.sh - Optional custom HF Dockerfile modification

src/envs/openspiel_env/server/prepare_hf.sh

2. Updated Static Dockerfiles

All environment Dockerfiles now follow the standard pattern:

# Install dependencies from requirements.txt
COPY src/envs/my_env/server/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt && rm /tmp/requirements.txt

# For complex setup, use install_deps.sh
COPY src/envs/my_env/server/install_deps.sh /tmp/install_deps.sh
RUN chmod +x /tmp/install_deps.sh && \
    /tmp/install_deps.sh && \
    rm /tmp/install_deps.sh

3. Enhanced Environment READMEs

Added HF Space YAML front matter to each environment's README:

---
title: Echo Environment Server
emoji: 🔊
colorFrom: '#00C9FF'
colorTo: '#1B2845'
sdk: docker
pinned: false
app_port: 8000
base_path: /web
---

4. Simplified HF Deployment Script

Reduced scripts/prepare_hf_deployment.sh from ~329 lines to ~180 lines:

  • ❌ Removed all hardcoded case statements for dependencies
  • ❌ Removed dynamic Dockerfile generation
  • ✅ Now copies and minimally modifies static Dockerfiles
  • ✅ Reuses existing environment READMEs
  • ✅ Executes optional environment-specific preparation scripts
  • ✅ Cross-platform compatible (macOS BSD sed + Linux GNU sed)

Testing

Generate the readmes and dockers for the envs and check the generated files.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 28, 2025
@@ -0,0 +1,2 @@
torch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need versions?

@pankit-eng pankit-eng merged commit f6b4dc2 into main Oct 30, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants