Skip to content

Commit

Permalink
add cli arg to choose experiments dir (jpata#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwulff authored Nov 7, 2023
1 parent 5b516d5 commit d221dfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion mlpf/pyg_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
parser.add_argument("--comet", action="store_true", help="use comet ml logging")
parser.add_argument("--comet-offline", action="store_true", help="save comet logs locally")
parser.add_argument("--comet-step-freq", type=int, default=None, help="step frequency for saving comet metrics")
parser.add_argument("--experiments-dir", type=str, default=None, help="base directory within which trainings are stored")


def run(rank, world_size, config, args, outdir, logfile):
Expand Down Expand Up @@ -447,7 +448,10 @@ def hpo(search_space, config, args, world_size):
)

else:
outdir = create_experiment_dir(prefix=(args.prefix or "") + Path(args.config).stem + "_")
outdir = create_experiment_dir(
prefix=(args.prefix or "") + Path(args.config).stem + "_",
experiments_dir=args.experiments_dir if args.experiments_dir else "experiments",
)
device_agnostic_run(config, args, world_size, outdir)


Expand Down
6 changes: 3 additions & 3 deletions mlpf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from comet_ml import OfflineExperiment, Experiment # isort:skip


def create_experiment_dir(prefix=None, suffix=None):
def create_experiment_dir(prefix=None, suffix=None, experiments_dir="experiments"):
if prefix is None:
train_dir = Path("experiments") / datetime.datetime.now().strftime("%Y%m%d_%H%M%S_%f")
train_dir = Path(experiments_dir) / datetime.datetime.now().strftime("%Y%m%d_%H%M%S_%f")
else:
train_dir = Path("experiments") / (prefix + datetime.datetime.now().strftime("%Y%m%d_%H%M%S_%f"))
train_dir = Path(experiments_dir) / (prefix + datetime.datetime.now().strftime("%Y%m%d_%H%M%S_%f"))

if suffix is not None:
train_dir = train_dir.with_name(train_dir.name + "." + platform.node())
Expand Down

0 comments on commit d221dfb

Please sign in to comment.