octue / octue-sdk-python

The python SDK for @Octue services and digital twins.
https://octue.com
Other
9 stars 4 forks source link

Add a length assertion on FilterSets #239

Open thclark opened 3 years ago

thclark commented 3 years ago

Feature request

Use Case

I want to be sure that after applying filters, I want to validate that I have a certain number of files.

For example, if I'm expecting a dataset to contain separate files for U, V, W components of a velocity field, I expect to get three files. Maybe I'd do:

filtered = my_dataset.files.filter(name__ends_with=".asc").filter(any_label_contains="component").order_by("tags__component")

But I'll always need to know there'll be three files.

Current state

I'll do:

assert(len(filtered) == 3)

However, I think it'd be neater to have an assertion built in, like:

my_dataset.files.filter(name__ends_with=".asc").filter(any_label_contains="component").order_by("tags__component").assertNumberOfFiles(3)

That way we could ultimately handle the exception and raise it as the same kind of validation error as we get e.g. if the input_values don't validate, so to an external user of the child, validation errors appear unified.

thclark commented 3 years ago

We should probably discuss this as part of a wider subject - unifying validation of file specifications.

cortadocodes commented 2 years ago

Do you still want this @thclark?