diff --git a/bittensor/utils/btlogging/loggingmachine.py b/bittensor/utils/btlogging/loggingmachine.py index d4441054de..96d0b2ceed 100644 --- a/bittensor/utils/btlogging/loggingmachine.py +++ b/bittensor/utils/btlogging/loggingmachine.py @@ -23,7 +23,6 @@ import argparse import atexit -import copy import logging as stdlogging import multiprocessing as mp import os @@ -182,7 +181,8 @@ def _extract_logging_config(self, config: "Config") -> dict: Returns: (dict): btlogging's config from Bittensor config or Bittensor config. """ - if hasattr(config, "logging"): + # This is to handle nature of DefaultMunch + if getattr(config, "logging", None): return config.logging else: return config @@ -213,14 +213,14 @@ def set_config(self, config: "Config"): Args: config (bittensor.core.config.Config): Bittensor config instance. """ - self._config = config - if config.logging_dir and config.record_log: + self._config = self._extract_logging_config(config) + if self._config.logging_dir and self._config.record_log: expanded_dir = os.path.expanduser(config.logging_dir) logfile = os.path.abspath(os.path.join(expanded_dir, DEFAULT_LOG_FILE_NAME)) self._enable_file_logging(logfile) - if config.trace: + if self._config.trace: self.enable_trace() - elif config.debug: + elif self._config.debug: self.enable_debug() def _create_and_start_listener(self, handlers): @@ -618,7 +618,7 @@ def __call__( logging_dir: str = None, ): if config is not None: - cfg = copy.deepcopy(config) + cfg = self._extract_logging_config(config) if debug is not None: cfg.debug = debug elif trace is not None: