Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
[minor][wandb] Save task arguments as separate config values (#4484)
Browse files Browse the repository at this point in the history
* [minor][wandb] Save task arguments as separate config values

Convenience so that we can do UI filters in wandb on values for task arguments.

```
>>> from parlai.core.logs import WandbLogger
>>> opt= {"wandb_name": "test_3", "wandb_project": "blah_2", "model_file": "dummy_mf", "task": "blah:x=y:a=2"}
>>> dummy = WandbLogger(opt)
>>> dummy.run.config
{'wandb_name': 'test_3', 'wandb_project': 'blah_2', 'model_file': 'dummy_mf', 'task': 'blah:x=y:a=2', 'x': 'y', 'a': '2'}

* Update from running in practice

* update again from running in practice lol (but it works now and flows end-to-end to my fairwandb)
  • Loading branch information
moyapchen committed Apr 5, 2022
1 parent 5f3fea7 commit f91bd80
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion parlai/core/logs.py
Expand Up @@ -181,14 +181,25 @@ def __init__(self, opt: Opt, model=None):
entity=opt.get('wandb_entity'),
reinit=True, # in case of preemption
resume=True, # requeued runs should be treated as single run
allow_val_change=True,
)
# suppress wandb's output
logging.getLogger("wandb").setLevel(logging.ERROR)

def set_config_value(self, key, value):
if self.run.config.get(key, None) != None:
setattr(self.run.config, k, v)

if not self.run.resumed:
for key, value in opt.items():
if value is None or isinstance(value, (str, numbers.Number, tuple)):
setattr(self.run.config, key, value)
set_config_value(self, key, value)
if key == "task": # For ags specified in the task argument
maybe_task_opts = value.split(":")
for task_opt in maybe_task_opts:
if len(task_opt.split("=")) == 2:
k, v = task_opt.split("=")
set_config_value(self, k, v)
if model is not None:
self.run.watch(model)

Expand Down

0 comments on commit f91bd80

Please sign in to comment.