Fix sim output
This commit is contained in:
@@ -1,14 +1,26 @@
|
||||
"""Warning: SIM_OUTPUT is a mutable global variable for the simulation output directory."""
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from primaite import _PRIMAITE_ROOT
|
||||
|
||||
SIM_OUTPUT = None
|
||||
"A path at the repo root dir to use temporarily for sim output testing while in dev."
|
||||
# TODO: Remove once we integrate the simulation into PrimAITE and it uses the primaite session path
|
||||
__all__ = ["SIM_OUTPUT"]
|
||||
|
||||
if not SIM_OUTPUT:
|
||||
session_timestamp = datetime.now()
|
||||
date_dir = session_timestamp.strftime("%Y-%m-%d")
|
||||
sim_path = session_timestamp.strftime("%Y-%m-%d_%H-%M-%S")
|
||||
SIM_OUTPUT = _PRIMAITE_ROOT.parent.parent / "simulation_output" / date_dir / sim_path
|
||||
SIM_OUTPUT.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
class __SimOutput:
|
||||
def __init__(self):
|
||||
self._path: Path = (
|
||||
_PRIMAITE_ROOT.parent.parent / "simulation_output" / datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
)
|
||||
|
||||
@property
|
||||
def path(self) -> Path:
|
||||
return self._path
|
||||
|
||||
@path.setter
|
||||
def path(self, new_path: Path) -> None:
|
||||
self._path = new_path
|
||||
self._path.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
|
||||
SIM_OUTPUT = __SimOutput()
|
||||
|
||||
Reference in New Issue
Block a user