Skip to content

Add export for MechanismConfig#346

Merged
K20shores merged 3 commits intoNCAR:mainfrom
DeeGrant:add-export
Jun 17, 2025
Merged

Add export for MechanismConfig#346
K20shores merged 3 commits intoNCAR:mainfrom
DeeGrant:add-export

Conversation

@DeeGrant
Copy link
Copy Markdown
Collaborator

@DeeGrant DeeGrant commented May 15, 2025

Work completed for issue #345

  • Add export option to Mechanism
  • Added tests for serializer / exporter
  • Moved testing mechanism to separate file
  • Bug: removed gas_phase property from AqueousEquilibrium, wasn't supported by importer

Items pushed to a later PR

  • Finish Edge case testing
  • Add logging
  • Separate mechanism_configuration.py into smaller files

@DeeGrant
Copy link
Copy Markdown
Collaborator Author

Resolved conflicts - reopening pull request

@DeeGrant DeeGrant reopened this Jun 16, 2025
@DeeGrant DeeGrant requested a review from K20shores June 16, 2025 20:42
@DeeGrant DeeGrant marked this pull request as ready for review June 16, 2025 21:11
@K20shores K20shores requested review from boulderdaze and Copilot June 16, 2025 21:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new export pathway for Mechanism via a Serializer and updates related examples and tests.

  • Adds pyyaml as a dependency for YAML export.
  • Implements Serializer with to_dict/export on Mechanism and serialize static methods on reaction classes.
  • Updates example files and adds tests to verify export behavior.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Added pyyaml>=6.0.2 dependency for YAML support.
musica/mechanism_configuration.py Introduced Serializer, to_dict, export and class-specific serialize methods.
musica/mechanism_configuration.cpp Removed the gas_phase binding for AqueousEquilibrium to match Python changes.
musica/test/test_serializer.py New tests covering exporting via export and Serializer.
musica/test/examples/v1/full_configuration/full_configuration.yaml Inserted __irrelevant fields in the YAML example.
musica/test/examples/v1/full_configuration/full_configuration.json Inserted __irrelevant fields in the JSON example.
Comments suppressed due to low confidence (2)

musica/mechanism_configuration.py:1113

  • The __init__ signature still includes a gas_phase parameter that is no longer assigned in the body; remove this parameter to avoid unused or misleading parameters.
def __init__(

musica/test/test_serializer.py:47

  • [nitpick] Consider adding a test for unsupported file extensions (e.g., .txt) to ensure serialize() raises the expected exception for invalid formats.
with pytest.raises(TypeError):

@K20shores
Copy link
Copy Markdown
Collaborator

The fetch content errors happen because this branch lives on a fork. We can ignore those errors. The other windows actions that are failing are the same as in #374

Copy link
Copy Markdown
Collaborator

@boulderdaze boulderdaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@K20shores K20shores requested a review from mattldawson June 16, 2025 22:42
Copy link
Copy Markdown
Collaborator

@mattldawson mattldawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!

@K20shores K20shores merged commit 3e1f85d into NCAR:main Jun 17, 2025
65 of 70 checks passed
@DeeGrant DeeGrant deleted the add-export branch June 17, 2025 17:40
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.

5 participants