Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wandb config run name #195

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/zeroband/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def train(config: Config):
logger_cls = WandbMetricLogger if config.metric_logger_type == "wandb" else DummyMetricLogger
metric_logger = logger_cls(
project=config.project,
config={"config": config.model_dump(), "world_info": world_info.json()},
logger_config={"config": config.model_dump(), "world_info": world_info.json()},
resume=config.wandb_resume,
)
else:
Expand Down
14 changes: 6 additions & 8 deletions src/zeroband/utils/metric_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@
from typing import Any, Protocol
import importlib.util

from zeroband.config import get_env_config


class MetricLogger(Protocol):
def __init__(self, project, config): ...
def __init__(self, project, logger_config): ...

def log(self, metrics: dict[str, Any]): ...

def finish(self): ...


class WandbMetricLogger(MetricLogger):
def __init__(self, project, config, resume: bool):
def __init__(self, project, logger_config, resume: bool):
if importlib.util.find_spec("wandb") is None:
raise ImportError("wandb is not installed. Please install it to use WandbMonitor.")

import wandb

run_name = get_env_config(config, "run_name")
run_name = logger_config["config"]["run_name"]

wandb.init(
project=project, config=config, name=run_name, resume="auto" if resume else None
project=project, config=logger_config, name=run_name, resume="auto" if resume else None
) # make wandb reuse the same run id if possible

def log(self, metrics: dict[str, Any]):
Expand All @@ -38,9 +36,9 @@ def finish(self):


class DummyMetricLogger(MetricLogger):
def __init__(self, project, config, *args, **kwargs):
def __init__(self, project, logger_config, *args, **kwargs):
self.project = project
self.config = config
self.logger_config = logger_config
open(self.project, "a").close() # Create an empty file to append to

self.data = []
Expand Down
Loading