From c8b500d0d602004f750b4234d50994fa0405d36a Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Thu, 28 Nov 2024 12:34:28 -0800 Subject: [PATCH 1/5] Fixed logging configs not getting parsed when passing whole bittensor config --- bittensor/utils/btlogging/loggingmachine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/utils/btlogging/loggingmachine.py b/bittensor/utils/btlogging/loggingmachine.py index d4441054de..a3c51b3978 100644 --- a/bittensor/utils/btlogging/loggingmachine.py +++ b/bittensor/utils/btlogging/loggingmachine.py @@ -213,7 +213,7 @@ def set_config(self, config: "Config"): Args: config (bittensor.core.config.Config): Bittensor config instance. """ - self._config = config + self._config = config = self._extract_logging_config(config) if config.logging_dir and config.record_log: expanded_dir = os.path.expanduser(config.logging_dir) logfile = os.path.abspath(os.path.join(expanded_dir, DEFAULT_LOG_FILE_NAME)) From 04a8714d1168b15b42157bea86416b2d6e627de8 Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Thu, 28 Nov 2024 15:12:41 -0800 Subject: [PATCH 2/5] Handles defaultmunch behaviour --- bittensor/utils/btlogging/loggingmachine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/utils/btlogging/loggingmachine.py b/bittensor/utils/btlogging/loggingmachine.py index a3c51b3978..4915e3a30e 100644 --- a/bittensor/utils/btlogging/loggingmachine.py +++ b/bittensor/utils/btlogging/loggingmachine.py @@ -182,7 +182,7 @@ def _extract_logging_config(self, config: "Config") -> dict: Returns: (dict): btlogging's config from Bittensor config or Bittensor config. """ - if hasattr(config, "logging"): + if hasattr(config, "logging") and getattr(config, "logging", None): return config.logging else: return config From 35fd6763d2c039ec5ffc2a064ba30c0788d16f1c Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Fri, 29 Nov 2024 11:32:56 -0800 Subject: [PATCH 3/5] Improvements --- bittensor/utils/btlogging/loggingmachine.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bittensor/utils/btlogging/loggingmachine.py b/bittensor/utils/btlogging/loggingmachine.py index 4915e3a30e..e6fe0704e0 100644 --- a/bittensor/utils/btlogging/loggingmachine.py +++ b/bittensor/utils/btlogging/loggingmachine.py @@ -182,7 +182,8 @@ def _extract_logging_config(self, config: "Config") -> dict: Returns: (dict): btlogging's config from Bittensor config or Bittensor config. """ - if hasattr(config, "logging") and getattr(config, "logging", None): + # This is to handle + if getattr(config, "logging", None): return config.logging else: return config @@ -213,14 +214,14 @@ def set_config(self, config: "Config"): Args: config (bittensor.core.config.Config): Bittensor config instance. """ - self._config = config = self._extract_logging_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 +619,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: From b70c2cd700b3f6cc7068f351a6bd5a34cd3177a4 Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Fri, 29 Nov 2024 12:16:47 -0800 Subject: [PATCH 4/5] Removes unused import --- bittensor/utils/btlogging/loggingmachine.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bittensor/utils/btlogging/loggingmachine.py b/bittensor/utils/btlogging/loggingmachine.py index e6fe0704e0..f172b9d5e8 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 From 263218ab5c65bc7bf36bb93a129ecc240f1f234d Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Fri, 29 Nov 2024 12:17:48 -0800 Subject: [PATCH 5/5] Completes comment --- bittensor/utils/btlogging/loggingmachine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/utils/btlogging/loggingmachine.py b/bittensor/utils/btlogging/loggingmachine.py index f172b9d5e8..96d0b2ceed 100644 --- a/bittensor/utils/btlogging/loggingmachine.py +++ b/bittensor/utils/btlogging/loggingmachine.py @@ -181,7 +181,7 @@ def _extract_logging_config(self, config: "Config") -> dict: Returns: (dict): btlogging's config from Bittensor config or Bittensor config. """ - # This is to handle + # This is to handle nature of DefaultMunch if getattr(config, "logging", None): return config.logging else: