From 317130825c27bb00af2ab04b4082e86409971c62 Mon Sep 17 00:00:00 2001 From: madhur-ob <155637867+madhur-ob@users.noreply.github.com> Date: Thu, 10 Oct 2024 02:08:38 +0530 Subject: [PATCH] use cwd in nbrunner and nbdeployer (#2088) * use cwd in nbrunner and nbdeployer * address nits --- metaflow/runner/nbdeploy.py | 10 ++++------ metaflow/runner/nbrun.py | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/metaflow/runner/nbdeploy.py b/metaflow/runner/nbdeploy.py index 1fe9634f6b1..dea8c0f41cf 100644 --- a/metaflow/runner/nbdeploy.py +++ b/metaflow/runner/nbdeploy.py @@ -5,8 +5,6 @@ from metaflow import Deployer from metaflow.runner.utils import get_current_cell, format_flowfile -DEFAULT_DIR = tempfile.gettempdir() - class NBDeployerInitializationError(Exception): """Custom exception for errors during NBDeployer initialization.""" @@ -46,8 +44,8 @@ class NBDeployer(object): Additional environment variables to set. This overrides the environment set for this process. base_dir : Optional[str], default None - The directory to run the subprocess in; if not specified, a temporary - directory is used. + The directory to run the subprocess in; if not specified, the current + working directory is used. **kwargs : Any Additional arguments that you would pass to `python myflow.py` i.e. options listed in `python myflow.py --help` @@ -60,7 +58,7 @@ def __init__( show_output: bool = True, profile: Optional[str] = None, env: Optional[Dict] = None, - base_dir: str = DEFAULT_DIR, + base_dir: Optional[str] = None, file_read_timeout: int = 3600, **kwargs, ): @@ -78,7 +76,7 @@ def __init__( self.show_output = show_output self.profile = profile self.env = env - self.cwd = base_dir + self.cwd = base_dir if base_dir is not None else os.getcwd() self.file_read_timeout = file_read_timeout self.top_level_kwargs = kwargs diff --git a/metaflow/runner/nbrun.py b/metaflow/runner/nbrun.py index 62b9a53d37e..400a77a85b8 100644 --- a/metaflow/runner/nbrun.py +++ b/metaflow/runner/nbrun.py @@ -5,8 +5,6 @@ from metaflow import Runner from metaflow.runner.utils import get_current_cell, format_flowfile -DEFAULT_DIR = tempfile.gettempdir() - class NBRunnerInitializationError(Exception): """Custom exception for errors during NBRunner initialization.""" @@ -43,8 +41,8 @@ class NBRunner(object): Additional environment variables to set for the Run. This overrides the environment set for this process. base_dir : Optional[str], default None - The directory to run the subprocess in; if not specified, a temporary - directory is used. + The directory to run the subprocess in; if not specified, the current + working directory is used. file_read_timeout : int, default 3600 The timeout until which we try to read the runner attribute file. **kwargs : Any @@ -59,7 +57,7 @@ def __init__( show_output: bool = True, profile: Optional[str] = None, env: Optional[Dict] = None, - base_dir: str = DEFAULT_DIR, + base_dir: Optional[str] = None, file_read_timeout: int = 3600, **kwargs, ): @@ -84,7 +82,7 @@ def __init__( if profile: self.env_vars["METAFLOW_PROFILE"] = profile - self.base_dir = base_dir + self.base_dir = base_dir if base_dir is not None else os.getcwd() self.file_read_timeout = file_read_timeout if not self.cell: