Merged
Conversation
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR focuses on enhancing the HDF5 file reading functionality by introducing property mapping support and adding a factory class for property instantiation. The main goal is to allow users to specify how properties should be mapped to specific classes when reading from HDF5 files, rather than defaulting to the generic PropertyBaseModel class.
- Adds property_map parameter to create_dataset_from_hdf5 function for mapping property names to specific classes
- Implements PropertyFactory class for programmatic property instantiation based on string names
- Updates comprehensive test coverage for both new features and property mapping scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| modelforge-curate/modelforge/curate/tests/test_curate.py | Adds extensive test coverage for HDF5 reading with property mapping and PropertyFactory functionality |
| modelforge-curate/modelforge/curate/sourcedataset.py | Enhances create_dataset_from_hdf5 function with property_map parameter support |
| modelforge-curate/modelforge/curate/properties.py | Implements PropertyFactory class for creating property instances from string names |
| modelforge-curate/modelforge/curate/examples/basic_usage.ipynb | Updates notebook with demonstration of property mapping usage and corrects typos |
Comments suppressed due to low confidence (1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Summary
This is a very small PR that focuses on making minor changes to the function that allows you to read an HDF5 file back into a SourceDataset instance. This function now will take a "property_map" that maps the name of a property in the HDF5 file to a specific class (e.g., "dft_energy" to the Energies class in properties). Since the name of a property can be anything, we cannot necessarily infer it.
Previously, these were simply loaded into the PropertyBaseModel class; while that class has the same variables (name, units, value, property_type, classification), as it is the parent for all the actual properties we define, it does not contain any of the specific validation functions associated with a given property. Also, if writing the dataset to an hdf5 file, lots of warnings will be logged since I have a check that requires instances of
AtomicNumbers,PositionsandEnergiesto be in every record (as the minimum info required by modelforge).I also added a factory class that allows a user to generate an instance of a class based on its name as a string (so passing "positions" will return an instance of the
Positionsclass). I ended up not using this, but left the code (with tests) as it may ultimately be useful.Associated Issue(s)
Pull Request Checklist