Skip to content

Add cross-language symmetry tests for MATLAB ↔ Python DID databases#19

Merged
stevevanhooser merged 5 commits intomainfrom
claude/add-symmetry-tests-vtgOJ
Mar 16, 2026
Merged

Add cross-language symmetry tests for MATLAB ↔ Python DID databases#19
stevevanhooser merged 5 commits intomainfrom
claude/add-symmetry-tests-vtgOJ

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

This PR introduces a comprehensive cross-language symmetry testing framework that verifies DID databases created in Python can be correctly read by MATLAB and vice versa. The implementation includes CI/CD automation, utility functions for database comparison, and parameterized test suites.

Key Changes

  • GitHub Actions Workflow (.github/workflows/symmetry.yml): Three-stage CI pipeline that:

    1. Runs MATLAB makeArtifact tests to generate database artifacts
    2. Runs Python makeArtifact and readArtifact tests (reading MATLAB artifacts)
    3. Runs MATLAB readArtifact tests (reading Python artifacts)
  • Database Utility Functions:

    • src/did/util/database_summary.py: Generates a comprehensive summary dict of a DID database including branch hierarchy, document counts, and properties
    • src/did/util/compare_database_summary.py: Compares two database summaries and returns detailed discrepancy messages
    • src/did/util/__init__.py: Exports the new utility functions
  • Symmetry Test Suite (tests/symmetry/):

    • make_artifacts/database/test_build_database.py: Creates a multi-branch DID database with documents, exports it as JSON artifacts and a SQLite database file
    • read_artifacts/database/test_build_database.py: Reads artifacts from either Python or MATLAB sources, validates them against a live database summary
    • conftest.py: Shared fixtures and pytest markers for symmetry tests
  • Test Configuration:

    • pyproject.toml: Added pytest markers (symmetry, make_artifacts, read_artifacts) and test path configuration
    • README.md: Updated with instructions for running symmetry tests and explanation of the cross-language testing approach

Implementation Details

  • Tests use a well-known temporary directory structure (<tempdir>/DID/symmetryTest/{pythonArtifacts,matlabArtifacts}/) for artifact exchange between languages
  • The readArtifact tests are parameterized to run against both Python and MATLAB artifact sources, gracefully skipping when artifacts are unavailable
  • Database summaries include branch hierarchy, document metadata, and properties to enable comprehensive cross-language validation
  • Fixed random seeds ensure reproducible test data generation
  • All symmetry tests are auto-marked via pytest hooks based on file path location

https://claude.ai/code/session_01JeFfZ9DvpQws6LUCk5a8E6

claude added 5 commits March 16, 2026 10:48
Add makeArtifact and readArtifact symmetry tests (mirroring DID-matlab's
tests/+did/+symmetry/) that verify DID databases created in Python can be
read by MATLAB and vice versa. Includes:

- tests/symmetry/make_artifacts/ - generates database + JSON summary artifacts
- tests/symmetry/read_artifacts/ - validates artifacts from either language
- src/did/util/ - database_summary and compare_database_summary utilities
- .github/workflows/symmetry.yml - 3-stage CI: MATLAB make -> Python make+read -> MATLAB read
- Updated README with instructions for running test groups separately
- Added pytest markers (symmetry, make_artifacts, read_artifacts)

https://claude.ai/code/session_01JeFfZ9DvpQws6LUCk5a8E6
The MATLAB jobs need MatBox (ehennestad/matbox-actions/install-matbox@v1)
to install project requirements (mksqlite, vhlab-toolbox-matlab) before
running tests. Also adds Statistics_and_Machine_Learning_Toolbox product,
enables MATLAB caching, and uses the proper TestSuite/TestRunner pattern
matching DID-matlab's own test-symmetry.yml workflow.

https://claude.ai/code/session_01JeFfZ9DvpQws6LUCk5a8E6
- Fix black formatting and ruff lint errors (unused imports, re-export aliases)
- Combine all three CI stages (MATLAB make, Python make+read, MATLAB read)
  into a single job so artifacts in the runner's temp directory are shared
  across all steps

https://claude.ai/code/session_01JeFfZ9DvpQws6LUCk5a8E6
- Document.__init__ now properly handles dot-notation kwargs (e.g.,
  'demoA.value=42') by navigating/creating nested dicts, matching
  MATLAB's document_properties structure where demoA.value is a
  nested field
- Fix pre-existing bug in field_search OR operation that required
  params to be dicts (they're lists)
- Update compare_database_summary to compare .value subfield,
  matching MATLAB's compareDatabaseSummary behavior

https://claude.ai/code/session_01JeFfZ9DvpQws6LUCk5a8E6
- Transform flat classname/superclasses from schema files into nested
  document_class structure (class_name, superclasses, etc.) matching
  MATLAB's document definition format
- Fix _normalize_loaded_props to re-wrap string superclasses back into
  lists after SQLite round-trip (was only handling dict→list case)

https://claude.ai/code/session_01JeFfZ9DvpQws6LUCk5a8E6
@stevevanhooser stevevanhooser merged commit cfbf786 into main Mar 16, 2026
5 checks passed
@stevevanhooser stevevanhooser deleted the claude/add-symmetry-tests-vtgOJ branch March 16, 2026 12:58
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