Environment Manager
Environment Manager
Section titled “Environment Manager”The EnvManager creates and maintains isolated Python environments (venv or conda) for each pipeline, with intelligent incremental dependency updates.
How it works
Section titled “How it works”- First execution: creates venv, installs all dependencies
- Same requirements: reuses environment (instant, hash match)
- Added package:
pip installonly the new one - Changed version:
pip install --upgradeonly that package - Removed package:
pip uninstallthe removed one - Stale environments: cleaned up after configurable timeout
Requirements Hash
Section titled “Requirements Hash”Dependencies are tracked by a normalized hash:
- Lines sorted alphabetically
- Comments and blank lines ignored
- Same deps in different order → same hash
# These two produce the same hash:numpy==1.26 scikit-learn==1.4scikit-learn==1.4 numpy==1.26Lockfile
Section titled “Lockfile”Each environment stores a lockfile.json:
{ "packages": {"numpy": "1.26", "scikit-learn": "1.4"}, "requirements_hash": "a3f8b2c1...", "env_type": "venv", "python_version": "3.11"}Configuration
Section titled “Configuration”let env_mgr = EnvManager::new("/envs", EnvType::Venv);// orlet env_mgr = EnvManager::new("/envs", EnvType::Conda);Docker Worker
Section titled “Docker Worker”The Soma worker Docker image uses EnvManager internally:
docker run -d \ -e NOUS_API_KEY=nous_xxx \ -e NOUS_URL=wss://server/nous/ws/worker \ ghcr.io/manucouto1/soma-worker:latestPre-installed: numpy, scipy, scikit-learn, pandas, matplotlib, soma. Additional dependencies installed per-pipeline on first execution.