Skip to content

Commit 24d65ac

Browse files
authored
Merge pull request #4565 from grondo/issue#4552
flux-mini: change default unit for --time-limit to minutes
2 parents 4cef4b7 + c0f7c0e commit 24d65ac

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

doc/man1/flux-mini.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,12 @@ Additional job options
150150
The **run**, **submit**, **batch**, and **alloc** commands also take
151151
following additional job parameters:
152152

153-
**-t, --time-limit=FSD**
154-
Set a time limit for the job in Flux standard duration (RFC 23).
155-
FSD is a floating point number with a single character units suffix
156-
("s", "m", "h", or "d"). If unspecified, the job is subject to the
157-
system default time limit.
153+
**-t, --time-limit=MINUTES|FSD**
154+
Set a time limit for the job in either minutes or Flux standard duration
155+
(RFC 23). FSD is a floating point number with a single character units
156+
suffix ("s", "m", "h", or "d"). The default unit for the ``--time-limit``
157+
option is minutes when no units are otherwise specified. If the time
158+
limit is unspecified, the job is subject to the system default time limit.
158159

159160
STANDARD I/O
160161
============

src/cmd/flux-mini.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,9 @@ def create_parser(exclude_io=False):
461461
"-t",
462462
"--time-limit",
463463
type=str,
464-
metavar="FSD",
465-
help="Time limit in Flux standard duration, e.g. 2d, 1.5h",
464+
metavar="MIN|FSD",
465+
help="Time limit in minutes when no units provided, otherwise "
466+
+ "in Flux standard duration, e.g. 30s, 2d, 1.5h",
466467
)
467468
parser.add_argument(
468469
"--urgency",
@@ -614,6 +615,13 @@ def jobspec_create(self, args):
614615
list_split(args.requires),
615616
)
616617
if args.time_limit is not None:
618+
# With no units, time_limit is in minutes, but jobspec.duration
619+
# takes seconds or FSD by default, so convert here if necessary.
620+
try:
621+
limit = float(args.time_limit)
622+
args.time_limit = limit * 60
623+
except ValueError:
624+
pass
617625
jobspec.duration = args.time_limit
618626

619627
if args.job_name is not None:

