-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: add data config checker for property value types #2328
base: develop
Are you sure you want to change the base?
Conversation
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.
Minor remark.
Otherwise it s greatly neat!
if property_types := data_node_config._PROPERTIES_TYPES.get(data_node_config.storage_type): | ||
for prop_key, prop_type in property_types.items(): | ||
prop_value = data_node_config.properties.get(prop_key) if data_node_config.properties else None | ||
if prop_value and not isinstance(prop_value, prop_type): |
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.
prop_type
is the value in the _PROPERTIES_TYPES
dictionary. Today, it must be a Python type.
Can we imagine prop_type
being either a type or a list of types? Then, we should check that the type of prop_value
is among the types in the prop_type
list of types.
Does it make sense, or is it just over-engineering?
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.
isinstance can take a tuple of type as the second parameter. So we only need to define the proprety as a tuple of expected types and it should be good to go. I had to do that for a couple of properties already.
c82433d
to
70c47f1
Compare
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
f"`{prop_key}` of DataNodeConfig `{data_node_config_id}` must be" | ||
f" populated with a serializable Callable function but not a lambda.", | ||
) | ||
def _check_property_types(self, data_node_config_id: str, data_node_config: DataNodeConfig): |
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.
can you help propagate this change on enterprise as well? I'm quite certain it will fail on enterprise :D thanks!
What type of PR is this? (check all applicable)
Description
Related Tickets & Documents
How to reproduce the issue
Please replace this line with instructions on how to reproduce the issue or test the feature.
Other branches or releases that this needs to be backported
Describe which projects this change will impact and that needs to be backported.
Checklist
We encourage you to keep the code coverage percentage at 80% and above.