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/lib/cli/api/fine_tuning/list_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ async def list_metrics(
"Fetching metrics...",
config.client.fine_tuning.list_metrics(
fine_tune_id,
global_step_from=global_step_from or omit,
global_step_to=global_step_to or omit,
logged_at_from=logged_at_from or omit,
logged_at_to=logged_at_to or omit,
resolution=resolution or omit,
global_step_from=global_step_from if global_step_from is not None else omit,
global_step_to=global_step_to if global_step_to is not None else omit,
logged_at_from=logged_at_from if logged_at_from is not None else omit,
logged_at_to=logged_at_to if logged_at_to is not None else omit,
resolution=resolution if resolution is not None else omit,
),
)

Expand Down
46 changes: 46 additions & 0 deletions tests/cli/test_fine_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import os
import json
import importlib
from typing import cast
from pathlib import Path
from unittest.mock import patch

import httpx
import pytest
from respx import MockRouter
from respx.models import Call

from tests.cli.utils import CliRunner

Expand Down Expand Up @@ -70,6 +72,16 @@
"step": 5,
}

_FT_METRICS_BODY = {
"metrics": [
{
"global_step": 0,
"train_loss": 1.25,
"logged_at": "2024-01-01T00:00:00Z",
}
]
}


class TestFineTuningList:
@pytest.mark.respx(base_url=base_url)
Expand Down Expand Up @@ -197,6 +209,40 @@ def test_list_checkpoints_empty_message(self, respx_mock: MockRouter, cli_runner
assert "No checkpoints found" in result.output


class TestFineTuningListMetrics:
@pytest.mark.respx(base_url=base_url)
def test_list_metrics_json_includes_zero_step_filters(self, respx_mock: MockRouter, cli_runner: CliRunner) -> None:
route = respx_mock.get("/fine-tunes/ft-1/metrics").mock(return_value=httpx.Response(200, json=_FT_METRICS_BODY))

result = cli_runner.invoke(
[
"fine-tuning",
"list-metrics",
"ft-1",
"--global-step-from",
"0",
"--global-step-to",
"0",
"--logged-at-from",
"2024-01-01T00:00:00+00:00",
"--logged-at-to",
"2024-01-02T00:00:00+00:00",
"--resolution",
"50",
"--json",
]
)

assert result.exit_code == 0
params = cast(Call, route.calls[0]).request.url.params
assert params["global_step_from"] == "0"
assert params["global_step_to"] == "0"
assert params["logged_at_from"] == "2024-01-01T00:00:00+00:00"
assert params["logged_at_to"] == "2024-01-02T00:00:00+00:00"
assert params["resolution"] == "50"
assert json.loads(result.output) == _FT_METRICS_BODY["metrics"]


class TestFineTuningDownload:
@pytest.mark.respx(base_url=base_url)
def test_download_invokes_download_manager(
Expand Down
Loading