diff --git a/src/psij/executors/batch/batch_scheduler_executor.py b/src/psij/executors/batch/batch_scheduler_executor.py index ebb691d0..0019a5d4 100644 --- a/src/psij/executors/batch/batch_scheduler_executor.py +++ b/src/psij/executors/batch/batch_scheduler_executor.py @@ -497,7 +497,7 @@ def _create_script_context(self, job: Job) -> Dict[str, object]: def _format_duration(self, d: timedelta) -> str: # the default is hh:mm:ss, with hh not limited to 24; this is the least ambiguous # choice - return '%s:%s:%s' % (d.total_seconds() // 3600, (d.seconds // 60) % 60, d.seconds % 60) + return '%s:%s:%s' % (int(d.total_seconds()) // 3600, (d.seconds // 60) % 60, d.seconds % 60) def _run_command(self, cmd: List[str]) -> str: res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) diff --git a/src/psij/executors/batch/lsf.py b/src/psij/executors/batch/lsf.py index f5dac7e3..274f081f 100644 --- a/src/psij/executors/batch/lsf.py +++ b/src/psij/executors/batch/lsf.py @@ -141,4 +141,4 @@ def get_list_command(self) -> List[str]: def _format_duration(self, d: timedelta) -> str: # https://www.ibm.com/docs/en/spectrum-lsf/10.1.0?topic=o-w-1: # bsub -W [hour:]minute[/host_name | /host_model] - return "%s:%s" % (d.total_seconds() // 3600, (d.seconds // 60) % 60) + return "%s:%s" % (int(d.total_seconds()) // 3600, (d.seconds // 60) % 60) diff --git a/tests/test_issue_435.py b/tests/test_issue_435.py new file mode 100644 index 00000000..be145803 --- /dev/null +++ b/tests/test_issue_435.py @@ -0,0 +1,14 @@ +from datetime import timedelta + +from _test_tools import _get_executor_instance, _get_timeout, assert_completed +from executor_test_params import ExecutorTestParams +from psij import Job, JobSpec, JobAttributes + + +def test_issue_435(execparams: ExecutorTestParams) -> None: + job = Job(JobSpec(executable='/bin/date', launcher=execparams.launcher, + attributes=JobAttributes(duration=timedelta(seconds=3700.5)))) + ex = _get_executor_instance(execparams, job) + ex.submit(job) + status = job.wait(timeout=_get_timeout(execparams)) + assert_completed(job, status)