Skip to content

Commit 717731c

Browse files
authored
Run id file should be written prior to execution when resuming (#1051)
* Run id file should be written prior to execution when resuming * separate run id test so we can exclude from batch
1 parent 27cce78 commit 717731c

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

metaflow/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,11 +729,10 @@ def resume(
729729
max_num_splits=max_num_splits,
730730
max_log_size=max_log_size * 1024 * 1024,
731731
)
732+
write_run_id(run_id_file, runtime.run_id)
732733
runtime.persist_constants()
733734
runtime.execute()
734735

735-
write_run_id(run_id_file, runtime.run_id)
736-
737736

738737
@parameters.add_custom_parameters(deploy_mode=True)
739738
@cli.command(help="Run the workflow locally.")

test/core/contexts.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
"NestedUnboundedForeachTest",
9393
"DetectSegFaultTest",
9494
"TimeoutDecoratorTest",
95-
"CardExtensionsImportTest"
95+
"CardExtensionsImportTest",
96+
"RunIdFileTest"
9697
]
9798
},
9899
{
@@ -128,7 +129,8 @@
128129
"NestedUnboundedForeachTest",
129130
"DetectSegFaultTest",
130131
"TimeoutDecoratorTest",
131-
"CardExtensionsImportTest"
132+
"CardExtensionsImportTest",
133+
"RunIdFileTest"
132134
]
133135
}
134136
],

test/core/tests/run_id_file.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from metaflow_test import MetaflowTest, ExpectationFailed, steps
2+
3+
4+
class RunIdFileTest(MetaflowTest):
5+
"""
6+
Resuming and initial running of a flow should write run id file early (prior to execution)
7+
"""
8+
9+
RESUME = True
10+
PRIORITY = 3
11+
12+
@steps(0, ["singleton-start"], required=True)
13+
def step_start(self):
14+
import os
15+
from metaflow import current
16+
17+
# Whether we are in "run" or "resume" mode, --run-id-file must be written prior to execution
18+
assert os.path.isfile(
19+
"run-id"
20+
), "run id file should exist before resume execution"
21+
with open("run-id", "r") as f:
22+
run_id_from_file = f.read()
23+
assert run_id_from_file == current.run_id
24+
25+
# Test both regular run and resume paths
26+
if not is_resumed():
27+
raise ResumeFromHere()
28+
29+
@steps(2, ["all"])
30+
def step_all(self):
31+
pass
32+
33+
def check_results(self, flow, checker):
34+
pass

0 commit comments

Comments
 (0)