Standardize CLI output into a pipeline-friendly envelope - #119
Merged
Conversation
Every --json command now wraps its payload in one common shape so a downstream tool can read the same keys regardless of which command produced it: tool, version, command, input, parser (the reader chosen from the extension), backends (optional packages the run actually engaged), warnings, and result. New molscope/cli_output.py holds the shared helpers (envelope, parser detection, and an honest "backends used this run" snapshot-and-diff over sys.modules). Applied to qc, structure-report, compare, preflight and presets. The batch commands gain --manifest PATH (analyze, export): the same envelope written alongside the outputs with feature_names (CSV columns / graph node+edge features) and skipped (one entry per input that failed, with the reason). The analyze/export workers now return structured (path, result, error) outcomes so skips are captured rather than only printed to stderr. BREAKING (CLI output): the five --json commands above now emit the envelope instead of the bare report; previous top-level fields move under "result" (presets --json is now an object, not a bare list). Updated the affected tests and documented the change in README and CHANGELOG. Adds tests/test_cli_output.py.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
What
Makes CLI output predictable for scripting. Every
--jsoncommand now wraps its payload in one common envelope, so a downstream tool reads the same keys no matter which command produced the JSON:{ "tool": "molscope", "version": "0.16.0", "command": "qc", "input": "3ptb.pdb", // path/id, or a list for batch commands "parser": "pdb", // reader chosen from the extension "backends": ["scipy"], // optional packages this run engaged "warnings": [ ... ], "result": { ... } // command-specific payload }Applied to
qc,structure-report,compare,preflight,presets.Batch run manifests
analyzeandexportgain--manifest PATH, which writes the same envelope alongside the outputs with:feature_names— the CSV descriptor columns (analyze) / graph node+edge feature names (export)skipped— one{input, error}per file that failed (previously only printed to stderr)n_inputs/n_written, plusoutput/out_dir/to/presetThe
analyze/exportworkers now return structured(path, result, error)outcomes so skips are captured, not just logged.Honest
backendsbackendsis computed by snapshottingsys.modulesat the handler entry and reporting which optional packages (rdkit,gemmi,scipy,torch,torch_geometric,dgl,networkx, ...) were imported during the run — an accurate "engaged this run" signal in a one-shot CLI process, and snapshot-diffed so it stays correct in the long-lived test process too.The five
--jsoncommands now emit the envelope instead of the bare report; previous top-level fields move underresult(e.g.payload["ligands"]→payload["result"]["ligands"], andpresets --jsonis now an object, not a bare list). Documented under Changed in the CHANGELOG. No Python API changes.Scope
Covers the inspection
--jsoncommands and the two feature-producing batch commands — wherefeature_names/skippedactually apply. The docking-triage andselect/binding-siteCSV commands keep their established multi-file outputs (theirfilecolumns already carry the input path); a manifest for those is a natural follow-up.Tests & docs
tests/test_cli_output.py(helpers + end-to-end envelope + manifests, incl. all-skipped and partial-skip cases);cli_output.py98% covered. Updated the 5 tests that asserted the old flat shape.ruff checkclean.