Repository navigation
Add a headless mode for running without a display - #67
Merged
Merged
Conversation
Running the diagnostics one after another stops on a plot window, because
frc/frc_calc2d.py has show_plot = True by default and
diagnostics/frc/analyze_data.py calls it without saying otherwise, once
per test directory. Its command line already has --no-plot; only the
programmatic call was missing the equivalent.
Two changes, because the immediate cause and the general one are
different.
The call site now passes show_plot = False. An analyze step that loops
over directories should never wait for anyone.
And STORM_ANALYSIS_HEADLESS in the environment now selects a
non-interactive matplotlib backend, in __init__.py, before pyplot is
imported. That makes every pyplot.show() in the package a no-op, all
twenty one of them, without touching a single call site. Worth having
because the flags that control this are not consistent:
frc/frc_calc2d.py show_plot default True
multi_plane/plane_weighting no_plots inverted sense
rcc/rcc_drift_correction make_plots
micrometry/micrometry show, save_as
Four names, three spellings, one inverted. Anyone adding a diagnostic has
to know which one applies, and the failure is a hung script rather than
an error.
Figures written to disk are unaffected: savefig() works the same under
Agg, and the multicolor diagnostic still produces its three mapping
images. Checked rather than assumed, both by writing a file directly and
by re-running that diagnostic headless.
Verified that the default is unchanged, tkagg here, and that with the
variable set the backend is Agg and show() returns instead of blocking.
Also isHeadless(), for code that wants to skip building a figure it
cannot display.
The diagnostics README says how to use it, and, while there, that
multiplane/configure.py needs --psf-model.
Co-Authored-By: Claude Opus 5 <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.
Running the diagnostics one after another stops on a plot window.
frc/frc_calc2d.pyhasshow_plot = Trueby default anddiagnostics/frc/analyze_data.pycalls it without saying otherwise, once pertest directory. Its command line already has
--no-plot; only theprogrammatic call was missing the equivalent.
Two changes, because the immediate cause and the general one are different.
The call site
diagnostics/frc/analyze_data.pynow passesshow_plot = False. An analyzestep that loops over directories should never wait for someone to close a
window.
The general case
STORM_ANALYSIS_HEADLESSin the environment now selects a non-interactivematplotlib backend, set in
__init__.pybeforepyplotis imported. Thatmakes every
pyplot.show()in the package a no-op — all 21 of them — withouttouching a single call site.
Worth having because the flags controlling this are not consistent:
frc/frc_calc2d.pyshow_plotmulti_plane/plane_weighting.pyno_plotsrcc/rcc_drift_correction.pymake_plotsmicrometry/micrometry.pyshow,save_asFour flags, three spellings, one inverted. Anyone adding a diagnostic has to
know which applies, and getting it wrong produces a hung script rather than an
error.
Figures written to disk are unaffected
savefig()works the same under Agg. Checked rather than assumed: directly,and by re-running the multicolor diagnostic headless and confirming it still
produces its three mapping images.
Verified that the default is unchanged (
tkagghere), that with the variableset the backend is
Aggandshow()returns instead of blocking, and thatthe frc diagnostic's analyze step drops from 9s to 2s because it no longer
builds the figure.
Also adds
isHeadless(), for code that would rather skip building a figure itcannot display.
The diagnostics README says how to use it, and — while there — that
multiplane/configure.pyneeds--psf-model, which is the one thing in thatdirectory you cannot work out from the README.
Full test suite passes, 280 tests. All 17 diagnostics were then run end to
end with this branch, 68 steps, no failures; multiplane was run three times,
once per PSF model.