File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,6 +217,11 @@ def _start(
217217 # to avoid confusion.
218218 if exp_obj and exp_obj .status != Status .COMPLETED :
219219 self ._id = exp_obj .uuid
220+ # reset to running status.
221+ self ._runtime ._metadb .update_experiment (
222+ experiment_id = self ._id ,
223+ status = Status .RUNNING ,
224+ )
220225 elif exp_obj and exp_obj .status == Status .COMPLETED :
221226 raise RuntimeError (
222227 f"Experiment with name '{ name } ' already exists and is completed. \
Original file line number Diff line number Diff line change @@ -178,6 +178,16 @@ async def test_experiment_with_done_with_cancel():
178178
179179 assert global_runtime ().metadb .get_run (run_id = run_id ).status == Status .CANCELLED
180180
181+ async with CraftExperiment .start (name = "first-experiment" ) as exp :
182+ run = exp .run (lambda : asyncio .sleep (2 ))
183+ exp_obj = global_runtime ().metadb .get_experiment (experiment_id = exp .id )
184+ # will be reset to running
185+ assert exp_obj .status == Status .RUNNING
186+
187+ # finally should be completed after context exit
188+ exp_obj = global_runtime ().metadb .get_experiment (experiment_id = exp .id )
189+ assert exp_obj .status == Status .COMPLETED
190+
181191
182192@pytest .mark .asyncio
183193async def test_experiment_with_wait ():
You can’t perform that action at this time.
0 commit comments