Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/together/cli/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions src/together/types/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/test_cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
)

Expand Down Expand Up @@ -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),
)

Expand All @@ -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),
)

Expand Down
Loading