Repository navigation
Ig 016 serializable diagnostics and config containers - #20
Conversation
…rializableConfig`'s purview; add `Parameters` class specifically for storing simple dicts; add `_Diagnostic` class for pre- and post-simulation analyses and standardized storage; add triggers to `Simulation` to run `_Diagnostic.analyze`
…eDiagnostic` to handle particle selection and loading; add beam moment expansion diagnostic
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
|
@claude , please review this PR. |
|
Claude finished @joshmann-inversionsemi's task in 2m 23s —— View job PR review: serializable diagnostics and config containers
Overall the design is solid. Diagnostics are kept out of 1. Diagnostics never run when a run is skipped as already done, so the demo silently writes no results
Diagnostics aren't part of the hash, and post-run diagnostics only read output files already on disk. So they could still run when stepping is skipped. Two options: run post-run diagnostics in the skipped branch, or document the behavior and make the demo log a warning when 2. A failed analysis forces the whole simulation to run again
3.
|
… save hash before post-analysis
…g after construction to `ConfigContainer`
|
I have addressed some of the major concerns; please provide another review @claude |
|
Claude finished @joshmann-inversionsemi's task in 1m 2s —— View job PR re-review: serializable diagnostics and config containers
I couldn't run Status of the earlier findings
The control flow for #1 and #2 looks right to me. Setup that is skipped as already done returns with Remaining concernsA.
|
|
The first issue is not a problem; overwriting old runs is not supported. One last check, @claude |
|
Claude finished @joshmann-inversionsemi's task in 51s —— View job Final check: serializable diagnostics and config containers
No blocking issues. This looks ready to merge. Your responses to the open items
Merge with
|
|
@cedoss-inversion , ready for artisanal review! |
cedoss-inversion
left a comment
There was a problem hiding this comment.
Just some questions on how I would do some FBPIC tasks in practice. Otherwise the demo looks great and would definitely want something like this for the bulk simulation set
Summary
A
Simulationcan now carry diagnostics (analysis that runs automatically and saves its results with the config) and parameters (curated input metadata). Both are serializable like the other config objects. A newConfigContainermay be used to group them.What's new
Parameters(datapoint.py): stores a plain dict of user inputs as metadata. The simulation never interprets it._Diagnostic(diagnostics.py): abstract base class. Subclasses implement_analyze() -> dict.analyze()stores the results indataand setsanalysis_complete. Analysis never runs during construction, loading, or serialization.RUN_BEFORE_SIMULATIONon a subclass runs it at the end of setup. The default is after the full simulation run._ParticleDiagnostic: base class for diagnostics that need particles.load_particles()reads the highest-numbereddata########.h5dump at analysis time.selectiontakes("elec_name" | "ion_name", name or names)or("all_of_species", species)."e"means all electrons.MomentDescriptorDiagnostic: the first concrete diagnostic. It wrapscompute_moment_descriptorand defaults to the 33-feature spline descriptor.ConfigContainer(config_container.py): an ordered, nestable list of configs. Entries can be objects, dicts, YAML/JSON strings, or file paths.Simulationaccepts all of the above inelements. It exposes them assim.diagnosticsandsim.parameters, and runs diagnostics on the write rank only.Usage
This is from the ionization demo (run_simulation.py):
Behavior notes
is_setupfalse, and a failed post-simulation diagnostic records no completion hash.SerializableConfigfixes:from_anyno longer swallows everyOSError. OnlyENAMETOOLONGandEINVALfall back to parsing the string as a dict.README_LIB.mdand the.pyistubs are updated. The demo and its README show the new usage.