Skip to content

Commit 5a9a192

Browse files
authored
fix wandb large config error (#203)
* try to fix * fix errors * remove CommError import * try to fix typing errors
1 parent bfb9f94 commit 5a9a192

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

autointent/_callbacks/wandb.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import logging
12
import os
23
from pathlib import Path
34
from typing import Any
45

56
from autointent._callbacks.base import OptimizerCallback
67

8+
logger = logging.getLogger(__name__)
9+
710

811
class WandbCallback(OptimizerCallback):
912
"""Wandb callback for logging the optimization process to Weights & Biases (W&B).
@@ -94,13 +97,26 @@ def log_final_metrics(self, metrics: dict[str, Any]) -> None:
9497
Args:
9598
metrics: A dictionary of final performance metrics.
9699
"""
97-
self.wandb.init(
98-
project=self.project_name,
99-
group=self.group,
100-
name="final_metrics",
101-
config=metrics,
102-
settings=self.wandb.Settings(x_stats_sampling_interval=self.log_interval_time),
103-
)
100+
wandb_run_init_args = {
101+
"project": self.project_name,
102+
"group": self.group,
103+
"name": "final_metrics",
104+
"settings": self.wandb.Settings(x_stats_sampling_interval=self.log_interval_time),
105+
}
106+
107+
try:
108+
self.wandb.init(config=metrics, **wandb_run_init_args)
109+
except Exception as e:
110+
if "run config cannot exceed" not in str(e):
111+
# https://github.com/deeppavlov/AutoIntent/issues/202
112+
raise
113+
logger.warning("W&B run config is too large, skipping logging modules configs")
114+
logger.warning("'final_metrics' will be logged to W&B with pipeline_metrics only")
115+
logger.warning("If you want to access modules configs in future, address to the individual modules runs")
116+
self.wandb.init(
117+
config={},
118+
**wandb_run_init_args,
119+
)
104120

105121
self.wandb.log(metrics.get("pipeline_metrics", {}))
106122
self.wandb.finish()

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ docs = [
8686
dspy = [
8787
"dspy (>=2.6.5,<3.0.0)",
8888
]
89+
wandb = [
90+
"wandb (>=0.19.10,<1.0.0)",
91+
]
8992

9093
[project.urls]
9194
Homepage = "https://deeppavlov.github.io/AutoIntent/"

0 commit comments

Comments
 (0)