feat: better args parsing

This commit is contained in:
2026-03-15 20:03:01 -03:00
parent 4c8cbc821d
commit 6a154429e9
3 changed files with 13 additions and 6 deletions

View File

@@ -3,4 +3,6 @@ from diceplayer.state.state_model import StateModel
class DiceHandler: class DiceHandler:
@staticmethod @staticmethod
def run(state: StateModel, current_cycle: int) -> StateModel: ... def run(state: StateModel, current_cycle: int) -> StateModel:
print(f"Running Dice - {current_cycle}")
return state

View File

@@ -4,7 +4,9 @@ from diceplayer.state.state_model import StateModel
class OptimizationHandler: class OptimizationHandler:
@staticmethod @staticmethod
def run(state: StateModel, current_cycle: int) -> StateModel: ... def run(state: StateModel, current_cycle: int) -> StateModel:
print(f"Running Optimization - {current_cycle}")
return state
@staticmethod @staticmethod
def _fetch_current_routine(state: StateModel, current_cycle: int) -> RoutineType: def _fetch_current_routine(state: StateModel, current_cycle: int) -> RoutineType:

View File

@@ -19,13 +19,16 @@ class Player:
self._state_handler = StateHandler(config.simulation_dir) self._state_handler = StateHandler(config.simulation_dir)
def play(self, **flags: Unpack[PlayerFlags]): def play(self, **flags: Unpack[PlayerFlags]):
if not flags["continuation"]: continuation = flags.get("continuation", False)
force = flags.get("force", False)
state: StateModel = self._state_handler.get(self.config, force=force)
if not continuation and state is not None:
logger.info( logger.info(
"Continuation flag is not set. Starting a new simulation and deleting any existing state." "Continuation flag is not set. Starting a new simulation and deleting any existing state."
) )
self._state_handler.delete() self._state_handler.delete()
state = self._state_handler.get(self.config, force=force)
state = self._state_handler.get(self.config, force=flags["force"])
if state is None: if state is None:
state = StateModel.from_config(self.config) state = StateModel.from_config(self.config)
@@ -37,7 +40,7 @@ class Player:
f"Starting cycle {state.current_cycle + 1} of {self.config.max_cyc}." f"Starting cycle {state.current_cycle + 1} of {self.config.max_cyc}."
) )
step_directory = self.config.simulation_dir / f"{state.current_cycle::02d}" step_directory = self.config.simulation_dir / f"{state.current_cycle:02d}"
if not step_directory.exists(): if not step_directory.exists():
step_directory.mkdir(parents=True) step_directory.mkdir(parents=True)