t/t2212-job-manager-plugins.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ test_expect_success 'job-manager: load jobtap_api test plugin' '
223223
/bin/false) &&
224224
test_expect_code 1 flux job attach -vEX $id &&
225225
test_must_fail flux job wait-event $id exception &&
226-
id=$(flux mini submit -t 0.1 \
226+
id=$(flux mini submit -t 0.1s \
227227
--setattr=system.expected-result=timeout \
228228
sleep 10) &&
229229
test_must_fail flux job wait-event -vm type=test $id exception &&

t/t2220-job-manager-jobspec-default.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ test_expect_success HAVE_JQ 'the redacted jobspec contains default duration' '
7474
jq -e ".jobspec.attributes.system.duration == 3600" <getattr4.json
7575
'
7676
test_expect_success 'submit a job that overrides the default duration' '
77-
flux mini submit -t5 /bin/true >id5
77+
flux mini submit -t5s /bin/true >id5
7878
'
7979
test_expect_success HAVE_JQ 'the redacted jobspec contains the override' '
8080
jm_getattr $(cat id5) jobspec >getattr5.json &&
@@ -158,7 +158,7 @@ test_expect_success HAVE_JQ 'the redacted jobspec contains queue duration' '
158158
jq -e ".jobspec.attributes.system.duration == 99" <getattr8.json
159159
'
160160
test_expect_success 'submit a job with with queue and duration' '
161-
flux mini submit --setattr=system.queue=pdebug -t 111 /bin/true >id9
161+
flux mini submit --setattr=system.queue=pdebug -t 111s /bin/true >id9
162162
'
163163
test_expect_success HAVE_JQ 'the redacted jobspec contains user duration' '
164164
jm_getattr $(cat id9) jobspec >getattr9.json &&

t/t2260-job-list.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ test_expect_success HAVE_JQ 'flux job list outputs exceptions correctly (excepti
778778
# expiration time
779779

780780
test_expect_success HAVE_JQ 'flux job list outputs expiration time when set' '
781-
jobid=$(flux mini submit -t 30 sleep 1000 | flux job id) &&
781+
jobid=$(flux mini submit -t 30s sleep 1000 | flux job id) &&
782782
fj_wait_event $jobid start &&
783783
flux job list | grep $jobid > expiration.json &&
784784
test_debug "cat expiration.json" &&

t/t2607-job-shell-input.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test_expect_success NO_CHAIN_LINT 'flux-shell: attach twice, one with data' '
7373
'
7474

7575
test_expect_success 'flux-shell: multiple jobs, each want stdin' '
76-
flux mini submit --cc=1-4 -n1 -t 30 \
76+
flux mini submit --cc=1-4 -n1 -t 30s \
7777
${TEST_SUBPROCESS_DIR}/test_echo -O -n >pipe5.jobids &&
7878
test_debug "cat pipe5.jobids" &&
7979
i=1 &&
@@ -151,7 +151,7 @@ test_expect_success 'flux-shell: run 2-task input file as stdin job' '
151151
'
152152

153153
test_expect_success 'flux-shell: multiple jobs, each want stdin via file' '
154-
flux mini submit --cc=1-4 -n1 -t 30 --input=input_stdin_file \
154+
flux mini submit --cc=1-4 -n1 -t 30s --input=input_stdin_file \
155155
${TEST_SUBPROCESS_DIR}/test_echo -O -n >file2.jobids &&
156156
test_debug "cat file2.jobids" &&
157157
i=1 &&

t/t2700-mini-cmd.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,23 @@ test_expect_success 'flux mini run -vvv produces exec events on stderr' '
9898
'
9999
test_expect_success HAVE_JQ 'flux mini submit --time-limit=5d works' '
100100
flux mini submit --dry-run --time-limit=5d hostname >t5d.out &&
101-
jq -r ".attributes.system.duration == 432000"
101+
jq -e ".attributes.system.duration == 432000" < t5d.out
102102
'
103103
test_expect_success HAVE_JQ 'flux mini submit --time-limit=4h works' '
104104
flux mini submit --dry-run --time-limit=4h hostname >t4h.out &&
105-
jq -r ".attributes.system.duration == 14400"
105+
jq -e ".attributes.system.duration == 14400" < t4h.out
106106
'
107107
test_expect_success HAVE_JQ 'flux mini submit --time-limit=1m works' '
108108
flux mini submit --dry-run --time-limit=5m hostname >t5m.out &&
109-
jq -r ".attributes.system.duration == 300"
109+
jq -e ".attributes.system.duration == 300" < t5m.out
110110
'
111111
test_expect_success HAVE_JQ 'flux mini submit -t5s works' '
112112
flux mini submit --dry-run -t5s hostname >t5s.out &&
113-
jq -r ".attributes.system.duration == 300"
113+
jq -e ".attributes.system.duration == 5" < t5s.out
114114
'
115-
test_expect_success HAVE_JQ 'flux mini submit -t5 works' '
115+
test_expect_success HAVE_JQ 'flux mini submit -t5 sets 5m duration' '
116116
flux mini submit --dry-run -t5 hostname >t5.out &&
117-
jq -r ".attributes.system.duration == 300"
117+
jq -e ".attributes.system.duration == 300" < t5.out
118118
'
119119
test_expect_success 'flux mini submit --time-limit=00:30 fails' '
120120
test_must_fail flux mini submit --time-limit=00:30 hostname 2>st.err &&

t/t2900-job-timelimits.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test_have_prereq ASAN && TIMEOUT=3
1616

1717
test_expect_success 'job time limits are enforced' '
1818
test_expect_code 142 \
19-
flux mini run --time-limit=${TIMEOUT} sleep 30 2>limit1.err &&
19+
flux mini run --time-limit=${TIMEOUT}s sleep 30 2>limit1.err &&
2020
grep "resource allocation expired" limit1.err
2121
'
2222
test_expect_success HAVE_JQ 'job timelimits are propagated' '
@@ -57,7 +57,7 @@ sigalrm_sigkill_test() {
5757
flux module reload job-exec kill-timeout=$kill_timeout &&
5858
ofile=trap.$scale.out &&
5959
test_must_fail_or_be_terminated \
60-
flux mini run -vvv --time-limit=${timeout} bash -xc \
60+
flux mini run -vvv --time-limit=${timeout}s bash -xc \
6161
"trap \"echo got SIGALRM>>$ofile\" SIGALRM;sleep 10;sleep 15" \
6262
> $ofile 2> trap.$scale.err &&
6363
test_debug "grep . trap.*" &&
@@ -74,7 +74,7 @@ test_expect_success 'expired jobs are sent SIGALRM, then SIGKILL' '
7474
done
7575
'
7676
expired_cancel_test() {
77-
id=$(flux mini submit --time-limit=$1 bash -c \
77+
id=$(flux mini submit --time-limit=${1}s bash -c \
7878
"trap \"echo got SIGALRM>>trap2.out\" SIGALRM;sleep 60;sleep 60" ) &&
7979
flux job wait-event --timeout=30 $id exception &&
8080
flux job cancel $id &&

0 commit comments

Comments
 (0)