Repository navigation
fix(lifecycle): keep failed commands' output, cap it at 1024 lines, pass false parameters - #162
Merged
Merged
Conversation
configure.arguments skipped every parameter whose value was falsy, so False, 0 and "" were silently replaced by the command's defaults, and on/off flags (e.g. --trace/--no-trace) could never be turned off. Only missing (None) parameters now fall back to the defaults; a flag set to False is passed by its secondary name (--no-trace) when it has one, and left off otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
execute.command checked the return code before storing stdout and stderr, so a failed command's Work had no output at all, only the logged CalledProcessError. The output is now stored first; a command stopped by its timeout keeps what it printed before it was killed (returncode None). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A command's whole stdout was saved in its Work's results, and so in the Buckets and Results databases, which keep it with no retention (one baseband localization Work holds about 3 MB of output). Only its last 1024 lines are kept now, which still include the last line that results are read from; stderr is kept whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Programs that use Python logging write it to stderr by default, so stderr is where most output is (34,000 of 36,000 lines for a baseband localization). Both streams are now capped at their last 1024 lines (OUTPUT_LINES), which still include a failure's traceback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runner's spinner was forced on even without a terminal, so in a container every frame was written to its logs, once a second for the whole run (5,209 frames in one localization's saved logs). It is now only shown when stdout or stderr is a terminal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
masonng-astro
approved these changes
Nov 1, 2026
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.
Why
Runner bugs, and the size of saved output, found while running the baseband localization pipeline on CANFAR through static configs (CHIMEFRB/baseband-analysis#661):
execute.commandcalledprocess.check_returncode()before storingstdoutandstderr, so when a command exits non-zero its Work has no output, only the loggedCalledProcessError. Those are the runs where the output is needed most. The same happened when a command hit its timeout.configure.argumentsskipped every falsy value (if parameter_value_in_work:), soFalse,0and""were silently replaced by the command's defaults. On/off flags couldn't be turned off:trace: falsefor a--trace/--no-traceoption (default on) still ran with tracing. The runner also only ever passed a flag's "on" name.workflow runforced its spinner on (Console(force_terminal=True)) even without a terminal, slowed to 1 frame/s, so every frame went into the container's logs for the whole run: 5,209 frames in one localization's saved step logs, each on its own line.What
execute.commandstores the output in the Work's results (newoutput()helper) before checking the return code. A failed command is still markedfailure, now with itsstdout,stderrandreturncode. A command stopped by its timeout keeps what it printed before it was killed, withreturncode: None.OUTPUT_LINES). That still includes a failure's traceback, and the last line of stdout, which results are read from.configure.argumentsonly leaves a parameter to its default when it's missing (None). A flag set toFalseis passed by its secondary name (--no-trace) when it has one, and left off otherwise.0and""are passed as values.workflow runonly shows the spinner when stdout or stderr is a terminal.Tests
tests/test_run.py::test_run_without_a_terminal_writes_no_spinnerrunsworkflow runwithout a terminal (backends, workspace and lifecycle stubbed) and checks that no spinner frames are written; it fails without the fix.tests/test_lifecycle.py:trace: false→--no-trace,trace: true→--trace, a plain flag set toFalseis left off,0and""are passed,Nonefalls back to the default, and click parses them back to the values given.All lifecycle tests and the new run test pass, and pre-commit passes.
tests/test_run.py::test_complete_work_runandtests/test_cli.py::TestWorkspaceCLI::test_workflow_buckets_clifail locally onmaintoo (they need local Buckets/Results servers).Notes
configure.defaults()has the same falsy handling but isn't called anywhere, so it's left as is.validate.sizemeasuressys.getsizeof(work.results), which is only the dict's own size, not its contents, so the 4 MB check never triggers. Not changed here.🤖 Generated with Claude Code