Repository navigation
Conversation
`_run_module` calls each step's entrypoint in-process. Those entrypoints are written as `main(argv=None)` and fall through to `parse_args(argv)`, and with `argv=None` argparse reads `sys.argv[1:]` -- which belongs to the pipeline, not the step. So running `--from dataset_assembly --force --no-zenml` killed the clustering step with "unrecognized arguments: --from dataset_assembly --force", one step from the end of a four-hour chain, and took `figures` with it. It had never surfaced because the systemd unit invoked the pipeline with no arguments at all, leaving `sys.argv[1:]` empty and argparse satisfied. Every historical run took the single path that happens to work; the first run with flags hit it immediately. Three modules parse args this way -- unsupervised_clustering, chain_verification and binding_site -- so the guard goes in `_run_module` rather than at the call sites, where the next one written would miss it. argv is restored in a `finally`, so a failing step cannot leave it clobbered for the steps after it. The tests were checked against the unfixed code: reverting the guard reproduces the production error verbatim.
hallelx2
deleted the
halleluyaholudele/hal-4194-step-bodies-parse-the-pipelines-own-argv
branch
October 25, 2026 11:15
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.
The rebuild completed ten steps and then died one from the end:
_run_modulecalls each step's entrypoint in-process. Those are written asmain(argv=None)and fall through toparse_args(argv)— and withargv=None, argparse readssys.argv[1:], which belongs to the pipeline, not the step. Soclusteringwas handed--from dataset_assembly --force --no-zenml, didn't recognise them, andSystemExit-ed.figuresnever ran.Why four hours of work hit this and nothing before did
The systemd unit invoked the pipeline with no arguments:
ExecStart=/usr/local/bin/uv run --with mlflow python -m cancerag.pipelinesys.argv[1:]was empty, argparse was satisfied, and every historical run took the one path that works. The first run with--from/--forcehit it immediately. A latent bug in a step that only fires when you use the CLI as designed.Change
The guard goes in
_run_module, not the call sites. Three modules parse args this way —unsupervised_clustering,chain_verification,binding_site— and patching three places leaves the next one written exposed. The step is invoked as a function; it should not see a command line at all.sys.argvis restored in afinally, so a failing step cannot leave it clobbered for the steps after it._scriptand_module_cliusesubprocess.run([sys.executable, "-m", module]), which gets a fresh argv — unaffected.Verification
pytest tests/unit— 481 passed, 31 skipped (was 474; +7 here)ruff checkclean on both touched files**kwargsstill reach the entrypoint; and a guard test that flags if any of the three exposed modules stops parsing args, so the issue's exposure list can't silently rotNext: re-run
--from clusteringto finishclusteringandfigures.Closes HAL-4194