Skip to content

Write the contract parser #11

Description

@nikki-t

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions