Skip to content

Commit

Permalink
Implement wandb settings conversion for latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
schustmi committed Dec 5, 2024
1 parent 61988c0 commit 8cc73d0
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
cast,
)

from pydantic import field_validator
from pydantic import field_validator, BaseModel

from zenml.config.base_settings import BaseSettings
from zenml.experiment_trackers.base_experiment_tracker import (
Expand Down Expand Up @@ -60,18 +60,26 @@ def _convert_settings(cls, value: Any) -> Any:
Args:
value: The settings.
Raises:
ValueError: If converting the settings failed.
Returns:
Dict representation of the settings.
"""
import wandb

if isinstance(value, wandb.Settings):
# Depending on the wandb version, either `make_static` or `to_dict`
# is available to convert the settings to a dictionary
if hasattr(value, "make_static"):
# Depending on the wandb version, either `model_dump`,
# `make_static` or `to_dict` is available to convert the settings
# to a dictionary
if isinstance(value, BaseModel):
return value.model_dump()
elif hasattr(value, "make_static"):
return cast(Dict[str, Any], value.make_static())
else:
elif hasattr(value, "to_dict"):
return value.to_dict()
else:
raise ValueError("Unable to convert wandb settings to dict.")
else:
return value

Expand Down

0 comments on commit 8cc73d0

Please sign in to comment.