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

[refactor] Extend WandbLogger to log config variables, entity and kwargs #1

Merged
merged 6 commits into from
Oct 20, 2021
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
8 changes: 8 additions & 0 deletions mmf/configs/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ training:
wandb:
# Whether to use Weights and Biases Logger, (Default: false)
enabled: false
# An entity is a username or team name where you're sending runs.
# This is necessary if you want to log your metrics to a team account. By default
# it will log the run to your user account.
entity: null
# Project name to be used while logging the experiment with wandb
wandb_projectname: mmf_${oc.env:USER,}
# Experiment/ run name to be used while logging the experiment
# under the project with wandb
wandb_runname: ${training.experiment_name}
# Specify other argument values to be used while logging the experiment
init_kwargs:
job_type: train


# Size of the batch globally. If distributed or data_parallel
# is used, this will be divided equally among GPUs
Expand Down
10 changes: 7 additions & 3 deletions mmf/trainers/callbacks/logistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ def __init__(self, config, trainer):
if env_wandb_logdir:
log_dir = env_wandb_logdir

wandb_projectname = config.training.wandb.wandb_projectname
wandb_runname = config.training.wandb.wandb_runname
wandb_init_kwargs = config.training.wandb.init_kwargs

self.wandb_logger = WandbLogger(
name=wandb_runname, save_dir=log_dir, project=wandb_projectname
entity=config.training.wandb.entity,
project=config.training.wandb.wandb_projectname,
config=config,
name=config.training.wandb.wandb_runname,
save_dir=log_dir,
**wandb_init_kwargs,
)

def on_train_start(self):
Expand Down
8 changes: 7 additions & 1 deletion mmf/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,11 @@ class WandbLogger:
Log using `Weights and Biases`.

Args:
entity: An entity is a username or team name where you're sending runs.
name: Display name for the run.
save_dir: Path where data is saved (./save/logs/wandb/ by default).
project: Display name for the project.
config: Configuration for the run.
**init_kwargs: Arguments passed to :func:`wandb.init`.

Raises:
Expand All @@ -406,9 +408,11 @@ class WandbLogger:

def __init__(
self,
entity: Optional[str] = None,
name: Optional[str] = None,
save_dir: Optional[str] = None,
project: Optional[str] = None,
config: Optional[Dict] = None,
**init_kwargs,
):
try:
Expand All @@ -421,7 +425,9 @@ def __init__(

self._wandb = wandb

self._wandb_init = dict(name=name, project=project, dir=save_dir)
self._wandb_init = dict(
entity=entity, name=name, project=project, dir=save_dir, config=config
)

self._wandb_init.update(**init_kwargs)

Expand Down