Skip to content

Commit fefb5c0

Browse files
committed
python: add constraint parameter to flux.job.job_list
Problem: There is no way to pass a constraint to flux.job.job_list() Add an optional constraint parameter to job_list() and job_list_inactive()
1 parent 127fa70 commit fefb5c0

File tree

1 file changed

+16
-3
lines changed
  • src/bindings/python/flux/job

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ def job_list(
5555
since=0.0,
5656
name=None,
5757
queue=None,
58+
constraint=None,
5859
):
59-
# N.B. an "and" operation with no values returns everything
60-
constraint = {"and": []}
60+
if constraint is None:
61+
# N.B. an "and" operation with no values returns everything
62+
constraint = {"and": []}
63+
else:
64+
# O/w, a provided constraint will be anded with other parameters below:
65+
constraint = {"and": [constraint]}
66+
6167
if userid != flux.constants.FLUX_USERID_UNKNOWN:
6268
constraint["and"].append({"userid": [userid]})
6369
if name:
@@ -83,7 +89,13 @@ def job_list(
8389

8490

8591
def job_list_inactive(
86-
flux_handle, since=0.0, max_entries=1000, attrs=["all"], name=None, queue=None
92+
flux_handle,
93+
since=0.0,
94+
max_entries=1000,
95+
attrs=["all"],
96+
name=None,
97+
queue=None,
98+
constraint=None,
8799
):
88100
"""Same as ``flux.job.list.job_list``, but lists only inactive jobs."""
89101
return job_list(
@@ -95,6 +107,7 @@ def job_list_inactive(
95107
since=since,
96108
name=name,
97109
queue=queue,
110+
constraint=constraint,
98111
)
99112

100113

0 commit comments

Comments
 (0)