create dir for log file name (#867)

This commit is contained in:
Chi Wang 2022-12-30 10:21:30 -08:00 committed by GitHub
parent b78d0b57c4
commit 90aea9c28b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -448,6 +448,7 @@ def run(
logger.addHandler(old_handlers[0])
if verbose > 0:
if log_file_name:
os.makedirs(os.path.dirname(log_file_name), exist_ok=True)
logger.addHandler(logging.FileHandler(log_file_name))
elif not logger.hasHandlers():
# Add the console handler.

View File

@ -46,8 +46,7 @@ def test_nested_run():
metric="loss",
mode="min",
num_samples=5,
local_dir="logs",
log_file_name="logs/nested.log",
log_file_name="logs/create/nested.log",
verbose=3,
)
print(analysis.best_result)