Skip to content

Refactor: allow for dataset-derived traits from loader#6

Merged
leifdenby merged 15 commits intomainfrom
refactor/return-traits-from-loader
Apr 14, 2026
Merged

Refactor: allow for dataset-derived traits from loader#6
leifdenby merged 15 commits intomainfrom
refactor/return-traits-from-loader

Conversation

@leifdenby
Copy link
Copy Markdown
Member

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}_trait e.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 to mlwp_data_specs.validate_dataset(ds=ds, ...)).

As decided on #5 (comment) mlwp-data-loaders always 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. Because mlwp-data-loaders also applies validation now the main API function has been renamed from load_dataset to load_and_validate_dataset to reflect this change.

Implements changes agreed on in #5

    - 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.
@leifdenby leifdenby changed the title Refactor: return traits from loader Refactor: allow for dataset-derived traits from loader Apr 14, 2026
@leifdenby leifdenby merged commit 3fc53f3 into main Apr 14, 2026
3 checks passed
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