From 2639a31ef2ca4f902854972f98bdc8ebf17dd0dc Mon Sep 17 00:00:00 2001 From: Maxime Date: Thu, 6 Oct 2022 16:26:52 +0200 Subject: [PATCH 1/3] Command format fix with backslashes Signed-off-by: Maxime --- monai/apps/auto3dseg/bundle_gen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monai/apps/auto3dseg/bundle_gen.py b/monai/apps/auto3dseg/bundle_gen.py index bc96691ac4..796b2f3ef1 100644 --- a/monai/apps/auto3dseg/bundle_gen.py +++ b/monai/apps/auto3dseg/bundle_gen.py @@ -180,7 +180,8 @@ def _run_cmd(self, cmd: str, devices_info: str): ps_environ = os.environ.copy() if devices_info: ps_environ["CUDA_VISIBLE_DEVICES"] = devices_info - normal_out = subprocess.run(cmd.split(), env=ps_environ, check=True, capture_output=True) + cmd = [f'{c}'.replace("\\", "/") for c in cmd.split()] + normal_out = subprocess.run(cmd, env=ps_environ, check=True, capture_output=True) logger.info(repr(normal_out).replace("\\n", "\n").replace("\\t", "\t")) except subprocess.CalledProcessError as e: output = repr(e.stdout).replace("\\n", "\n").replace("\\t", "\t") From e972f249aaefde85a1ac1391b728052408b1ad4e Mon Sep 17 00:00:00 2001 From: Mingxin Zheng Date: Thu, 13 Oct 2022 21:54:13 +0800 Subject: [PATCH 2/3] fix python fire config file path on Windows Signed-off-by: Mingxin Zheng --- monai/apps/auto3dseg/bundle_gen.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/monai/apps/auto3dseg/bundle_gen.py b/monai/apps/auto3dseg/bundle_gen.py index 796b2f3ef1..8c0899962d 100644 --- a/monai/apps/auto3dseg/bundle_gen.py +++ b/monai/apps/auto3dseg/bundle_gen.py @@ -17,7 +17,7 @@ from copy import deepcopy from tempfile import TemporaryDirectory from typing import Any, Dict, List, Mapping - +from pathlib import Path import torch from monai.apps import download_and_extract @@ -28,7 +28,7 @@ from monai.utils import ensure_tuple logger = get_logger(module_name=__name__) -ALGO_HASH = os.environ.get("MONAI_ALGO_HASH", "004a63c") +ALGO_HASH = os.environ.get("MONAI_ALGO_HASH", "d7bf36c") __all__ = ["BundleAlgo", "BundleGen"] @@ -152,7 +152,8 @@ def _create_cmd(self, train_params=None): base_cmd += f"{train_py} run --config_file=" else: base_cmd += "," # Python Fire does not accept space - config_yaml = os.path.join(config_dir, file) + # Python Fire may be confused by single-quoted WindowsPath + config_yaml = Path(os.path.join(config_dir, file)).as_posix() base_cmd += f"'{config_yaml}'" if "CUDA_VISIBLE_DEVICES" in params: @@ -180,8 +181,7 @@ def _run_cmd(self, cmd: str, devices_info: str): ps_environ = os.environ.copy() if devices_info: ps_environ["CUDA_VISIBLE_DEVICES"] = devices_info - cmd = [f'{c}'.replace("\\", "/") for c in cmd.split()] - normal_out = subprocess.run(cmd, env=ps_environ, check=True, capture_output=True) + normal_out = subprocess.run(cmd.split(), env=ps_environ, check=True, capture_output=True) logger.info(repr(normal_out).replace("\\n", "\n").replace("\\t", "\t")) except subprocess.CalledProcessError as e: output = repr(e.stdout).replace("\\n", "\n").replace("\\t", "\t") From fb32848b29988ea0c7168452a9e2ebdf328d826b Mon Sep 17 00:00:00 2001 From: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> Date: Fri, 14 Oct 2022 10:54:54 +0800 Subject: [PATCH 3/3] fix isort complaint Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> --- monai/apps/auto3dseg/bundle_gen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monai/apps/auto3dseg/bundle_gen.py b/monai/apps/auto3dseg/bundle_gen.py index 8c0899962d..eea7604846 100644 --- a/monai/apps/auto3dseg/bundle_gen.py +++ b/monai/apps/auto3dseg/bundle_gen.py @@ -15,9 +15,10 @@ import subprocess import sys from copy import deepcopy +from pathlib import Path from tempfile import TemporaryDirectory from typing import Any, Dict, List, Mapping -from pathlib import Path + import torch from monai.apps import download_and_extract