Skip to content

Commit 026f97a

Browse files
committed
add comments for why reset of env and metadata is needed
1 parent 5b28338 commit 026f97a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

metaflow/runner/metaflow_runner.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,22 @@ async def __aenter__(self) -> "Runner":
248248
return self
249249

250250
def __get_executing_run(self, tfp_metadata_pathspec, command_obj):
251+
# When two 'Runner' executions are done sequentially i.e. one after the other
252+
# the 2nd run kinda uses the 1st run's previously set metadata and
253+
# environment variables.
254+
255+
# It is thus necessary to set them to correct values before we return
256+
# the Run object.
251257
try:
258+
# Set the environment variables to what they were before the run executed.
252259
clear_and_set_os_environ(self.old_env)
260+
261+
# Set the correct metadata from the runner_attribute file corresponding to this run.
253262
content = read_from_file_when_ready(tfp_metadata_pathspec.name, timeout=10)
254263
metadata_for_flow, pathspec = content.split(":", maxsplit=1)
255-
# set the current metadata from the metadata_pathspec file
256264
metadata(metadata_for_flow)
265+
266+
# Finally, create the Run object.
257267
run_object = Run(pathspec, _namespace_check=False)
258268
return ExecutingRun(self, command_obj, run_object)
259269
except TimeoutError as e:

0 commit comments

Comments
 (0)