Skip to content

Commit edff7c1

Browse files
committed
python: add optional constraint parameter to JobList
Problem: There is no way to pass extra constraints via the JobList interface. Add an optional constraint parameter to the JobList initializer. This paramter takes a string in constraint query syntax which is parsed by an instance of JobListConstraintParser. The result is then joined with ``and`` to any other constraints before being passed to the job-list module.
1 parent f153cae commit edff7c1

File tree

1 file changed

+9
-0
lines changed
  • src/bindings/python/flux/job

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ class JobList:
220220
:since: Limit jobs to those that have been active since a given timestamp.
221221
:name: Limit jobs to those with a specific name.
222222
:queue: Limit jobs to those submitted to a specific queue.
223+
:constraint: A constraint query string which will be parsed by
224+
JobListConstraintParser to create a job-list constraint object.
225+
(e.g. ``node:foo1 failed``) The result is then joined with other
226+
constraints provided by above parameters via the ``and`` operator.
223227
"""
224228

225229
# pylint: disable=too-many-instance-attributes
@@ -253,6 +257,7 @@ def __init__(
253257
since=0.0,
254258
name=None,
255259
queue=None,
260+
constraint=None,
256261
):
257262
self.handle = flux_handle
258263
self.attrs = list(attrs)
@@ -268,6 +273,9 @@ def __init__(
268273
for x in fname.split(","):
269274
self.add_filter(x)
270275
self.set_user(user)
276+
self.constraint = None
277+
if constraint:
278+
self.constraint = JobListConstraintParser().parse(constraint)
271279

272280
def set_user(self, user):
273281
"""Only return jobs for user (may be a username or userid)"""
@@ -319,6 +327,7 @@ def fetch_jobs(self):
319327
since=self.since,
320328
name=self.name,
321329
queue=self.queue,
330+
constraint=self.constraint,
322331
)
323332

324333
def jobs(self):

0 commit comments

Comments
 (0)