Skip to content

Commit 2ff0ec9

Browse files
committed
python: add flux.job.info.strtostate and strtoresult
Problem: flux_job_strtostate(3) and flux_job_strtoresult(3) are not exposed in the Python API. Add strtostate() and strtoresult() to flux.job.info.
1 parent 95386e5 commit 2ff0ec9

File tree

1 file changed

+13
-1
lines changed
  • src/bindings/python/flux/job

1 file changed

+13
-1
lines changed

src/bindings/python/flux/job/info.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from itertools import chain
2020

2121
import flux.constants
22-
from flux.core.inner import raw
22+
from flux.core.inner import ffi, raw
2323
from flux.job.JobID import JobID
2424
from flux.job.stats import JobStats
2525
from flux.memoized_property import memoized_property
@@ -42,6 +42,12 @@ def statetostr(stateid, fmt="L"):
4242
return raw.flux_job_statetostr(stateid, fmt).decode("utf-8")
4343

4444

45+
def strtostate(state):
46+
result = ffi.new("flux_job_state_t [1]")
47+
raw.flux_job_strtostate(state, result)
48+
return int(result[0])
49+
50+
4551
def statetoemoji(stateid):
4652
statestr = raw.flux_job_statetostr(stateid, "S").decode("utf-8")
4753
if statestr == "N":
@@ -81,6 +87,12 @@ def resulttostr(resultid, fmt="L"):
8187
return raw.flux_job_resulttostr(resultid, fmt).decode("utf-8")
8288

8389

90+
def strtoresult(arg):
91+
result = ffi.new("flux_job_result_t [1]")
92+
raw.flux_job_strtoresult(arg, result)
93+
return int(result[0])
94+
95+
8496
def resulttoemoji(resultid):
8597
if resultid != "":
8698
resultstr = raw.flux_job_resulttostr(resultid, "S").decode("utf-8")

0 commit comments

Comments
 (0)