Skip to content

Commit

Permalink
Merge pull request #6430 from grondo/issue#6426
Browse files Browse the repository at this point in the history
indicate held jobs in the` INFO` column of `flux jobs` output
  • Loading branch information
mergify[bot] authored Nov 13, 2024
2 parents 6689625 + c61dfca commit 83d7b57
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
12 changes: 7 additions & 5 deletions doc/man1/flux-jobs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,13 @@ the state of the job or other context:

**contextual_info**
Returns selected information based on the job's current state. If the
job is in PRIORITY state, then the string ``priority-wait`` is returned,
if the job is in DEPEND state, then a list of outstanding dependencies
is returned, if the job is in SCHED state then an estimated time the
job will run is returned (if the scheduler supports it). Otherwise,
the assigned nodelist is returned (if resources were assigned).
job is in PRIORITY state, then the string ``priority-wait`` is returned.
If the job is in DEPEND state, then a list of outstanding dependencies
is returned. If the job is in SCHED state and its priority is currently
0, then one of ``held`` or ``priority-hold`` will be printed depending
on if urgency is also 0, otherwise an estimated time the job will run is
returned (if supported by the scheduler). In other states, the assigned
nodelist is returned (if resources were assigned).

**contextual_info**
Returns the job runtime for jobs in RUN state or later, otherwise the
Expand Down
18 changes: 16 additions & 2 deletions src/bindings/python/flux/job/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ def contextual_info(self):
Generate contextual nodelist/reason information based on job state:
PRIORITY: returns "priority-wait"
DEPEND: returns depends:dependencies list
SCHED: returns eta:sched.t_estimate if available
SCHED: returns eta:sched.t_estimate if available, "held" if
urgency=0, or "priority-hold" if urgency>0 and priority=0.
RUN+: returns assigned nodelist
"""
# Required for pylint, o/w it thinks state is a callable:
Expand All @@ -521,6 +522,12 @@ def contextual_info(self):
eta = flux.util.fsd(eta)
return f"eta:{eta}"
except TypeError:
# No eta available. Print "held" if job is held, or
# priority-hold if priority == 0, otherwise nothing.
if self.urgency == 0:
return "held"
elif self.priority == 0:
return "priority-hold"
return ""
else:
return self.nodelist
Expand Down Expand Up @@ -687,7 +694,14 @@ def job_fields_to_attrs(fields):
"t_remaining": ("expiration", "state", "result"),
"annotations": ("annotations",),
"dependencies": ("dependencies",),
"contextual_info": ("state", "dependencies", "annotations", "nodelist"),
"contextual_info": (
"state",
"dependencies",
"annotations",
"nodelist",
"priority",
"urgency",
),
"contextual_time": ("state", "t_run", "t_cleanup", "duration"),
"inactive_reason": (
"state",
Expand Down
15 changes: 14 additions & 1 deletion t/t2800-jobs-cmd.t
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test_expect_success 'submit jobs for job list testing' '
#
# Submit a set of jobs with non-default urgencies
#
for u in 31 25 20 15 10 5; do
for u in 31 25 20 15 10 5 0; do
flux job submit --urgency=$u sleeplong.json >> sched.ids
done &&
listjobs > active.ids &&
Expand Down Expand Up @@ -552,6 +552,7 @@ test_expect_success 'flux-jobs --format={urgency},{priority} works' '
echo 15,15 >> urgency_priority.exp &&
echo 10,10 >> urgency_priority.exp &&
echo 5,5 >> urgency_priority.exp &&
echo 0,0 >> urgency_priority.exp &&
for i in `seq 1 $(job_list_state_count run)`; do
echo "16,16" >> urgency_priority.exp
done &&
Expand All @@ -561,6 +562,18 @@ test_expect_success 'flux-jobs --format={urgency},{priority} works' '
test_cmp urgency_priority.out urgency_priority.exp
'

test_expect_success 'flux-jobs --format={contextual_info} shows held job' '
flux jobs -no {urgency}:{contextual_info} | grep 0:held
'

# There is no simple way to create a job with urgency > 0 and priority == 0,
# so test priority-hold using --from-stdin:
test_expect_success 'flux-jobs {contextual_info} shows priority-hold job' '
echo "{\"id\":195823665152,\"state\":8,\"priority\":0,\"urgency\":16}" \
| flux jobs --from-stdin -no {priority}:{contextual_info} \
| grep 0:priority-hold
'

test_expect_success 'flux-jobs --format={state},{state_single} works' '
flux jobs --filter=pending -c1 -no "{state},{state_single}" > stateP.out &&
test "$(cat stateP.out)" = "SCHED,S" &&
Expand Down

0 comments on commit 83d7b57

Please sign in to comment.