diff --git a/metaflow/runner/metaflow_runner.py b/metaflow/runner/metaflow_runner.py index d162c236a7e..fe0a2720e9c 100644 --- a/metaflow/runner/metaflow_runner.py +++ b/metaflow/runner/metaflow_runner.py @@ -428,3 +428,6 @@ def __exit__(self, exc_type, exc_value, traceback): async def __aexit__(self, exc_type, exc_value, traceback): self.spm.cleanup() + + def cleanup(self): + self.spm.cleanup() diff --git a/metaflow/runner/nbrun.py b/metaflow/runner/nbrun.py index 2d55218724f..58a9a1f5f1c 100644 --- a/metaflow/runner/nbrun.py +++ b/metaflow/runner/nbrun.py @@ -101,12 +101,12 @@ def __init__( def nbrun(self, **kwargs): result = self.runner.run(**kwargs) - self.runner.spm.cleanup() + self.cleanup() return result.run def nbresume(self, **kwargs): result = self.runner.resume(**kwargs) - self.runner.spm.cleanup() + self.cleanup() return result.run def run(self, **kwargs): @@ -132,3 +132,7 @@ async def async_resume(self, **kwargs): Asynchronously resumes the flow. """ return await self.runner.async_resume(**kwargs) + + def cleanup(self): + os.remove(self.tmp_flow_file.name) + self.runner.cleanup()