run_dir fn

This commit is contained in:
JJJHolscher 2023-12-13 13:52:19 +01:00
parent 22e93da91f
commit 44d6534b5e
2 changed files with 7 additions and 9 deletions

View File

@ -1,7 +1,7 @@
[project]
name = "jo3util"
version = "0.0.10"
version = "0.0.13"
description = ""
dependencies = []
dynamic = ["readme"]

View File

@ -81,12 +81,10 @@ def root_file():
raise NotImplementedError
def run_dir(obj, subdir=Path("run")):
run_id: str = json.dumps(obj, default=lambda x: vars(x))
def run_dir(obj, root=Path(os.path.abspath("./run"))):
run_id: str = json.dumps(
obj,
default=lambda x: vars(x) if hasattr(x, "__dict__") else str(x)
)
run_id: str = hash_string(run_id)
path = root_dir()
if subdir:
path /= subdir
path /= run_id
return path
return root / run_id