Skip to content

Commit f1a6ccf

Browse files
committed
Add init dir logs (yaml dump of options and args)
1 parent c073f19 commit f1a6ccf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

train.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,17 @@ def main():
145145
if os.path.isdir(options['logs']['dir_logs']):
146146
if click.confirm('Logs directory already exists in {}. Erase?'
147147
.format(options['logs']['dir_logs'], default=False)):
148-
os.system('rm -r '+options['logs']['dir_logs'])
148+
os.system('rm -r ' + options['logs']['dir_logs'])
149149
else:
150150
return
151-
os.system('mkdir -p '+options['logs']['dir_logs'])
152-
os.system('cp {} {}'.format(args.path_opt, options['logs']['dir_logs']))
151+
os.system('mkdir -p ' + options['logs']['dir_logs'])
152+
path_new_opt = os.path.join(options['logs']['dir_logs'],
153+
os.path.basename(args.path_opt))
154+
path_args = os.path.join(options['logs']['dir_logs'], 'args.yaml')
155+
with open(path_new_opt, 'w') as f:
156+
yaml.dump(options, f, default_flow_style=False)
157+
with open(path_args, 'w') as f:
158+
yaml.dump(vars(args), f, default_flow_style=False)
153159

154160
if exp_logger is None:
155161
# Set loggers

0 commit comments

Comments
 (0)