world: install legion at a pinned commit instead of vendoring it

#1
by lewtun HF Staff - opened
Hugging Face Agent Swarms Research org
•
edited 1 day ago

What

The world image installs legion from GitHub at the pinned commit 803873b ("Rename flock to legion (#135)") instead of carrying a copy of 16 of its files. world/src/, world/vendor.sh and world/source-lock.json are deleted.

Why

legion is public now. Installing the exact commit replaces the copy, its sha256 lock and the re-vendoring script, and a bump becomes one changed line plus a regenerated requirements.txt.

How

  • world/Dockerfile installs legion @ git+https://github.com/huggingface/legion@803873b… with --no-deps, in its own pip install after the hashed requirements.txt. pip refuses VCS requirements in --require-hashes mode, so the full commit SHA is what pins legion's source. pip builds the wheel with an unpinned hatchling in build isolation, and none of it stays in the image. That line is the only place the pin lives.
  • requirements.txt is unchanged: re-exporting legion's uv.lock at 803873b with vendor.sh's uv export command gives the same bytes.
  • entrypoint.sh unsets PYTHONPATH instead of setting it to src/, so a host PYTHONPATH (pyxis) still can't shadow the image's legion. The image drops ENV PYTHONPATH, and the sidecar's python sandbox.py serve finds legion in site-packages.
  • tests/conftest.py and both scripts/ put only world/ on sys.path, and their sidecar subprocesses no longer get a PYTHONPATH.
  • README: updated file table, a new "The legion pin" section (where the commit lives, how to bump it), and Checks installs legion from the Dockerfile's line.
  • No changes to pybot.py, repository.py, sandbox.py, snapshot.py, the seed or the task. Bots still run under python -I -S with python_only=True isolation, so legion's new location doesn't change the sandbox's mounts.

Testing

Before editing, I checked that main's 16 vendored files (c786dae) match legion at 803873b and the sha256s in source-lock.json. The installed package matches too.

Both runs use Python 3.12.16 with pip install --no-deps --require-hashes -r requirements.txt. The "after" run also installs legion the way the Dockerfile does.

before (vendored, c786dae) after
python -m pytest -n 8 142 passed 142 passed
scripts/smoke-local.py --sidecar ok ok
scripts/smoke-local.py ok; run_bot note (no unshare here) same
scripts/check-sidecar.py PASS PASS
  • Entrypoint with a host PYTHONPATH set to the old src/: pybot.py starts with PYTHONPATH unset and imports the installed legion (checked with a stub python).
  • Without legion installed, the tests stop at collection with No module named 'legion'.
  • Not tried: building the image (no docker or podman available), or a real run on HF Jobs or Slurm.

Known gaps

  • Follow-up in legion: experiments/pybot/spec.yaml takes the pybot revision from PYBOT_TASK_REVISION, which legion PR #136 documents as c786dae. Bump it to this PR's merge commit once this is merged.

🤖 Generated with Claude Code

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment