@@ -254,6 +254,48 @@ def test_resume_experiment():
254254 )
255255
256256
257+ @pytest .mark .cloud ()
258+ def test_resume_old_experiment ():
259+ """Resume an experiment that has many newer experiments in the same teamspace."""
260+ from litlogger .api .metrics_api import MetricsApi
261+
262+ target_name = f"standalone_resume_old-{ uuid .uuid4 ().hex } "
263+ filler_prefix = f"standalone_resume_old_filler-{ uuid .uuid4 ().hex } "
264+
265+ exp1 = litlogger .init (name = target_name , teamspace = "oss-litlogger" )
266+ litlogger .log_metrics ({"loss" : 0.5 }, step = 0 )
267+ litlogger .finalize ()
268+
269+ project_id = exp1 ._teamspace .id
270+ target_stream_id = exp1 ._metrics_store .id
271+
272+ api = MetricsApi ()
273+ client = LitRestClient ()
274+
275+ filler_ids : list [str ] = []
276+ try :
277+ for i in range (51 ):
278+ stream = api .create_experiment_metrics (
279+ teamspace_id = project_id ,
280+ name = f"{ filler_prefix } -{ i } " ,
281+ )
282+ filler_ids .append (stream .id )
283+ sleep (1 ) # avoid rate limiting
284+
285+ exp2 = litlogger .init (name = target_name , teamspace = "oss-litlogger" )
286+ try :
287+ assert (
288+ exp2 ._metrics_store .id == target_stream_id
289+ ), "Expected to resume the original experiment, got a new stream"
290+ finally :
291+ litlogger .finalize ()
292+ finally :
293+ client .lit_logger_service_delete_metrics_stream (
294+ project_id = project_id ,
295+ body = LitLoggerServiceDeleteMetricsStreamBody (ids = [target_stream_id , * filler_ids ]),
296+ )
297+
298+
257299@pytest .mark .cloud ()
258300def test_new_dict_api_resume ():
259301 """Test resuming an experiment with the new dict-like API."""
0 commit comments