Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On-demand constraint-tailoring to dataset arguments #260

Merged
merged 2 commits into from
Feb 24, 2023

Conversation

mih
Copy link
Member

@mih mih commented Feb 24, 2023

This exposes a, so far dormant, feature of the Constraint class to
parameter validation: constraint tailoring for particular datasets.

EnsureCommandParameterization learned a tailor_for_dataset parameter
that can be used to identify which parameters' constraints should be
tailored for which Dataset instances. Tailoring will only be actually
done under the following conditions:

  • the dataset-providing parameters need to evaluate to a
    DatasetParameter instance, typically via EnsureDataset
    (all regular conditions apply, e.g. a default None not being processed
    etc)
  • the to-be-tailored parameter Constraint needs to implement its
    for_dataset() method to perform a tailoring.

A test with some custom-made constraints is included. At the moment,
no production-ready constraints do implement for_dataset(). However,
now that a consumer for that is available, it makes more sense to
address related issues, such as:

Closes #200

This exposes a, so far dormant, feature of the `Constraint` class to
parameter validation: constraint tailoring for particular datasets.

`EnsureCommandParameterization` learned a `tailor_for_dataset` parameter
that can be used to identify which parameters' constraints should be
tailored for which `Dataset` instances. Tailoring will only be actually
done under the following conditions:

- the dataset-providing parameters need to evaluate to a
  DatasetParameter instance, typically via `EnsureDataset`
  (all regular conditions apply, e.g. a default `None` not being processed
  etc)
- the to-be-tailored parameter `Constraint` needs to implement its
  `for_dataset()` method to perform a tailoring.

A test with some custom-made constraints is included. At the moment,
no production-ready constraints do implement `for_dataset()`. However,
now that a consumer for that is available, it makes more sense to
address related issues, such as:

- datalad#193
- datalad#131

Closes datalad#200
@mih
Copy link
Member Author

mih commented Feb 24, 2023

All CI failure is unrelated.

@mih mih merged commit c3f60e9 into datalad:main Feb 24, 2023
@mih mih deleted the dsconstraint branch February 24, 2023 14: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.

Dataset-scope tailoring of EnsureCommandParameterization validation
1 participant