Skip to content

Commit aac3e1a

Browse files
authored
Merge pull request #2500 from opentensor/fix/logging-configs-parsing
2 parents 3e56d5e + 263218a commit aac3e1a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

bittensor/utils/btlogging/loggingmachine.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import argparse
2525
import atexit
26-
import copy
2726
import logging as stdlogging
2827
import multiprocessing as mp
2928
import os
@@ -182,7 +181,8 @@ def _extract_logging_config(self, config: "Config") -> dict:
182181
Returns:
183182
(dict): btlogging's config from Bittensor config or Bittensor config.
184183
"""
185-
if hasattr(config, "logging"):
184+
# This is to handle nature of DefaultMunch
185+
if getattr(config, "logging", None):
186186
return config.logging
187187
else:
188188
return config
@@ -213,14 +213,14 @@ def set_config(self, config: "Config"):
213213
Args:
214214
config (bittensor.core.config.Config): Bittensor config instance.
215215
"""
216-
self._config = config
217-
if config.logging_dir and config.record_log:
216+
self._config = self._extract_logging_config(config)
217+
if self._config.logging_dir and self._config.record_log:
218218
expanded_dir = os.path.expanduser(config.logging_dir)
219219
logfile = os.path.abspath(os.path.join(expanded_dir, DEFAULT_LOG_FILE_NAME))
220220
self._enable_file_logging(logfile)
221-
if config.trace:
221+
if self._config.trace:
222222
self.enable_trace()
223-
elif config.debug:
223+
elif self._config.debug:
224224
self.enable_debug()
225225

226226
def _create_and_start_listener(self, handlers):
@@ -618,7 +618,7 @@ def __call__(
618618
logging_dir: str = None,
619619
):
620620
if config is not None:
621-
cfg = copy.deepcopy(config)
621+
cfg = self._extract_logging_config(config)
622622
if debug is not None:
623623
cfg.debug = debug
624624
elif trace is not None:

0 commit comments

Comments
 (0)