-
Notifications
You must be signed in to change notification settings - Fork 19
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
Enable debug option for pyschacl validation #281
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #281 +/- ##
==========================================
- Coverage 72.62% 72.40% -0.23%
==========================================
Files 90 90
Lines 5761 5787 +26
==========================================
+ Hits 4184 4190 +6
- Misses 1577 1597 +20
Flags with carried forward coverage won't be shown. Click here to find out more.
|
kgforge/core/archetypes/store.py
Outdated
run( | ||
self._register_one, | ||
None, | ||
data, | ||
required_synchronized=False, | ||
execute_actions=True, | ||
catch_exceptions=catch_exceptions, |
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 would do:
catch_exceptions= not debug
I haven't implemented yet the option to delete distributions and deprecate files when registration fails. I would rather put that in a separate PR. |
messages.append(str(the_details)) | ||
else: | ||
messages.append(str(result)) | ||
return ". ".join(messages) |
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.
Is it an absolute must to join these? Or, better yet, does the result dictionaries have to be converted to str
?
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 is a choice, would you like to have the full schacl error result? Maybe we can give it back when the debug option is true. However, if the intention is to make a nicer Error log, we can add it here, I don't know, what do you think?
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.
No, no. Not the full shacl output, absolutely not. It's just for flexibility of further handling the output.
For example, if the dict you gather above is kept as a dict, it would allow to catch and handle the output on user side like:
try: # this would happen in nexus-forge
reason = "Flux Capacitor is broken"
troubleshooting = {"attention": "Disconnect capacitor drive before opening", "safety": "Shield eyes from light", "actions": "do magic"}
raise ValueError(reason, troubleshooting)
except ValueError as e: # <-- error-handling on user side
print(f"ERROR: {e.args[0]}")
print("\nTroubleshooting Tips:")
for k,v in e.args[1].items():
print(f"\t{k.ljust(10)}: {v}")
OUTPUT:
ERROR: Flux Capacitor is broken
Troubleshooting Tips:
attention : Disconnect capacitor drive before opening
safety : Shield eyes from light
actions : do magic
or we can just leave it as it is:
raise ValueError(reason, troubleshooting)
OUTPUT:
# <traceback>
ValueError: ('Flux Capacitor is broken', {'attention': 'Disconnect capacitor drive before opening', 'safety': 'Shield eyes from light', 'actions': 'do magic'})
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.
On nexus-forge side, you would still able to format the messages any way you want in execution.py
. What do you think?
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.
Ah ok ok, I understand now your point, yes, I like it, I will make some changes, still not decided on if returning the dictionary, but already improved the message.
I was testing the newest changes, and we're discussing about it in NSETM-2067. Instead of opening a new ticket, I'll relay a comment from @jdcourcol, before this is pushed to master:
|
… to provide correct response message.
4aa8b8a
to
b627883
Compare
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 have yet to run things to see what happens
In the effort to solve #280 this option let's us use the
debug
version of the pyschacl validator.