Last active
March 31, 2020 00:07
-
-
Save raeidsaqur/89355713cf685c3c4baa1400a8ac4eea to your computer and use it in GitHub Desktop.
WandB Run Identifier (naive, untested example) to exemplify the idea
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import time, logging, platform | |
import wandb | |
def wandb_init(opt, *args, **kwargs): | |
"""A quick naive example """ | |
wandb_identifier = get_run_identifier(opt, *args, **kwargs) | |
wandb.init(project="aProj", name=wandb_identifier, notes="<Intriguing notes>") | |
wandb.config.update(opt) | |
model = kwargs.get('model') | |
if model: | |
wandb.watch(model) | |
# Init a Table of Stats|Results | |
stats = kwargs.get('stats') | |
if stats: | |
stats_table = wandb.Table(columns=list(stats.keys())) | |
def get_run_identifier(opt, *args, **kwargs) -> str: | |
""" | |
A unique run identifier for runs and corresponding checkpoints with the same time-stamp | |
Usage: @see wandb_init | |
Use as (prefix|suffix) E.g. f"{project_name}|{identifier}" | |
:param args: Run arguments | |
:return: A identifier string for a run set | |
""" | |
ts = time.strftime('%Y%m%d-%H%M%S') | |
template = kwargs.get('template', 'default_template') | |
if opt.is_train: | |
train_phase = "reinforce" if opt.is_finetune else "pretrain" | |
identifier = f"[ {template} ]-reason.run_train-{train_phase}-{opt.num_iters}num_iters.{opt.max_train_samples}tr_samples" \ | |
f".{opt.max_val_samples}val_samples.{opt.batch_size}bsz-{platform.node()}-{ts}" | |
else: | |
guess = "-GUESS" if opt.exec_guess_ans else "" | |
identifier = f"[ {template} ]-reason.run_test{guess}-[{opt.load_checkpoint_path}]" \ | |
f".{opt.batch_size}bsz-{platform.node()}-{ts}" | |
logging.debug("-" * 100) | |
logging.debug(f"Run identifier: {identifier}") | |
logging.debug("-" * 100) | |
return identifier |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment