AllenNeuralDynamics / aind-slims-api

AIND-specific access to data stored in SLIMS
MIT License
0 stars 1 forks source link

Add support for filtering api responses #26

Open mochic opened 1 month ago

mochic commented 1 month ago

We currently use slims-python-api under the hood. We want to be able to add api filters beyond just equality. In my mind, we could overload a custom object or use helper functions like here: https://github.com/genohm/slims-python-api/blob/master/src/slims/criteria.py

I personally prefer the helper function approach. I think that the custom object might be a little hard to test but if that's what end users desire then I can implement the magic overloaded object ontop of the helper functions. It would allow us to do:

client.fetch_models(model_class, model_class.prop > some_value)

versus

client.fetch_models(model_class, criterion_helpers.greater_than(prop_name, some_value))

Looking to potential end users for feedback.

bruno-f-cruz commented 1 month ago

+1 for helpers. It worries that some of their calls do not immediately translate into python operators and we would need to try to find cludges for them.

My only suggestion would be to validate prop_name (and maybe some_value (?)) against model_class (i.e. does the attribute exists, and is its type compatible) before making the request. Probably at the level of the "fetch_models" method.