Skip to content

Commit 7533029

Browse files
committed
Add integration test to verify experiment completion
1 parent de8fbfa commit 7533029

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/litlogger/experiment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ def finalize(self, status: str | None = None, print_summary: bool = True) -> Non
476476
url=self._url,
477477
)
478478

479+
#self._done_event.wait()
480+
479481
def print_url(self) -> None:
480482
"""Print the experiment URL and initialization info with styled output."""
481483
self._printer.experiment_start(

tests/integrations/test_standalone_lifecycle.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from lightning_sdk.lightning_cloud.openapi.models import LitLoggerServiceDeleteMetricsStreamBody
1414
from lightning_sdk.utils.resolve import _get_cloud_url
1515
from litlogger.api.client import LitRestClient
16+
from litlogger.types import PhaseType
1617

1718
# Suppress deprecation warnings from legacy API usage in integration tests
1819
pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning")
@@ -400,3 +401,32 @@ def test_get_or_create_experiment_metrics():
400401
project_id=teamspace_id,
401402
body=LitLoggerServiceDeleteMetricsStreamBody(ids=[original_id, new_experiment.id]),
402403
)
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

Comments
 (0)