-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tracking of different runs when using
WandbLogger
(#766)
- Loading branch information
Showing
3 changed files
with
73 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# type: ignore | ||
"""Utility functions for logging with Weights & Biases.""" | ||
|
||
from typing import Any, Dict | ||
|
||
from loguru import logger | ||
|
||
|
||
def rename_active_run(name: str) -> None: | ||
"""Renames the current run.""" | ||
import wandb | ||
|
||
if wandb.run: | ||
wandb.run.name = name | ||
wandb.run.save() | ||
else: | ||
logger.warning("No active wandb run found that could be renamed.") | ||
|
||
|
||
def init_run(name: str, init_kwargs: Dict[str, Any]) -> None: | ||
"""Initializes a new run. If there is an active run, it will be renamed and reused.""" | ||
import wandb | ||
|
||
init_kwargs["name"] = name | ||
rename_active_run(name) | ||
wandb.init(**init_kwargs) | ||
|
||
|
||
def finish_run() -> None: | ||
"""Finish the current run.""" | ||
import wandb | ||
|
||
wandb.finish() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters