-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Allow typed simple filters #5760
Conversation
cvat/apps/engine/filters.py
Outdated
queryset = None | ||
warnings.warn( | ||
"{} is not compatible with schema generation".format(view.__class__) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any views left that are incompatible with schema generation? Why couldn't they be adapted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, there are no such views and we can tighten this requirement.
cvat/apps/engine/filters.py
Outdated
else: | ||
parameter_schema = { 'type': 'string' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should check that the field is actually a string here? If we're doing typing, it would be useful to check that the type we're applying is appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, these types are everything we need to support in simple filters. Basically, all fields must be serialized into strings, but we do an exception for numbers. Which other types would you like to support? To my knowledge, there are only dates that could be supported, but there are no such filters now. What is possible is that the model choice is not an integer, this is a good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is not that we should support other types, but that when we declare a parameter to be a string, we should check that it actually is a string. If you add an assert for that, then in the future, when someone adds a filter of a type that hasn't been used before, they will be notified that they need to update the schema generation too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Motivation and context
This PR implements typed query params for simple filters, making SDK interface clearer.
How has this been tested?
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.