From 3f45fb851bace1d5bb56cd4df06ba0f4c5c47b9b Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 3 May 2021 20:33:28 +0200 Subject: Add directory prefixes to experiments --- src/experiment.py | 9 +++++---- src/run.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/experiment.py b/src/experiment.py index f8a219a..85bc4a1 100644 --- a/src/experiment.py +++ b/src/experiment.py @@ -9,8 +9,8 @@ import torch from runner import Runner class Experiment: - def __init__(self, file): - self.make_dir() + def __init__(self, file, prefix): + self.make_dir(prefix) self.copy_config(file) self.metrics = ExperimentMetrics() self.runner = Runner(file, self.metrics) @@ -41,9 +41,10 @@ class Experiment: def dir_path(self, file): return '{}/{}'.format(self.dirname, file) - def make_dir(self): + def make_dir(self, prefix): time_string = time.strftime('%Y%m%d%H%M%S') - dirname = 'outputs/{}'.format(time_string) + prefix = '' if prefix == '' else '{}-'.format(prefix) + dirname = 'outputs/{}{}'.format(prefix, time_string) self.dirname = dirname os.mkdir(dirname) diff --git a/src/run.py b/src/run.py index db25e60..28324d8 100644 --- a/src/run.py +++ b/src/run.py @@ -8,7 +8,8 @@ if len(sys.argv) < 2: exit(1) file = sys.argv[1] +prefix = sys.argv[2] if len(sys.argv) > 2 else '' -experiment = Experiment(file) +experiment = Experiment(file, prefix) experiment.run() experiment.save_results() -- cgit v1.2.3