Skip to content

Commit 92525d9

Browse files
authored
Merge pull request #436 from ExaWorks/fix_walltime_float_hours
Fix walltime float hours
2 parents 4e86a17 + 9e6abb9 commit 92525d9

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/psij/executors/batch/batch_scheduler_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def _create_script_context(self, job: Job) -> Dict[str, object]:
497497
def _format_duration(self, d: timedelta) -> str:
498498
# the default is hh:mm:ss, with hh not limited to 24; this is the least ambiguous
499499
# choice
500-
return '%s:%s:%s' % (d.total_seconds() // 3600, (d.seconds // 60) % 60, d.seconds % 60)
500+
return '%s:%s:%s' % (int(d.total_seconds()) // 3600, (d.seconds // 60) % 60, d.seconds % 60)
501501

502502
def _run_command(self, cmd: List[str]) -> str:
503503
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

src/psij/executors/batch/lsf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ def get_list_command(self) -> List[str]:
141141
def _format_duration(self, d: timedelta) -> str:
142142
# https://www.ibm.com/docs/en/spectrum-lsf/10.1.0?topic=o-w-1:
143143
# bsub -W [hour:]minute[/host_name | /host_model]
144-
return "%s:%s" % (d.total_seconds() // 3600, (d.seconds // 60) % 60)
144+
return "%s:%s" % (int(d.total_seconds()) // 3600, (d.seconds // 60) % 60)

tests/test_issue_435.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from datetime import timedelta
2+
3+
from _test_tools import _get_executor_instance, _get_timeout, assert_completed
4+
from executor_test_params import ExecutorTestParams
5+
from psij import Job, JobSpec, JobAttributes
6+
7+
8+
def test_issue_435(execparams: ExecutorTestParams) -> None:
9+
job = Job(JobSpec(executable='/bin/date', launcher=execparams.launcher,
10+
attributes=JobAttributes(duration=timedelta(seconds=3700.5))))
11+
ex = _get_executor_instance(execparams, job)
12+
ex.submit(job)
13+
status = job.wait(timeout=_get_timeout(execparams))
14+
assert_completed(job, status)

0 commit comments

Comments
 (0)