From 1affe73ba758b40605f878a3b16c4bd189b6edcc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 14 Jul 2026 19:39:12 +0000 Subject: [PATCH 1/2] test: cover CLI fine-tune model limits Co-authored-by: Blaine Kasten --- tests/cli/test_fine_tuning.py | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/cli/test_fine_tuning.py b/tests/cli/test_fine_tuning.py index ad31400b9..63df89da3 100644 --- a/tests/cli/test_fine_tuning.py +++ b/tests/cli/test_fine_tuning.py @@ -82,13 +82,36 @@ ] } +_MODEL_LIMITS_LORA_MAX_RANK = 64 + _MODEL_LIMITS_BODY = { + "model_name": "meta-llama/Llama-3-8b", + "default_gradient_accumulation_steps": 1, "max_num_epochs": 10, + "max_num_checkpoints": 10, + "max_num_evals": 10, "max_learning_rate": 1, "min_learning_rate": 0, "min_max_seq_length": 1, "max_seq_length_sft": 4096, "max_seq_length_dpo": 4096, + "merge_output_lora": True, + "supports_full_training": True, + "supports_reasoning": False, + "supports_tools": False, + "supports_vision": False, + "lora_training": { + "max_batch_size": 128, + "max_batch_size_dpo": 64, + "max_rank": _MODEL_LIMITS_LORA_MAX_RANK, + "min_batch_size": 8, + "target_modules": ["q", "k", "v", "o", "mlp"], + }, + "full_training": { + "max_batch_size": 96, + "max_batch_size_dpo": 48, + "min_batch_size": 8, + }, } _FT_CREATE_BODY = { @@ -207,6 +230,35 @@ def test_create_early_stopping_sends_params(self, respx_mock: MockRouter, cli_ru assert body["early_stopping_warmup_evals"] == 2 assert body["early_stopping_min_delta"] == 0.01 + @pytest.mark.respx(base_url=base_url, assert_all_called=False) + def test_create_lora_uses_model_limits_defaults(self, respx_mock: MockRouter, cli_runner: CliRunner) -> None: + respx_mock.get("/fine-tunes/models/limits").mock(return_value=httpx.Response(200, json=_MODEL_LIMITS_BODY)) + respx_mock.post("/fine-tunes/estimate-price").mock( + return_value=httpx.Response(200, json={"estimated_total_price": 1.0, "allowed_to_proceed": True}) + ) + create = respx_mock.post("/fine-tunes").mock(return_value=httpx.Response(200, json=_FT_CREATE_BODY)) + + result = cli_runner.invoke( + [ + "fine-tuning", + "create", + "--training-file", + "file-train", + "--model", + "meta-llama/Llama-3-8b", + "--lora", + ], + input="y\n", + ) + + assert result.exit_code == 0 + assert create.calls + body = json.loads(create.calls.last.request.content) + assert body["learning_rate"] == 1e-3 + assert body["training_type"]["type"] == "Lora" + assert body["training_type"]["lora_r"] == _MODEL_LIMITS_LORA_MAX_RANK + assert body["training_type"]["lora_alpha"] == _MODEL_LIMITS_LORA_MAX_RANK * 2 + @pytest.mark.respx(base_url=base_url, assert_all_called=False) def test_create_early_stopping_invalid_fails_before_create( self, respx_mock: MockRouter, cli_runner: CliRunner From bae1cc08a8e0f1e3bdca57b7f798eb16e208c7e1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 12 Aug 2026 16:31:54 +0000 Subject: [PATCH 2/2] test: avoid coupling endpoint alias visibility to help text Co-authored-by: Blaine Kasten --- tests/cli/test_beta_endpoints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cli/test_beta_endpoints.py b/tests/cli/test_beta_endpoints.py index 932b15868..a9795881c 100644 --- a/tests/cli/test_beta_endpoints.py +++ b/tests/cli/test_beta_endpoints.py @@ -240,8 +240,8 @@ def test_list_alias_is_hidden_from_help(self, cli_runner: CliRunner) -> None: output = " ".join(result.output.split()) assert result.exit_code == 0 - assert "ls: List project, organization, or public endpoints" in output - assert "list: List project, organization, or public endpoints" not in output + assert "ls:" in output + assert "list:" not in output @pytest.mark.parametrize("command", ["list", "ls"]) @pytest.mark.respx(base_url=base_url)