|
23 | 23 |
|
24 | 24 | import argparse
|
25 | 25 | import atexit
|
26 |
| -import copy |
27 | 26 | import logging as stdlogging
|
28 | 27 | import multiprocessing as mp
|
29 | 28 | import os
|
@@ -182,7 +181,8 @@ def _extract_logging_config(self, config: "Config") -> dict:
|
182 | 181 | Returns:
|
183 | 182 | (dict): btlogging's config from Bittensor config or Bittensor config.
|
184 | 183 | """
|
185 |
| - if hasattr(config, "logging"): |
| 184 | + # This is to handle nature of DefaultMunch |
| 185 | + if getattr(config, "logging", None): |
186 | 186 | return config.logging
|
187 | 187 | else:
|
188 | 188 | return config
|
@@ -213,14 +213,14 @@ def set_config(self, config: "Config"):
|
213 | 213 | Args:
|
214 | 214 | config (bittensor.core.config.Config): Bittensor config instance.
|
215 | 215 | """
|
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: |
218 | 218 | expanded_dir = os.path.expanduser(config.logging_dir)
|
219 | 219 | logfile = os.path.abspath(os.path.join(expanded_dir, DEFAULT_LOG_FILE_NAME))
|
220 | 220 | self._enable_file_logging(logfile)
|
221 |
| - if config.trace: |
| 221 | + if self._config.trace: |
222 | 222 | self.enable_trace()
|
223 |
| - elif config.debug: |
| 223 | + elif self._config.debug: |
224 | 224 | self.enable_debug()
|
225 | 225 |
|
226 | 226 | def _create_and_start_listener(self, handlers):
|
@@ -618,7 +618,7 @@ def __call__(
|
618 | 618 | logging_dir: str = None,
|
619 | 619 | ):
|
620 | 620 | if config is not None:
|
621 |
| - cfg = copy.deepcopy(config) |
| 621 | + cfg = self._extract_logging_config(config) |
622 | 622 | if debug is not None:
|
623 | 623 | cfg.debug = debug
|
624 | 624 | elif trace is not None:
|
|
0 commit comments