Skip to content

tools: add gidopensees .mat/.cnd schema parser#2

Merged
ogunc merged 1 commit into
mainfrom
feat/gidopensees-schema-parser
May 22, 2026
Merged

tools: add gidopensees .mat/.cnd schema parser#2
ogunc merged 1 commit into
mainfrom
feat/gidopensees-schema-parser

Conversation

@ogunc

@ogunc ogunc commented May 22, 2026

Copy link
Copy Markdown
Owner

Deliverables

  • tools/gidopensees_import/schema_model.py — Pydantic v2 IR models (DependencyAction, DependencyRule, FieldSpec, EntrySpec, BookSpec, CatalogSpec)
  • tools/gidopensees_import/parse_schemas.py — line-by-line state-machine parser + CLI (python -m tools.gidopensees_import.parse_schemas --mat … --cnd … --out …)
  • tools/gidopensees_import/schemas.json — committed output of the parser run
    against gidopensees@HEAD (918 KB, regenerable; checked in for diffable reviews)
  • tests/tools/test_parse_schemas.py — 42 passing tests (unit + snapshot +
    integration); integration tests auto-skip when gidopensees repo is absent

Parser features

  • Handles CRLF/LF, blank lines, leading whitespace; UTF-8 with latin-1 fallback
  • QUESTION types: CB (combo), UNITS, MAT (material ref), SCALAR, TUPLE
  • VALUE: strips #WIDTH#(N) hint into width_hint field; preserves #N# prefix raw
  • DEPENDENCIES: supports single group per line, multiple space-separated groups per line, RESTORE/HIDE/SET actions, literal and #CURRENT# targets
  • TKWIDGET attribution: follows most recent QUESTION; falls back to entry-level
  • TITLE: directives stored as section_title on subsequent fields
  • STATE: HIDDEN / DISABLED preserved on fields
  • END_CONDITION (no space) and END CONDITION (with space) both handled
  • Fails loudly with ParseError(path, lineno, message) on malformed input

Verified counts against real gidopensees files

  • .mat: 14 books, 58 materials
  • .cnd: 6 books, 39 conditions
  • Steel02: fields include Steel_grade, Yield_Stress_Fy, Strain-hardening_ratio_b, Parameter_R0, Parameter_cR1, Parameter_cR2; Formulation has 3 dependency rules
  • Concrete04_(Popovics_concrete): book = Uniaxial_Concrete_Materials

Manual Verification checklist (for reviewer)

  • Open tools/gidopensees_import/schemas.json; spot-check Steel02 fields against OpenSees.mat lines 523-594 — field names, options, defaults.
  • Spot-check Concrete04_(Popovics_concrete) in schemas.json against OpenSees.mat lines 901-958.
  • Confirm mat_books[0].entries count == 10 (Standard_Uniaxial_Materials book).
  • Confirm schemas.json contains exactly 58 mat entries in total.
  • Confirm no src/, tests/unit/, or pyproject.toml files were modified.
  • Run: python -m tools.gidopensees_import.parse_schemas --mat … --cnd … --out /tmp/test.json and diff against tools/gidopensees_import/schemas.json — must be identical.

Summary

Linked issue

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • CI / tooling

Architectural checklist

  • No from PySide6 in core/ or services/
  • No import openseespy in core/ or views/
  • Public functions have type hints + docstrings
  • Heavy work runs off the GUI thread

Testing

Deliverables
- tools/gidopensees_import/schema_model.py  — Pydantic v2 IR models
  (DependencyAction, DependencyRule, FieldSpec, EntrySpec, BookSpec, CatalogSpec)
- tools/gidopensees_import/parse_schemas.py — line-by-line state-machine parser +
  CLI (python -m tools.gidopensees_import.parse_schemas --mat … --cnd … --out …)
- tools/gidopensees_import/schemas.json     — committed output of the parser run
  against gidopensees@HEAD (918 KB, regenerable; checked in for diffable reviews)
- tests/tools/test_parse_schemas.py         — 42 passing tests (unit + snapshot +
  integration); integration tests auto-skip when gidopensees repo is absent

Parser features
- Handles CRLF/LF, blank lines, leading whitespace; UTF-8 with latin-1 fallback
- QUESTION types: CB (combo), UNITS, MAT (material ref), SCALAR, TUPLE
- VALUE: strips #WIDTH#(N) hint into width_hint field; preserves #N# prefix raw
- DEPENDENCIES: supports single group per line, multiple space-separated groups
  per line, RESTORE/HIDE/SET actions, literal and #CURRENT# targets
- TKWIDGET attribution: follows most recent QUESTION; falls back to entry-level
- TITLE: directives stored as section_title on subsequent fields
- STATE: HIDDEN / DISABLED preserved on fields
- END_CONDITION (no space) and END CONDITION (with space) both handled
- Fails loudly with ParseError(path, lineno, message) on malformed input

Verified counts against real gidopensees files
- .mat: 14 books, 58 materials
- .cnd: 6 books, 39 conditions
- Steel02: fields include Steel_grade, Yield_Stress_Fy, Strain-hardening_ratio_b,
  Parameter_R0, Parameter_cR1, Parameter_cR2; Formulation has 3 dependency rules
- Concrete04_(Popovics_concrete): book = Uniaxial_Concrete_Materials

Manual Verification checklist (for reviewer)
- [ ] Open tools/gidopensees_import/schemas.json; spot-check Steel02 fields
      against OpenSees.mat lines 523-594 — field names, options, defaults.
- [ ] Spot-check Concrete04_(Popovics_concrete) in schemas.json against
      OpenSees.mat lines 901-958.
- [ ] Confirm mat_books[0].entries count == 10 (Standard_Uniaxial_Materials book).
- [ ] Confirm schemas.json contains exactly 58 mat entries in total.
- [ ] Confirm no src/, tests/unit/, or pyproject.toml files were modified.
- [ ] Run: python -m tools.gidopensees_import.parse_schemas --mat … --cnd … --out /tmp/test.json
      and diff against tools/gidopensees_import/schemas.json — must be identical.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ogunc
ogunc merged commit 73b8d5d into main May 22, 2026
1 of 2 checks passed
@ogunc
ogunc deleted the feat/gidopensees-schema-parser branch June 5, 2026 18:22
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.

1 participant