Closed will-moore closed 11 months ago
This pull request has been mentioned on Image.sc Forum. There might be relevant details there:
Interesting thread which incidentally raises the question: what the recommendation should be for handling and communicating failures in OMERO.scripts?
At the moment, the primary relevant place I found in the reference documentation suggests failures may be handled via client output message - see https://omero.readthedocs.io/en/stable/developers/scripts/style-guide.html#script-outputs
Using the official Populate_Metadata.py
OMERO script as an exmple, there is already a mixture of behaviours:
sys.stderr
and raisesys.exit(1)
- e.g. https://github.com/ome/omero-scripts/blob/88219a3323685a575f92e689222b91b4e590da3c/omero/import_scripts/Populate_Metadata.py#L65-L68. These would be displayed with an error icon as per the current state of this PR@sbesson Thanks for the review. I guess we can't currently have the script raise an Exception (to get the failed
icon) and also return a useful Error message. But the Exception will be captured in stdout - do we need to make it more obvious that the user should look there?
I would prefer not to add another convention (on top of the "Message" convention) for errors, so I think that raising an Exception should be the best way to indicate "Failure".
That last commit fixed the display of Error reporting in Figure:
@will-moore following up on the questions from https://github.com/ome/omero-web/pull/474#discussion_r1219073402, would it be possible to either update the description of this PR or add a comment with the different types of scenarios that should be tested and the expected outcome of the callback
dictionary ?
@sbesson I've updated the PR description. Hope that contains everything you need?
Thanks @will-moore for adjusting the description. As per the previous discussion, I am still questioning the added value of the new failure
key as its value seems to be completely redundant with the presence/value of error
. I thought the plan was to remove it as per https://github.com/ome/omero-web/pull/474#discussion_r1321661476 ?
Also re https://github.com/ome/omero-web/pull/474#discussion_r1203972716, has the proposal of storing the value of the return code in error
and adjust the HTML template to handle the non-zero scenario been discussed further?
OK - yes, apologies. I'll do that...
@sbesson Use key returncode
now for the returncode! Updated the JSON in the description accordingly.
This uses the
returncode
returned from running scripts to show the Error icon in Activities dialog:Feature requested at https://forum.image.sc/t/omero-scripts-fail-icon/81495
To test:
client.setOutput("Message", rstring("OK so far..."))
returncode
from the failure.The
context
used to render the html page in the example above looks like this: