diff --git a/src/super_gradients/common/auto_logging/auto_logger.py b/src/super_gradients/common/auto_logging/auto_logger.py index 312bf655c1..e0ef358a05 100755 --- a/src/super_gradients/common/auto_logging/auto_logger.py +++ b/src/super_gradients/common/auto_logging/auto_logger.py @@ -32,7 +32,7 @@ def _setup_default_logging(self, log_level: str = None) -> None: # Therefore the log file will have the parent PID to being able to discriminate the logs corresponding to a single run. timestamp = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime()) self._setup_logging( - filename=os.path.expanduser(f"~/sg_logs/logs_{os.getppid()}_{timestamp}.log"), + filename=os.path.join(env_variables.SUPER_GRADIENTS_LOG_DIR, f"logs_{os.getppid()}_{timestamp}.log"), copy_already_logged_messages=False, filemode="w", log_level=log_level, diff --git a/src/super_gradients/common/auto_logging/console_logging.py b/src/super_gradients/common/auto_logging/console_logging.py index 7a3f8ecbb2..b7a9e0d9aa 100644 --- a/src/super_gradients/common/auto_logging/console_logging.py +++ b/src/super_gradients/common/auto_logging/console_logging.py @@ -7,6 +7,7 @@ from threading import Lock from super_gradients.common.environment.ddp_utils import multi_process_safe, is_main_process +from super_gradients.common.environment.env_variables import env_variables class BufferWriter: @@ -117,7 +118,7 @@ def __init__(self): @multi_process_safe def _setup(self): """On instantiation, setup the default sink file.""" - filename = Path.home() / "sg_logs" / "console.log" + filename = Path(env_variables.SUPER_GRADIENTS_LOG_DIR) / "console.log" filename.parent.mkdir(exist_ok=True) self.filename = str(filename) os.makedirs(os.path.dirname(self.filename), exist_ok=True) diff --git a/src/super_gradients/common/environment/env_variables.py b/src/super_gradients/common/environment/env_variables.py index 24f35933a1..557caca58a 100644 --- a/src/super_gradients/common/environment/env_variables.py +++ b/src/super_gradients/common/environment/env_variables.py @@ -1,4 +1,5 @@ import os +from pathlib import Path from typing import Optional @@ -45,5 +46,9 @@ def HYDRA_FULL_ERROR(self) -> Optional[str]: def HYDRA_FULL_ERROR(self, value: str): os.environ["HYDRA_FULL_ERROR"] = value + @property + def SUPER_GRADIENTS_LOG_DIR(self) -> str: + return os.getenv("SUPER_GRADIENTS_LOG_DIR", default=str(Path.home() / "sg_logs")) + env_variables = EnvironmentVariables()