Refactor: allow for dataset-derived traits from loader#6
Merged
Conversation
…LI, and update README
- Rename `load_dataset` to `load_and_validate_dataset`.
- Remove static trait profiles from loader modules; loaders now attach `mlwp_{trait}_trait` attributes directly to the returned `xr.Dataset`.
- Import trait attribute constants directly from `mlwp_data_specs.api`.
- Replace `return_dataset_traits` with `return_validation_report` in the API.
- Simplify kwargs handling by removing the explicit `storage_options` parameter and custom signature validation.
- Update CLI, tests, and README to reflect the new loader contract.
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.
This PR refactors the loading API to allow loaders to dynamically set dataset traits based on the contents of the loaded data. These dataset traits are set as global attributes in the format
mlwp_{trait_name}_traite.g.mlwp_space_trait. mlwp-data-specs was recently changed to support the use of these trait values directly from dataset attributes (as well as through call arguments tomlwp_data_specs.validate_dataset(ds=ds, ...)).As decided on #5 (comment)
mlwp-data-loadersalways calls the validator (e.g.mlwp_data_specs.validate_dataset(ds)) directly on the loaded dataset, without needing to extract traits and pass them as separate keyword arguments. Becausemlwp-data-loadersalso applies validation now the main API function has been renamed fromload_datasettoload_and_validate_datasetto reflect this change.Implements changes agreed on in #5