-
Notifications
You must be signed in to change notification settings - Fork 31
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
Detect and display non-zero returncode from scripts #474
Changes from 2 commits
803f18c
bd9f57d
f5384a2
f4c0fcd
1879956
8081fa7
c9a586d
c88fdf7
659d4c5
760da8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3522,6 +3522,13 @@ def update_callback(request, cbString, **kwargs): | |
request.session["callback"][cbString][key] = value | ||
|
||
|
||
# Subclass to handle returncode | ||
class ScriptsCallback(omero.scripts.ProcessCallbackI): | ||
def processFinished(self, returncode, current=None): | ||
super().processFinished(returncode, current) | ||
self.returncode = returncode | ||
|
||
|
||
@login_required() | ||
@render_response() | ||
def activities(request, conn=None, **kwargs): | ||
|
@@ -3797,14 +3804,22 @@ def activities(request, conn=None, **kwargs): | |
error=1, | ||
) | ||
continue | ||
cb = omero.scripts.ProcessCallbackI(conn.c, proc) | ||
cb = ScriptsCallback(conn.c, proc) | ||
# check if we get something back from the handle... | ||
if cb.block(0): # ms. | ||
cb.close() | ||
try: | ||
# we can only retrieve this ONCE - must save results | ||
results = proc.getResults(0, conn.SERVICE_OPTS) | ||
update_callback(request, cbString, status="finished") | ||
kwargs = { | ||
"status": ("finished" if cb.returncode == 0 else "failed"), | ||
"failure": cb.returncode, | ||
} | ||
if cb.returncode != 0: | ||
# This 'error' shows failure icon | ||
kwargs["error"] = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading the code, if return code is non-zero, there are currently three keys which have updated values ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
kwargs["Message"] = "Script failed with Exception" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this not just be Also, I could see adding the return code into the message unobstruvisely, e.g.:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is |
||
update_callback(request, cbString, **kwargs) | ||
new_results.append(cbString) | ||
except Exception: | ||
update_callback( | ||
|
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 initially thought that this key was reflecting the process termination state i.e. the enums defined in https://github.com/ome/omero-py/blob/d5ca72f930d85ee1f147f9f8e3cfd1c95c8089ae/src/omero/callbacks.py#L62-L64 but looking at the code, we seem to have additional state e.g. in-progress, failed etc
Do we have a list of all supported statuses with their meaning?
In that case, I suspect
finished
must be interpreted asfinished with a zero return code
. Note this is a more restrictive interpretation than https://docs.openmicroscopy.org/omero-blitz/5.6.2/slice2html/omero/grid/ProcessCallback.html#processFinished.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.
From testing in omero-figure, that app is using the
"finished"
status to know when the figure export script is done. Without it, the spinner keeps on spinning and the stderr isn't displayed.So, best not to change this if we can help it.