-
Notifications
You must be signed in to change notification settings - Fork 10
Follow links and resolve #642
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
Follow links and resolve #642
Conversation
ValidationProblem.ExpectedGroup, | ||
None, | ||
) | ||
# collector.collect_and_log( |
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.
remove if not matching?
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.
If we remove, we should log.
I don't have time for a full review, but these are my observations:
gives:
gives correct error:
|
These were coming from the same issue which should be fixed with 1976f30. Namely, the logic for checking linked fields (in the validation against base classes) was ordered incorrectly. Should be fixed now, can you please try again? I also added positive tests for links (both for appdef and base class concepts) in that and the next commit. |
It seems to work now. |
Great that it works. Currently, I have the warning messages disabled, but indeed we remove these keys. This was my question, shall we remove them in the first place? More broadly, do we want to remove fields/groups if they lead to ExpectedGroup/ExpectedField errors (not just from links)? If so, obviously we can enable the messages again. |
Maybe we only remove them if 8000 they lead to write errors because of conflicts in the dict? Or we just raise an error in that case. |
I think it's not possible to predict if we'll get a write error while we are validating. The original error that we got here only became a problem because of the I think for the original error in the writer we can just do
Then we don't even need to raise anymore and we can keep the keys in the template (at least for now, maybe there will be further problems later). |
EDIT: if we don't remove such keys, we get warnings like I think this is more confusing than removing the keys. |
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.
I can't say I understand all the changes to the logic here. So at least some more comments in the code would be good for later code maintenance.
Otherwise, it appears to do the correct thing (acccording to my few tests).
is_mapping = isinstance(resolved_link[key], Mapping) | ||
|
||
if node.type == "group" and not is_mapping: | ||
# Groups must have subelements |
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.
Technically, I think this is not necessary, neither by h5 nor by Nexus, no?
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.
In our case, we don't allow this because we don't have a value to write into the template then. So if we want to ahve groups, we always need to write subkeys.
We could think about allowing to write empty group (by passing an empty dict for example), but currently we don't allow this.
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.
okay, makes sense, was just a thought I had here. Maybe add a comment
ValidationProblem.ExpectedGroup, | ||
None, | ||
) | ||
# collector.collect_and_log( |
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.
If we remove, we should log.
a4779ce
into
599-undescriptive-error-message-cleanup
@rettigl with this PR, we properly follow links as discussed in #638 (comment) and raise an error if the type of the key does not match the type of the linked entity. This works both for concepts from appdefs as well as from base classes (see the two new tests).
I had to make a lot of changes on the way unfortunately, hence this new PR (pointing to my previous one):
is_documented
part for concepts from the base classes.Further improvements:
validate_data_dict
function (so we don't have to pass them to the converter) ->validate_dict_against
just returns a boolean, as before.Questions:
ExpectedGroup/ExpectedField
errors?