|
13 | 13 | from lightning_sdk.lightning_cloud.openapi.models import LitLoggerServiceDeleteMetricsStreamBody |
14 | 14 | from lightning_sdk.utils.resolve import _get_cloud_url |
15 | 15 | from litlogger.api.client import LitRestClient |
| 16 | +from litlogger.types import PhaseType |
16 | 17 |
|
17 | 18 | # Suppress deprecation warnings from legacy API usage in integration tests |
18 | 19 | pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") |
@@ -400,3 +401,32 @@ def test_get_or_create_experiment_metrics(): |
400 | 401 | project_id=teamspace_id, |
401 | 402 | body=LitLoggerServiceDeleteMetricsStreamBody(ids=[original_id, new_experiment.id]), |
402 | 403 | ) |
| 404 | + |
| 405 | + |
| 406 | +@pytest.mark.cloud() |
| 407 | +def test_experiment_completion(): |
| 408 | + """Test that finalize correctly marks the experiment as complete.""" |
| 409 | + exp = litlogger.init( |
| 410 | + name=f"lightning_experiment_completion-{uuid.uuid4().hex}", |
| 411 | + teamspace="oss-litlogger", |
| 412 | + ) |
| 413 | + |
| 414 | + exp.log_metrics({"my_metric": 0}, step=0) |
| 415 | + exp.finalize() |
| 416 | + |
| 417 | + stream_id = exp._metrics_store.id |
| 418 | + |
| 419 | + client = LitRestClient() |
| 420 | + response = client.lit_logger_service_get_metrics_stream( |
| 421 | + project_name=exp._teamspace.name, |
| 422 | + project_owner_name=exp._teamspace.owner.name, |
| 423 | + id=stream_id, |
| 424 | + ) |
| 425 | + |
| 426 | + client.lit_logger_service_delete_metrics_stream( |
| 427 | + project_id=exp._teamspace.id, |
| 428 | + body=LitLoggerServiceDeleteMetricsStreamBody(ids=[stream_id]), |
| 429 | + ) |
| 430 | + |
| 431 | + assert response is not None |
| 432 | + assert response.phase == PhaseType.COMPLETED, f"Expected metrics stream status to be 'COMPLETED', but got {response.metrics_stream.phase}" |
0 commit comments