P1-10 — Write the contract parser.
- Write
parser.py.
ContractParser.parse reads a results file and generates a draft contract.
- It fills dtype and shape from the file and merges attrs from the rules artifact.
- Cross-check the target against any rules artifact for the module: the parser derives
filepath from a real filename, so it is the authority. Warn — never fail — when a rules
artifact for that module declares a different module_name or filepath, and print the
tools/rules_convert.py --module-name ... --filepath ... invocation that would reconcile it.
- Reuse the shared match helper rather than reimplementing the comparison:
tools/rules_convert.py
(check_target, added in P1-8) and the P1-17 registry cross-check apply the same rule, so the
three must not drift.
- Wire it to
cit parse.
AC:
cit parse --module momma --results <sample .nc> --rules rules.yml -o momma.yml produces a usable draft with the source and version scaffold.
- Parsing a module whose rules artifact declares a different
module_name or filepath warns,
names both the rules value and the derived value, and still writes the draft.
- Parsing a module with no rules artifact produces no such warning.
P1-10 — Write the contract parser.
parser.py.ContractParser.parsereads a results file and generates a draft contract.filepathfrom a real filename, so it is the authority. Warn — never fail — when a rulesartifact for that module declares a different
module_nameorfilepath, and print thetools/rules_convert.py --module-name ... --filepath ...invocation that would reconcile it.tools/rules_convert.py(
check_target, added in P1-8) and the P1-17 registry cross-check apply the same rule, so thethree must not drift.
cit parse.AC:
cit parse --module momma --results <sample .nc> --rules rules.yml -o momma.ymlproduces a usable draft with the source and version scaffold.module_nameorfilepathwarns,names both the rules value and the derived value, and still writes the draft.