Skip to content

Commit

Permalink
Merge pull request #436 from ExaWorks/fix_walltime_float_hours
Browse files Browse the repository at this point in the history
Fix walltime float hours
  • Loading branch information
hategan authored Jan 15, 2024
2 parents 4e86a17 + 9e6abb9 commit 92525d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/psij/executors/batch/batch_scheduler_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/psij/executors/batch/lsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 14 additions & 0 deletions tests/test_issue_435.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 92525d9

Please sign in to comment.