Skip to content

Commit c03ce8c

Browse files
committed
add comments for why reset of env and metadata is needed
1 parent da6090b commit c03ce8c

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
@@ -234,12 +234,22 @@ async def __aenter__(self) -> "Runner":
234234
return self
235235

236236
def __get_executing_run(self, tfp_metadata_pathspec, command_obj):
237+
# When two 'Runner' executions are done sequentially i.e. one after the other
238+
# the 2nd run kinda uses the 1st run's previously set metadata and
239+
# environment variables.
240+
241+
# It is thus necessary to set them to correct values before we return
242+
# the Run object.
237243
try:
244+
# Set the environment variables to what they were before the run executed.
238245
clear_and_set_os_environ(self.old_env)
246+
247+
# Set the correct metadata from the runner_attribute file corresponding to this run.
239248
content = read_from_file_when_ready(tfp_metadata_pathspec.name, timeout=5)
240249
metadata_for_flow, pathspec = content.split(":", maxsplit=1)
241-
# set the current metadata from the metadata_pathspec file
242250
metadata(metadata_for_flow)
251+
252+
# Finally, create the Run object.
243253
run_object = Run(pathspec, _namespace_check=False)
244254
return ExecutingRun(self, command_obj, run_object)
245255
except TimeoutError as e:

0 commit comments

Comments
 (0)