Skip to content

Commit 6e77f0b

Browse files
wandb hack (#574)
Co-authored-by: Felipe Mello <[email protected]>
1 parent 3d69189 commit 6e77f0b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/forge/util/logging.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7+
# FIXME: remove this once wandb fixed this issue
8+
# https://github.com/wandb/wandb/issues/10890
9+
# Patch importlib.metadata.distributions before wandb imports it
10+
# to filter out packages with None metadata
11+
import importlib.metadata
12+
13+
# Guard to ensure this runs only once
14+
if not hasattr(importlib.metadata, "_distributions_patched"):
15+
_original_distributions = importlib.metadata.distributions
16+
17+
def _patched_distributions():
18+
"""Filter out distributions with None metadata"""
19+
for distribution in _original_distributions():
20+
if distribution.metadata is not None:
21+
yield distribution
22+
23+
importlib.metadata.distributions = _patched_distributions
24+
importlib.metadata._distributions_patched = True
25+
726
import logging
827
from functools import lru_cache
928

0 commit comments

Comments
 (0)