diff --git a/packages/syft/src/syft/service/job/job_stash.py b/packages/syft/src/syft/service/job/job_stash.py index 082aa011f8b..982b9f502ad 100644 --- a/packages/syft/src/syft/service/job/job_stash.py +++ b/packages/syft/src/syft/service/job/job_stash.py @@ -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: diff --git a/packages/syft/tests/syft/service/jobs/job_stash_test.py b/packages/syft/tests/syft/service/jobs/job_stash_test.py index a228bea6f2e..9d3f5a964aa 100644 --- a/packages/syft/tests/syft/service/jobs/job_stash_test.py +++ b/packages/syft/tests/syft/service/jobs/job_stash_test.py @@ -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"), ], )