diff --git a/src/forge/util/logging.py b/src/forge/util/logging.py index 9eacf893d..8a7c1c99d 100644 --- a/src/forge/util/logging.py +++ b/src/forge/util/logging.py @@ -4,6 +4,25 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. +# FIXME: remove this once wandb fixed this issue +# https://github.com/wandb/wandb/issues/10890 +# Patch importlib.metadata.distributions before wandb imports it +# to filter out packages with None metadata +import importlib.metadata + +# Guard to ensure this runs only once +if not hasattr(importlib.metadata, "_distributions_patched"): + _original_distributions = importlib.metadata.distributions + + def _patched_distributions(): + """Filter out distributions with None metadata""" + for distribution in _original_distributions(): + if distribution.metadata is not None: + yield distribution + + importlib.metadata.distributions = _patched_distributions + importlib.metadata._distributions_patched = True + import logging from functools import lru_cache