Repository navigation
hog run: bootstrap a driver environment from the script's PEP 723 header - #142
Merged
Merged
Conversation
`hog run` imports the script in-process, so a harness (or anything defined
at module level, e.g. a class subclassing a third-party base) needs its
imports available locally, not just on the endpoint. Until now the header
only described the remote environment and users had to reinstall `hog`
with extra packages or repeat the dependency list on the command line.
Now, when the current interpreter does not satisfy requires-python or any
entry in dependencies is not installed, `hog run` re-executes itself as
uv run --no-project --python <requires-python> --with <groundhog spec>
--with <dep>... [--exclude-newer/--index-url/--extra-index-url]
hog run <script> <harness> [-- args]
with GROUNDHOG_BOOTSTRAPPED=1 in the child's environment so a child that
still fails the checks warns and runs in-process instead of looping. When
the environment already satisfies the header nothing changes.
`--no-bootstrap` (or GROUNDHOG_NO_BOOTSTRAP=1) keeps the old behaviour: warn
about the mismatch and run in-process. The old Python-mismatch warning is
subsumed by the bootstrap check.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hog runimports the script in-process, so a harness (or anything defined at module level, e.g. an AcademyAgentsubclass) needs its imports available locally, not just on the endpoint. The PEP 723 header already lists them; this makeshog runuse it.When the current interpreter does not satisfy
requires-python, or anydependenciesentry is not installed (app/utils.py::bootstrap_reasons),hog runre-executes itself aswith
GROUNDHOG_BOOTSTRAPPED=1in the child env (a child that still fails the checks warns and runs in-process, so no loop). Scripts the current environment already satisfies run exactly as before.--no-bootstrapflag /GROUNDHOG_NO_BOOTSTRAP=1: warn and run in-process (the old behaviour). Like--log-level, the flag goes before the script path.get_groundhog_version_spec()(same as the remote side); a0.0.0checkout falls back to its own path.[tool.uv]exclude-newer/index-url/extra-index-urlare forwarded when set.Motivating case: a single-file Academy × groundhog demo whose
Agentclasses needacademy-pyat import time on the laptop. With this,hog run demo.py -- …just works from a plainuv tool install groundhog-hpc.Test plan
uv run pytest(384 passed),uv run ruff check .,uv run ty check .dependencies = ["cowsay"](not installed in the tool env) →Bootstrapping an environment from needs_cowsay.py's metadata (missing dependencies: cowsay)→ harness ran under Python 3.13.9 with cowsay 6.1 imported, ~6 s wall including the env build.hog runtests unchanged (their headers are satisfied → in-process path).Depends on #141 only in the sense that the motivating demo needs both; the diffs are independent.
🤖 Generated with Claude Code