From 3bc11271213e7ce551caca6781f41570c2f617d4 Mon Sep 17 00:00:00 2001 From: Chaoying Wang Date: Thu, 16 Jan 2025 00:59:03 -0800 Subject: [PATCH] reload all related parameters in runner --- metaflow/runner/deployer_impl.py | 11 ++++++----- metaflow/runner/metaflow_runner.py | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/metaflow/runner/deployer_impl.py b/metaflow/runner/deployer_impl.py index f5a8bca1ad..fafafd66cd 100644 --- a/metaflow/runner/deployer_impl.py +++ b/metaflow/runner/deployer_impl.py @@ -63,11 +63,12 @@ def __init__( from metaflow.parameters import flow_context - if "metaflow.cli" in sys.modules: - # Reload the CLI with an "empty" flow -- this will remove any configuration - # options. They are re-added in from_cli (called below). - with flow_context(None) as _: - importlib.reload(sys.modules["metaflow.cli"]) + # Reload the CLI with an "empty" flow -- this will remove any configuration + # options. They are re-added in from_cli (called below). + to_be_reload = ["metaflow.cli", "metaflow.cli_components.run_cmds", "metaflow.cli_components.init_cmds"] + with flow_context(None): + [importlib.reload(sys.modules[module]) for module in to_be_reload if module in sys.modules] + from metaflow.cli import start from metaflow.runner.click_api import MetaflowAPI diff --git a/metaflow/runner/metaflow_runner.py b/metaflow/runner/metaflow_runner.py index d1656599d8..098db71d61 100644 --- a/metaflow/runner/metaflow_runner.py +++ b/metaflow/runner/metaflow_runner.py @@ -268,12 +268,13 @@ def __init__( # 'from .metaflow_runner import Runner' in '__init__.py' from metaflow.parameters import flow_context + + # Reload the CLI with an "empty" flow -- this will remove any configuration + # options. They are re-added in from_cli (called below). + to_be_reload = ["metaflow.cli", "metaflow.cli_components.run_cmds", "metaflow.cli_components.init_cmds"] + with flow_context(None): + [importlib.reload(sys.modules[module]) for module in to_be_reload if module in sys.modules] - if "metaflow.cli" in sys.modules: - # Reload the CLI with an "empty" flow -- this will remove any configuration - # options. They are re-added in from_cli (called below). - with flow_context(None) as _: - importlib.reload(sys.modules["metaflow.cli"]) from metaflow.cli import start from metaflow.runner.click_api import MetaflowAPI