From 15a7b4d2ef110135ceeefdeebd821cf2bf90dac4 Mon Sep 17 00:00:00 2001 From: Louis Dupont Date: Wed, 23 Aug 2023 09:55:29 +0300 Subject: [PATCH 1/3] fix --- .../common/environment/checkpoints_dir_utils.py | 2 ++ src/super_gradients/common/sg_loggers/base_sg_logger.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/super_gradients/common/environment/checkpoints_dir_utils.py b/src/super_gradients/common/environment/checkpoints_dir_utils.py index 5a136bdd37..571627fc0b 100644 --- a/src/super_gradients/common/environment/checkpoints_dir_utils.py +++ b/src/super_gradients/common/environment/checkpoints_dir_utils.py @@ -3,6 +3,7 @@ import pkg_resources from typing import Optional from datetime import datetime +from pathlib import Path from super_gradients.common.abstractions.abstract_logger import get_logger @@ -108,6 +109,7 @@ def get_checkpoints_dir_path(experiment_name: str, ckpt_root_dir: Optional[str] """ experiment_dir = get_experiment_dir_path(checkpoints_root_dir=ckpt_root_dir, experiment_name=experiment_name) checkpoint_dir = experiment_dir if run_id is None else os.path.join(experiment_dir, run_id) + Path(checkpoint_dir).mkdir(exist_ok=True, parents=True) return checkpoint_dir diff --git a/src/super_gradients/common/sg_loggers/base_sg_logger.py b/src/super_gradients/common/sg_loggers/base_sg_logger.py index f38c7c1812..e5210c528f 100644 --- a/src/super_gradients/common/sg_loggers/base_sg_logger.py +++ b/src/super_gradients/common/sg_loggers/base_sg_logger.py @@ -133,7 +133,8 @@ def _setup_dir(self): # Only if it exists, i.e. if hydra was used. if os.path.exists(source_hydra_path): destination_hydra_path = os.path.join(self._local_dir, ".hydra") - shutil.copytree(source_hydra_path, destination_hydra_path) + if not os.path.exists(destination_hydra_path): + shutil.copytree(source_hydra_path, destination_hydra_path) @multi_process_safe def _init_log_file(self): From d700a7664aed5ab59ee9f5603522da201ba8be6d Mon Sep 17 00:00:00 2001 From: Louis Dupont Date: Wed, 23 Aug 2023 10:00:18 +0300 Subject: [PATCH 2/3] replace change --- src/super_gradients/common/sg_loggers/base_sg_logger.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/super_gradients/common/sg_loggers/base_sg_logger.py b/src/super_gradients/common/sg_loggers/base_sg_logger.py index e5210c528f..0ba5f47788 100644 --- a/src/super_gradients/common/sg_loggers/base_sg_logger.py +++ b/src/super_gradients/common/sg_loggers/base_sg_logger.py @@ -133,8 +133,7 @@ def _setup_dir(self): # Only if it exists, i.e. if hydra was used. if os.path.exists(source_hydra_path): destination_hydra_path = os.path.join(self._local_dir, ".hydra") - if not os.path.exists(destination_hydra_path): - shutil.copytree(source_hydra_path, destination_hydra_path) + shutil.copytree(source_hydra_path, destination_hydra_path, dirs_exist_ok=True) @multi_process_safe def _init_log_file(self): From 0690e76b4a19d809868eb67c72fa1dc0b0b89038 Mon Sep 17 00:00:00 2001 From: Louis Dupont Date: Wed, 23 Aug 2023 10:03:51 +0300 Subject: [PATCH 3/3] use os --- .../common/environment/checkpoints_dir_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/super_gradients/common/environment/checkpoints_dir_utils.py b/src/super_gradients/common/environment/checkpoints_dir_utils.py index 571627fc0b..00beb53149 100644 --- a/src/super_gradients/common/environment/checkpoints_dir_utils.py +++ b/src/super_gradients/common/environment/checkpoints_dir_utils.py @@ -3,7 +3,6 @@ import pkg_resources from typing import Optional from datetime import datetime -from pathlib import Path from super_gradients.common.abstractions.abstract_logger import get_logger @@ -109,7 +108,7 @@ def get_checkpoints_dir_path(experiment_name: str, ckpt_root_dir: Optional[str] """ experiment_dir = get_experiment_dir_path(checkpoints_root_dir=ckpt_root_dir, experiment_name=experiment_name) checkpoint_dir = experiment_dir if run_id is None else os.path.join(experiment_dir, run_id) - Path(checkpoint_dir).mkdir(exist_ok=True, parents=True) + os.makedirs(checkpoint_dir, exist_ok=True) return checkpoint_dir