Skip to content

Commit 5dbbbd8

Browse files
committed
replace usage of open_dict
1 parent 5cc98b8 commit 5dbbbd8

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

mmf/utils/logger.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@
77
import os
88
import sys
99
import time
10+
from copy import deepcopy
1011
from functools import wraps
1112
from typing import Any, Callable, Dict, Optional, Union
1213

13-
import omegaconf
1414
import torch
1515
from mmf.common.registry import registry
1616
from mmf.utils.configuration import get_mmf_env
1717
from mmf.utils.distributed import get_rank, is_main, is_xla
1818
from mmf.utils.file_io import PathManager
1919
from mmf.utils.timer import Timer
20-
from omegaconf import OmegaConf
2120
from termcolor import colored
2221

2322

@@ -228,7 +227,7 @@ def summarize_report(
228227
return
229228

230229
# Log the learning rate if available
231-
if wandb_logger and "lr" in extra.keys():
230+
if wandb_logger and "lr" in extra:
232231
wandb_logger.log_metrics(
233232
{"train/learning_rate": float(extra["lr"])}, commit=False
234233
)
@@ -426,17 +425,12 @@ def __init__(
426425
)
427426

428427
self._wandb = wandb
429-
430-
self._wandb_init = dict(entity=entity, config=config, project=project)
431-
432-
wandb_params = config.training.wandb
433-
with omegaconf.open_dict(wandb_params):
434-
wandb_params.pop("enabled")
435-
wandb_params.pop("entity")
436-
wandb_params.pop("project")
437-
438-
init_kwargs = OmegaConf.to_container(wandb_params, resolve=True)
439-
self._wandb_init.update(**init_kwargs)
428+
self._wandb_init = dict(entity=entity, project=project)
429+
wandb_kwargs = deepcopy(config.training.wandb)
430+
wandb_kwargs.pop("enabled")
431+
wandb_kwargs.pop("entity")
432+
wandb_kwargs.pop("project")
433+
self._wandb_init.update(**wandb_kwargs)
440434

441435
self.setup()
442436

website/docs/notes/logging.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ env:
4848
4949
* To enable wandb logger the user needs to change the following option in the config.
5050
51-
`training.wandb.enabled=True`
51+
`training.wandb.enabled=True`
5252

5353
* To give the `entity` which is the name of the team or the username, the user needs to change the following option in the config. In case no `entity` is provided, the data will be logged to the `entity` set as default in the user's settings.
5454

55-
`training.wandb.entity=<teamname/username>`
55+
`training.wandb.entity=<teamname/username>`
5656

5757
* To give the current experiment a project and run name, user should add these config options. The default project name is `mmf` and the default run name is `${training.experiment_name}`.
5858

59-
`training.wandb.project=<ProjectName>` <br>
60-
`training.wandb.name=<RunName>`
59+
`training.wandb.project=<ProjectName>` <br>
60+
`training.wandb.name=<RunName>`
6161

6262
* To change the path to the directory where wandb metadata would be stored (Default: `env.log_dir`):
6363

64-
`env.wandb_logdir=<dir_name>`
64+
`env.wandb_logdir=<dir_name>`
6565

6666
* To provide extra arguments to `wandb.init()`, the user just needs to define them in the config file. Check out the documentation at https://docs.wandb.ai/ref/python/init to see what arguments are available. An example is shown in the config parameter shown above. Make sure to use the same key name in the config file as defined in the documentation.
6767

0 commit comments

Comments
 (0)