-
Notifications
You must be signed in to change notification settings - Fork 7
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
Improve error catching and message for add #290
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.
Thanks! I do think the old way had some advantages that we lose in the new implementation. Namely, if PRC / server implements these and there is no more error, the code will immediately work on our side as well. Perhaps the best would be to catch the TypeError, and reraise it with the new text if key/value is None, else reraise the original error.
ibridges/meta.py
Outdated
@@ -203,6 +203,10 @@ def add(self, key: str, value: str, units: Optional[str] = None): | |||
>>> meta.add("Mass", "10", "kg") | |||
|
|||
""" | |||
if key is None or key == "": | |||
raise ValueError("Key cannot be None or empty.") |
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 think technically, key is None
should raise a TypeError and key == ""
should raise a ValueError. Perhaps it makes the most sense to raise a TypeError in this case? We could also split it, but that may be too much for this technical detail.
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.
TO be pragmatic, I will turn them into TypeErrors.
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
I tried to trigger the
|
I'm quite sure I have seen the error at some point. What about other types? Like key/value being an integer? Does the blacklist check error you get when |
When I use a list or a tuple, then I hit the irods exception |
The error from the The user does not really know what went wrong and which part of the metadata item is the culprit. |
I think I got it now right. In the "add" function there is an extra TypeError that catches the failure of the comparison between ley and blacklist. I added again the BadAVU exception and only replaced its message when something is wrong with the key to stay consitstent that in iBridges we call attributes keys. @qubixes Can you please review again. |
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.
Still some questions, but we're almost there!
ibridges/meta.py
Outdated
try: | ||
self._ibridges_meta.add(*new_item_key) |
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 think it should be in the old place. Now, we don't know whether the new one was already added.
ibridges/search.py
Outdated
@@ -139,7 +139,7 @@ def search_data( # pylint: disable=too-many-branches | |||
path = IrodsPath(session, path) | |||
|
|||
if metadata is None: | |||
metadata = [] | |||
metadata = [] # type: ignore |
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.
Which error are we ignoring here? Can't we add an annotation?
ibridges/search.py
Outdated
@@ -178,7 +178,7 @@ def search_data( # pylint: disable=too-many-branches | |||
if path_pattern is not None: | |||
_path_filter(path_pattern, queries) | |||
|
|||
for mf in metadata: | |||
for mf in metadata: # type: ignore |
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.
Same here.
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
Co-authored-by: qubixes <[email protected]>
Improve error message as decsribed in #289