Skip to content

Commit

Permalink
Feature: add wandb dir as parser argument (#308)
Browse files Browse the repository at this point in the history
* feat: add wandb_dir as cfg argument

* refactor: match functional dir style for wandb dir
  • Loading branch information
fabioseel authored Nov 18, 2024
1 parent 6810db5 commit 46402c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions sample_factory/cfg/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,12 @@ def add_wandb_args(p: ArgumentParser):
nargs="*",
help="Tags can help with finding experiments in WandB web console",
)
p.add_argument(
"--wandb_dir",
default=join(os.getcwd(), "wandb"),
type=str,
help="Logging Directory for WandB",
)


def add_pbt_args(p: ArgumentParser):
Expand Down
4 changes: 4 additions & 0 deletions sample_factory/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def experiments_dir(cfg, mkdir=True) -> str:
return maybe_ensure_dir_exists(cfg.train_dir, mkdir)


def wandb_dir(cfg, mkdir=True) -> str:
return maybe_ensure_dir_exists(cfg.wandb_dir, mkdir)


def experiment_dir(cfg, mkdir=True) -> str:
experiment = cfg.experiment
experiments_root = experiments_dir(cfg, mkdir)
Expand Down
3 changes: 2 additions & 1 deletion sample_factory/utils/wandb_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

from sample_factory.utils.utils import log, retry
from sample_factory.utils.utils import log, retry, wandb_dir


def init_wandb(cfg):
Expand Down Expand Up @@ -44,6 +44,7 @@ def init_wandb_func():
tags=cfg.wandb_tags,
resume="allow",
settings=wandb.Settings(start_method="fork"),
dir=wandb_dir(cfg, True),
)

log.debug("Initializing WandB...")
Expand Down

0 comments on commit 46402c3

Please sign in to comment.