What is the best way to get job exit code from Python API? #3407
-
@jameshcorbett is attempting to get the exact exit code of a The only way that I'm aware of is to grab the job's eventlog and extract the Is there a better way to do it? If not, maybe we should add a function/method for that to the python bindings. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Strange, I could have sworn the exitcode was tracked by job-info and thus available via a |
Beta Was this translation helpful? Give feedback.
-
In case it is helpful for now, here's the code to get the status from the eventlog: import os
import sys
import flux
from flux import job
jobid = job.JobID(sys.argv[1])
status = job.event_wait(flux.Flux(), jobid, "finish").context["status"]
print(os.WEXITSTATUS(status))
|
Beta Was this translation helpful? Give feedback.
-
Thanks @SteVwonder for opening this for me and @grondo for providing a workaround. Right now all my Python code uses the wait-any functionality, so it doesn't look like I can leverage the |
Beta Was this translation helpful? Give feedback.
-
This has been partially resolved by #3408. However you will still have to fetch extra information when You can fetch a JobInfo object for a failed job via something like the following: job = JobList(h, ids=[jobid]).jobs[0] #3408 introduced a new property |
Beta Was this translation helpful? Give feedback.
-
I think this can be marked as answered. In addition to the
|
Beta Was this translation helpful? Give feedback.
I think this can be marked as answered. In addition to the
event_wait
andJobList
interfaces @grondo mentioned above, there are two new interfaces:returncode
property mentioned above.flux.job.FluxExecutor()
which returns futures that represent the return code of the job.