Skip to content

Commit 4fb4cc1

Browse files
authored
Merge pull request #4324 from chu11/issue4313_job_list_all
job-list: support new "all" attribute to get all job attributes
2 parents 9269a9c + 33f78cb commit 4fb4cc1

File tree

9 files changed

+297
-187
lines changed

9 files changed

+297
-187
lines changed

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

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +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-
]
46-
47-
4820
class JobListRPC(RPC):
4921
def get_jobs(self):
5022
return self.get()["jobs"]
@@ -177,7 +149,7 @@ class JobList:
177149
def __init__(
178150
self,
179151
flux_handle,
180-
attrs=VALID_ATTRS,
152+
attrs=["all"],
181153
filters=[],
182154
ids=[],
183155
user=None,

src/cmd/flux-job.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,14 +1092,6 @@ int cmd_cancelall (optparse_t *p, int argc, char **argv)
10921092
return 0;
10931093
}
10941094

1095-
static const char *list_attrs =
1096-
"[\"userid\",\"urgency\",\"priority\",\"t_submit\",\"state\"," \
1097-
"\"name\",\"ntasks\",\"nnodes\",\"ranks\",\"nodelist\",\"expiration\"," \
1098-
"\"success\",\"exception_occurred\",\"exception_severity\"," \
1099-
"\"exception_type\",\"exception_note\",\"result\",\"waitstatus\"," \
1100-
"\"t_depend\",\"t_run\",\"t_cleanup\"," \
1101-
"\"t_inactive\",\"annotations\",\"dependencies\"]";
1102-
11031095
int cmd_list (optparse_t *p, int argc, char **argv)
11041096
{
11051097
int optindex = optparse_option_index (p);
@@ -1133,7 +1125,7 @@ int cmd_list (optparse_t *p, int argc, char **argv)
11331125
else
11341126
userid = getuid ();
11351127

1136-
if (!(f = flux_job_list (h, max_entries, list_attrs, userid, states)))
1128+
if (!(f = flux_job_list (h, max_entries, "[\"all\"]", userid, states)))
11371129
log_err_exit ("flux_job_list");
11381130
if (flux_rpc_get_unpack (f, "{s:o}", "jobs", &jobs) < 0)
11391131
log_err_exit ("flux_job_list");
@@ -1169,7 +1161,7 @@ int cmd_list_inactive (optparse_t *p, int argc, char **argv)
11691161
if (!(h = flux_open (NULL, 0)))
11701162
log_err_exit ("flux_open");
11711163

1172-
if (!(f = flux_job_list_inactive (h, max_entries, since, list_attrs)))
1164+
if (!(f = flux_job_list_inactive (h, max_entries, since, "[\"all\"]")))
11731165
log_err_exit ("flux_job_list_inactive");
11741166
if (flux_rpc_get_unpack (f, "{s:o}", "jobs", &jobs) < 0)
11751167
log_err_exit ("flux_job_list_inactive");
@@ -1218,7 +1210,7 @@ int cmd_list_ids (optparse_t *p, int argc, char **argv)
12181210
for (i = 0; i < ids_len; i++) {
12191211
flux_jobid_t id = parse_jobid (argv[optindex + i]);
12201212
flux_future_t *f;
1221-
if (!(f = flux_job_list_id (h, id, list_attrs)))
1213+
if (!(f = flux_job_list_id (h, id, "[\"all\"]")))
12221214
log_err_exit ("flux_job_list_id");
12231215
if (flux_future_then (f, -1, list_id_continuation, NULL) < 0)
12241216
log_err_exit ("flux_future_then");

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):

src/modules/job-list/job-list.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
2020
#include "list.h"
2121
#include "idsync.h"
2222

23+
static const char *attrs[] = {
24+
"userid", "urgency", "priority", "t_submit",
25+
"t_depend", "t_run", "t_cleanup", "t_inactive",
26+
"state", "name", "ntasks", "nnodes",
27+
"ranks", "nodelist", "success", "exception_occurred",
28+
"exception_type", "exception_severity",
29+
"exception_note", "result", "expiration",
30+
"annotations", "waitstatus", "dependencies",
31+
NULL
32+
};
33+
34+
const char **job_attrs (void)
35+
{
36+
return attrs;
37+
}
38+
2339
static void stats_cb (flux_t *h, flux_msg_handler_t *mh,
2440
const flux_msg_t *msg, void *arg)
2541
{

src/modules/job-list/job-list.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct list_ctx {
2525
zhashx_t *idsync_waits;
2626
};
2727

28+
const char **job_attrs (void);
29+
2830
#endif /* _FLUX_JOB_LIST_H */
2931

3032
/*

0 commit comments

Comments
 (0)