Skip to content

Commit

Permalink
Merge pull request #8389 from OpenMined/fix-eta-fast-jobs
Browse files Browse the repository at this point in the history
distinguish between s/it and it/s for fast jobs
  • Loading branch information
koenvanderveen authored Jan 11, 2024
2 parents d61ef15 + 7d852b6 commit 5d12c10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions packages/syft/src/syft/service/job/job_stash.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,22 @@ def format_timedelta(local_timedelta):

now = datetime.now()
time_passed = now - datetime.fromisoformat(self.creation_time)

iter_duration_seconds = time_passed.total_seconds() / self.current_iter
iter_duration = timedelta(seconds=iter_duration_seconds)

iter_duration_seconds: float = time_passed.total_seconds() / self.current_iter
iters_remaining = self.n_iters - self.current_iter
# TODO: Adjust by the number of consumers
time_remaining = iters_remaining * iter_duration

# TODO: Adjust by the number of consumers
time_remaining = timedelta(seconds=iters_remaining * iter_duration_seconds)
time_passed_str = format_timedelta(time_passed)
time_remaining_str = format_timedelta(time_remaining)
iter_duration_str = format_timedelta(iter_duration)

return f"[{time_passed_str}<{time_remaining_str}]\n{iter_duration_str}s/it"
if iter_duration_seconds >= 1:
iter_duration: timedelta = timedelta(seconds=iter_duration_seconds)
iter_duration_str = f"{format_timedelta(iter_duration)}s/it"
else:
iters_per_second = round(1 / iter_duration_seconds)
iter_duration_str = f"{iters_per_second}it/s"

return f"[{time_passed_str}<{time_remaining_str}]\n{iter_duration_str}"

@property
def progress(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions packages/syft/tests/syft/service/jobs/job_stash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
(1, None, JobStatus.CREATED, timedelta(hours=2), None),
(5, 10, JobStatus.PROCESSING, timedelta(hours=2), "24:00s/it"),
(200000, 200000, JobStatus.COMPLETED, timedelta(hours=2), "<00:00"),
(156000, 200000, JobStatus.PROCESSING, timedelta(hours=2), "00:00s/it"),
(156000, 200000, JobStatus.PROCESSING, timedelta(hours=2), "22it/s"),
(1, 3, JobStatus.PROCESSING, timedelta(hours=2), "2:00:00s/it"),
(10, 10, JobStatus.PROCESSING, timedelta(minutes=5), "00:30s/it"),
(0, 10, JobStatus.CREATED, timedelta(days=1), None),
(10, 100, JobStatus.PROCESSING, timedelta(seconds=3600), "06:00s/it"),
(100000, 200000, JobStatus.PROCESSING, timedelta(minutes=1), "00:00s/it"),
(100000, 200000, JobStatus.PROCESSING, timedelta(minutes=1), "1667it/s"),
(2, 10, JobStatus.PROCESSING, timedelta(seconds=119.6), "00:59s/it"),
],
)
Expand Down

0 comments on commit 5d12c10

Please sign in to comment.