Skip to content

Add YAML validator; sync allow-lists with METIS_Pipeline classification#181

Open
astronomyk wants to merge 4 commits into
mainfrom
leschinski/yaml-validation
Open

Add YAML validator; sync allow-lists with METIS_Pipeline classification#181
astronomyk wants to merge 4 commits into
mainfrom
leschinski/yaml-validation

Conversation

@astronomyk
Copy link
Copy Markdown
Contributor

Summary

  • Add YAML/validate_yamls.py — scans every YAML under YAML/, checks (1) PyYAML parseability, (2) static validation via metis_simulations.runRecipes.validate_recipes, (3) acceptance by runSimulationBlock (with simulate stubbed). Writes a per-file markdown report to YAML/yaml_validation_report.md.
  • Refactor runRecipes.validateYAML into a reusable module-level validate_recipes(rcps) -> list[str]; fix the early-return bug on line 204 that was silencing the filter/catg/tech/type/nObs/ndit/dit checks.
  • Sync simulationDefinitions.py allow-lists with the canonical DPR.CATG/.TECH/.TYPE values from METIS_Pipeline/metisp/workflows/metis/metis_classification.py (treated as authoritative): fix PUP,MPUP,LM; add IFU; add DARK, FLAT,TWILIGHT, FLAT,LAMP,PINH, RSRF, PERSISTENCE; de-dup lss_m; add all wcu_* modes; add ND-2.8; widen LSS filter lists to include matching-band imaging filters (shared filter wheel).
  • Rename DARK,WCU_OFFDARK,WCUOFF in testYAML.yaml to match the classification form (the three wcuOff*.yaml files were already corrected by the kl/yaml_wcoOff_hotfix on main and merged in here).

After these changes the validator report goes from 14 passing / 65 static failures to 66 passing / 5 static failures. The remaining 5 static failures are genuine YAML bugs for the authors to address (missing filter_name in calib.yaml::IFU_DISTORTION_RAW, empty chophomeN.yaml, etc.).

Test plan

  • python YAML/validate_yamls.py runs clean and produces YAML/yaml_validation_report.md.
  • Non-zero exit when any file fails; zero exit when everything passes.
  • Report contains the three sections (PyYAML / Static / runSimulationBlock acceptance) and a Passing files list; a file only appears in Passing when it clears all three checks.
  • from metis_simulations.runRecipes import validate_recipes works without ScopeSim/IRDB installed (the validator pre-stubs scopesimWrapper and raw_script).
  • Existing runRecipes.validateYAML(...) callers still work — it's a thin wrapper over validate_recipes.

🤖 Generated with Claude Code

astronomyk and others added 4 commits April 17, 2026 13:33
Scans YAML/ recursively, checks each file parses with PyYAML and is
accepted by runSimulationBlock (with simulate stubbed out), and writes
a markdown report identifying the offending top-level entries in any
file that fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extracts validateYAML's checks into a standalone
validate_recipes(rcps) -> list[str] function in runRecipes. The
previous validateYAML exited early inside its first for-loop, so the
filter/ND/catg/tech/type/mode/positivity checks never ran; they do
now. validateYAML is a thin wrapper that prints each message.

validate_yamls.py now calls validate_recipes as a static-validation
step between PyYAML parse and runSimulationBlock acceptance. The
markdown report gains a third category and files must clear all three
to count as passing. metis_simulations.raw_script is also stubbed so
importing runRecipes doesn't pull in ScopeSim at validator startup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sync catgVals / techVals / typeVals / modeVals / validFilters / validND
in simulationDefinitions.py with the canonical DPR.CATG / .TECH / .TYPE
values declared in METIS_Pipeline's metis_classification.py.

Fixes:
- techVals: PUP,M typo -> PUP,LM; add IFU (pipeline canonical form)
- typeVals: add DARK, FLAT,TWILIGHT, FLAT,LAMP,PINH, RSRF, PERSISTENCE
- modeVals: de-dup lss_m, add all wcu_* ScopeSim modes
- validND: add ND-2.8
- validFilters: add wcu_* entries; widen LSS lists to include the
  matching-band imaging filters (shared filter wheel; used by AIT
  transmission sweeps)

Renames the stray DARK,WCU_OFF (underscore) occurrences in six YAML
files to DARK,WCUOFF to match classification.

Static-validation failures drop from 65 to 7; remaining 7 are genuine
YAML bugs (missing nObs/filter_name, indentation error under source:).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ation

# Conflicts:
#	YAML/ESO/wcuOffIFU.yaml
#	YAML/ESO/wcuOffLM.yaml
#	YAML/ESO/wcuOffN.yaml
@astronomyk astronomyk requested a review from JenniferKarr April 17, 2026 12:40
@@ -0,0 +1,1023 @@
# YAML validation report

- YAML root: `D:\Repos\METIS_Simulations\YAML`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not include code specific to your machine in the repository. This makes the report non-deterministic, meaning that everyone else would get a dirty repository when they run the validation script.

Also, why do we need this file at all in the repoitory if it can be generated?

Comment on lines +18 to +20
# DPR.CATG / .TYPE / .TECH values below follow the pipeline classification
# rules in METIS_Pipeline/metisp/workflows/metis/metis_classification.py,
# which is the authoritative source. A few extensions are kept for YAML
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you are only rewriting what is already there, and this got better so this comment should not be a blocker, but still: why not import the canonical source directly?

I know one reason why, because the workflow directory of the pipeline is currently not in the pymetis package. But then please go and fix that, instead of propagating hacks.

@hugobuddel
Copy link
Copy Markdown
Contributor

hugobuddel commented Apr 18, 2026

Great for making these!

However, the problem is not the availability of these scripts, but that people simply ignore them.

I've created https://github.com/AstarVienna/METIS_Simulations/blob/main/metis_simulations/compare_yaml_with_drld.py that is subsequently only maintained and ran by me.

So a bigger problem is that many people don't seem to care about such consistency at all. Most of us could write such a validator script, especially with help of Claude. But it seems I'm the only one doing so.

Therefore, I think you would be of bigger service to the group by putting on your manager head and make the team care about the importance of such validators. Then we can (have the clanker) write them ourselves.

Edit: we obviously do care about consistency, but we don't care enough to actually ensure consistency.

@astronomyk
Copy link
Copy Markdown
Contributor Author

astronomyk commented Apr 18, 2026 via email

@hugobuddel
Copy link
Copy Markdown
Contributor

I think we all agree that METIS_Simulations was originally never meant as production-ready code for a wider audience

Did I create the repository? I think so, since the first commit is mine. It was my goal to have different sets of simulations in here from the beginning. Basically a shared set of 'this is interesting data for METIS', as a consortium-wide collaboration. That's why initially there were different directories for different categories, and I'm happy these directories are back!

I'm fine with how the repository developed; because the people that do the actual work should have the freedom to do it the way they feel comfortable. And the repository is shaping up nicely with the recent developments!

Having yet another validator script does not add too much value I think; in fact, it adds negative value if the script is not ran or maintained. The existing YAML validation script is broken and thus adds only noise. I'll be happy to be proven wrong though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants