support case where no previous tests have been found
This commit is contained in:
parent
be4facfd40
commit
064e4dae2d
2 changed files with 10 additions and 4 deletions
|
|
@ -29,6 +29,8 @@ def run():
|
||||||
|
|
||||||
session_id = "test-" + get_datetime_string()
|
session_id = "test-" + get_datetime_string()
|
||||||
if args.resume:
|
if args.resume:
|
||||||
|
latest_session_id = DirManager.get_latest_session_id(args.output_dir)
|
||||||
|
if latest_session_id:
|
||||||
session_id = DirManager.get_latest_session_id(args.output_dir)
|
session_id = DirManager.get_latest_session_id(args.output_dir)
|
||||||
|
|
||||||
# ------------------------------- setup logging ------------------------------ #
|
# ------------------------------- setup logging ------------------------------ #
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from dotenv import dotenv_values
|
from dotenv import dotenv_values
|
||||||
|
|
||||||
|
|
@ -78,8 +79,11 @@ class DirManager:
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_latest_session_id(output_dir: Path) -> str:
|
def get_latest_session_id(output_dir: Path) -> Optional[str]:
|
||||||
"""returns the name of the newest dir inside of output_dir"""
|
"""returns the name of the newest dir inside of output_dir"""
|
||||||
all_dirs = [d for d in output_dir.iterdir() if d.is_dir()]
|
all_dirs = [d for d in output_dir.iterdir() if d.is_dir()]
|
||||||
|
if all_dirs:
|
||||||
newest_dir: Path = max(all_dirs, key=lambda x: x.stat().st_ctime)
|
newest_dir: Path = max(all_dirs, key=lambda x: x.stat().st_ctime)
|
||||||
return newest_dir.name
|
return newest_dir.name
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue