Skip to content

Commit 33f78cb

Browse files
chu11mergify[bot]
authored andcommitted
python: use job-list "all" attr
Problem: The python bindings have a VALID_ATTRS list that is maintained to grab all attrs from a job. This is no longer necessary with the job-list "all" attr. Solution: Use the "all" attr and remove VALID_ATTRS. As a side effect, a copy of valid attrs must be added to tests when checking for the list of legal attrs returned from job-list.list-attrs.
1 parent d3ff8a0 commit 33f78cb

File tree

3 files changed

+30
-34
lines changed

3 files changed

+30
-34
lines changed

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

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,6 @@
1717
from flux.rpc import RPC
1818

1919

20-
VALID_ATTRS = [
21-
"userid",
22-
"urgency",
23-
"priority",
24-
"t_submit",
25-
"t_depend",
26-
"t_run",
27-
"t_cleanup",
28-
"t_inactive",
29-
"state",
30-
"name",
31-
"ntasks",
32-
"nnodes",
33-
"ranks",
34-
"nodelist",
35-
"waitstatus",
36-
"success",
37-
"exception_occurred",
38-
"exception_type",
39-
"exception_severity",
40-
"exception_note",
41-
"result",
42-
"expiration",
43-
"annotations",
44-
"dependencies",
45-
"all",
46-
]
47-
48-
4920
class JobListRPC(RPC):
5021
def get_jobs(self):
5122
return self.get()["jobs"]
@@ -178,7 +149,7 @@ class JobList:
178149
def __init__(
179150
self,
180151
flux_handle,
181-
attrs=VALID_ATTRS,
152+
attrs=["all"],
182153
filters=[],
183154
ids=[],
184155
user=None,

src/cmd/flux-pstree.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,9 @@ def load_tree(
162162
# This may fail if the instance hasn't loaded the job-list module
163163
# or if the current user is not owner
164164
#
165-
attrs = flux.job.list.VALID_ATTRS
166165
try:
167166
jobs_rpc = JobList(
168-
flux.Flux(uri), ids=jobids, filters=filters, attrs=attrs
167+
flux.Flux(uri), ids=jobids, filters=filters, attrs=["all"]
169168
).fetch_jobs()
170169
jobs = jobs_rpc.get_jobs()
171170
except (OSError, FileNotFoundError):

t/python/t0010-job.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import flux.constants
2929
from flux import job
3030
from flux.job import Jobspec, JobspecV1, ffi, JobID, JobInfo
31-
from flux.job.list import VALID_ATTRS
3231
from flux.job.stats import JobStats
3332
from flux.future import Future
3433

@@ -453,8 +452,35 @@ def test_24_jobid(self):
453452
self.assertEqual(getattr(jobid, key), test[key])
454453

455454
def test_25_job_list_attrs(self):
455+
expected_attrs = [
456+
"userid",
457+
"urgency",
458+
"priority",
459+
"t_submit",
460+
"t_depend",
461+
"t_run",
462+
"t_cleanup",
463+
"t_inactive",
464+
"state",
465+
"name",
466+
"ntasks",
467+
"nnodes",
468+
"ranks",
469+
"nodelist",
470+
"waitstatus",
471+
"success",
472+
"exception_occurred",
473+
"exception_type",
474+
"exception_severity",
475+
"exception_note",
476+
"result",
477+
"expiration",
478+
"annotations",
479+
"dependencies",
480+
"all",
481+
]
456482
valid_attrs = self.fh.rpc("job-list.list-attrs", "{}").get()["attrs"]
457-
self.assertEqual(set(valid_attrs), set(VALID_ATTRS))
483+
self.assertEqual(set(valid_attrs), set(expected_attrs))
458484

459485
def test_30_job_stats_sync(self):
460486
stats = JobStats(self.fh)

0 commit comments

Comments
 (0)