-
Notifications
You must be signed in to change notification settings - Fork 11
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
Dataset-scope tailoring of EnsureCommandParameterization
validation
#200
Comments
With #234 in place, the situation presents itself to me as follows: A simple implicit or explicit order-based tailoring is not sufficient. Any particular command may take more than one Instead, I propose this:
Based on this input, |
I decided to not address this in #234 directly, but have that be merged first. |
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
A dataset often provides a critical piece of information to be able to validate properly and in-depth. For example, the name of an existing remote can only be validated once a dataset is determined in which this remote exists.
Constraints
havefor_dataset()
that is meant to be used for this purpose.EnsureCommandParameterization
would need to call this method for any constraint in order to obtain the most adequate variant.It could make sense to have the validation order be significant, i.e. have no
Dataset
identified, until adataset=
argument is processed, only only from there on callfor_dataset()
on the subsequent constraints.It may also be necessary to support an alternative name declaration for a "dataset" command, in case one and the same command has two arguments of this type.
For that reason, it may also be beneficial to ignore the name of an argument and go by constraint-type (i.e.
EnsureDataset
).Combined with validation order rules (a class author sets the order of arguments in
_validator_
) it may be sensible to start tailoring constraints when a first dataset-type (not name) argument is found, tailor all constraints from there on, and switch the dataset for tailoring, whenever another dataset-type argument is found.The text was updated successfully, but these errors were encountered: