From 1d8ad0968cef1a19c7642e71e549c882fd0c7185 Mon Sep 17 00:00:00 2001 From: Eren Golge Date: Fri, 11 May 2018 03:49:55 -0700 Subject: [PATCH] Allow debug runand don force git hash --- train.py | 4 +++- utils/generic_utils.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/train.py b/train.py index e554f424..d7c6b653 100644 --- a/train.py +++ b/train.py @@ -36,13 +36,15 @@ parser.add_argument('--restore_path', type=str, help='Folder path to checkpoints', default=0) parser.add_argument('--config_path', type=str, help='path to config file for training',) +parser.add_argument('--debug', type=bool, default=False, + help='do not ask for git has before run.') args = parser.parse_args() # setup output paths and read configs c = load_config(args.config_path) _ = os.path.dirname(os.path.realpath(__file__)) OUT_PATH = os.path.join(_, c.output_path) -OUT_PATH = create_experiment_folder(OUT_PATH, c.model_name) +OUT_PATH = create_experiment_folder(OUT_PATH, c.model_name, args.debug) CHECKPOINT_PATH = os.path.join(OUT_PATH, 'checkpoints') shutil.copyfile(args.config_path, os.path.join(OUT_PATH, 'config.json')) diff --git a/utils/generic_utils.py b/utils/generic_utils.py index 1cc547ab..7feb806d 100644 --- a/utils/generic_utils.py +++ b/utils/generic_utils.py @@ -34,10 +34,13 @@ def get_commit_hash(): return commit -def create_experiment_folder(root_path, model_name): +def create_experiment_folder(root_path, model_name, debug): """ Create a folder with the current date and time """ date_str = datetime.datetime.now().strftime("%B-%d-%Y_%I:%M%p") - commit_hash = get_commit_hash() + if debug: + commit_hash = 'debug' + else: + commit_hash = get_commit_hash() output_folder = os.path.join(root_path, date_str + '-' + model_name + '-' + commit_hash) os.makedirs(output_folder, exist_ok=True) print(" > Experiment folder: {}".format(output_folder))