-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: 🩹 update verify_properties_are_well_formed()
based on changes to the Properties
classes
#832
Conversation
We want this function to "focus" on whether the given properties are well-formed. Not whether they are complete; we have the verify_properties_are_complete for that.
…ince we use the compact_dict representation
|
||
errors = [ | ||
error | ||
for error in report.errors | ||
+ [error for task in report.tasks for error in task.errors] | ||
if error.type == error_type | ||
if "required" not in error.message and error.type == error_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.
This workaround, for example, is very non-ideal.
- To filter the required field errors, we have to go into the error message
- We have to filter on error type twice (here and on L28) to ensure we only catch the errors we intend to (either
PackageError
orResourceError)
@@ -24,14 +25,17 @@ def verify_properties_are_well_formed(properties: dict, error_type: str) -> dict | |||
non_empty_properties = { | |||
key: value for key, value in properties.items() if value != "" | |||
} | |||
report = validate(non_empty_properties) | |||
report = validate(non_empty_properties, type=error_type.replace("-error", "")) |
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.
Also not pretty 🥀
] | ||
|
||
if properties == {}: | ||
errors = [Error(note="Empty properties provided")] |
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.
We use Error
as a general error type instead of PackageError
and ResourceError
respectively.
verify_properties_are_well_formed()
based on changes to the Properties
classesverify_properties_are_well_formed()
based on changes to the Properties
classes
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.
Thanks!! Approving but agreeing with all your comments
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.
Yea, agreed. Too bad about frictionless's validate()
😒
933e069
into
fix/avoid-overwriting-non-edited-properties
Description
NB this is a stacked PR merging to #808
This PR changes the behaviour of
verify_properties_are_wellformed()
based on the changes to theProperties
classes in #808This work was done in collaboration with @martonvago 🌷 It's not pretty, but it gets the work done for now.
During this, we talked about #830 and how we think not using
frictionless-py
could simplify the work here as well, since thevalidate()
function keeps surprising us by not working as we expect it to.This PR needs an in-depth review.
Checklist