diff --git a/src/together/cli/api/utils.py b/src/together/cli/api/utils.py index 3bd2844..6b58994 100644 --- a/src/together/cli/api/utils.py +++ b/src/together/cli/api/utils.py @@ -103,13 +103,13 @@ def generate_progress_bar( progress = "Progress: [bold red]unavailable[/bold red]" if finetune_job.status in COMPLETED_STATUSES: progress = "Progress: [bold green]completed[/bold green]" - elif finetune_job.updated_at is not None: + elif finetune_job.started_at is not None: # Replace 'Z' with '+00:00' for Python 3.10 compatibility - updated_at_str = finetune_job.updated_at.replace("Z", "+00:00") - update_at = datetime.fromisoformat(updated_at_str).astimezone() + started_at_str = finetune_job.started_at.replace("Z", "+00:00") + started_at = datetime.fromisoformat(started_at_str).astimezone() if finetune_job.progress is not None: - if current_time < update_at: + if current_time < started_at: return progress if not finetune_job.progress.estimate_available: @@ -118,7 +118,7 @@ def generate_progress_bar( if finetune_job.progress.seconds_remaining <= 0: return progress - elapsed_time = (current_time - update_at).total_seconds() + elapsed_time = (current_time - started_at).total_seconds() ratio_filled = min( elapsed_time / finetune_job.progress.seconds_remaining, 1.0 ) diff --git a/src/together/types/finetune.py b/src/together/types/finetune.py index 95d48e5..faaaac0 100644 --- a/src/together/types/finetune.py +++ b/src/together/types/finetune.py @@ -286,6 +286,7 @@ class FinetuneResponse(BaseModel): # created/updated datetime stamps created_at: str | None = None updated_at: str | None = None + started_at: str | None = None # job status status: FinetuneJobStatus | None = None # job id diff --git a/tests/unit/test_cli_utils.py b/tests/unit/test_cli_utils.py index 02e6182..b5cef3c 100644 --- a/tests/unit/test_cli_utils.py +++ b/tests/unit/test_cli_utils.py @@ -12,7 +12,7 @@ def create_finetune_response( status: FinetuneJobStatus = FinetuneJobStatus.STATUS_RUNNING, - updated_at: str = "2024-01-01T12:00:00Z", + started_at: str = "2024-01-01T12:00:00Z", progress: FinetuneProgress | None = None, job_id: str = "ft-test-123", ) -> FinetuneResponse: @@ -30,7 +30,8 @@ def create_finetune_response( return FinetuneResponse( id=job_id, progress=progress, - updated_at=updated_at, + updated_at=started_at, + started_at=started_at, status=status, ) @@ -359,7 +360,7 @@ def test_timezone_aware_datetime(self): """Test with different timezone for updated_at.""" current_time = datetime(2024, 1, 1, 12, 0, 30, tzinfo=timezone.utc) finetune_job = create_finetune_response( - updated_at="2024-01-01T07:00:00-05:00", # Same as 12:00:00 UTC (EST = UTC-5) + started_at="2024-01-01T07:00:00-05:00", # Same as 12:00:00 UTC (EST = UTC-5) progress=FinetuneProgress(estimate_available=True, seconds_remaining=60.0), ) @@ -385,7 +386,7 @@ def test_negative_elapsed_time_scenario(self): """Test unusual case where current time appears before updated_at.""" current_time = datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc) finetune_job = create_finetune_response( - updated_at="2024-01-01T12:00:30Z", # In the "future" + started_at="2024-01-01T12:00:30Z", # In the "future" progress=FinetuneProgress(estimate_available=True, seconds_remaining=100.0), )