Implements Additional Logs and class Player Tests
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
from diceplayer.shared.config.dice_dto import DiceDTO
|
||||
from diceplayer.shared.config.step_dto import StepDTO
|
||||
from diceplayer.shared.interface import Interface
|
||||
from diceplayer import logger
|
||||
|
||||
from multiprocessing import Process, connection
|
||||
from setproctitle import setproctitle
|
||||
@@ -15,7 +16,6 @@ import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
DICE_END_FLAG: Final[str] = "End of simulation"
|
||||
DICE_FLAG_LINE: Final[int] = -2
|
||||
UMAANG3_TO_GCM3: Final[float] = 1.6605
|
||||
@@ -41,8 +41,9 @@ class DiceInterface(Interface):
|
||||
procs = []
|
||||
sentinels = []
|
||||
|
||||
for proc in range(1, self.step.nprocs + 1):
|
||||
logger.info(f"---------------------- DICE - CYCLE {cycle} --------------------------\n")
|
||||
|
||||
for proc in range(1, self.step.nprocs + 1):
|
||||
p = Process(target=self._simulation_process, args=(cycle, proc))
|
||||
p.start()
|
||||
|
||||
@@ -61,6 +62,8 @@ class DiceInterface(Interface):
|
||||
p.terminate()
|
||||
sys.exit(status)
|
||||
|
||||
logger.info("\n")
|
||||
|
||||
def reset(self):
|
||||
del self.step
|
||||
|
||||
@@ -132,6 +135,11 @@ class DiceInterface(Interface):
|
||||
f"step{cycle:02d}",
|
||||
f"p{proc:02d}"
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"Simulation process {str(proc_dir)} initiated with pid {os.getpid()}"
|
||||
)
|
||||
|
||||
os.chdir(proc_dir)
|
||||
|
||||
if not (self.config.randominit == 'first' and cycle > 1):
|
||||
@@ -385,3 +393,5 @@ class DiceInterface(Interface):
|
||||
flag = outfile.readlines()[DICE_FLAG_LINE].strip()
|
||||
if flag != DICE_END_FLAG:
|
||||
raise RuntimeError(f"Dice process step{cycle:02d}-p{proc:02d} did not exit properly")
|
||||
|
||||
logger.info(f"Dice {file_name} - step{cycle:02d}-p{proc:02d} exited properly")
|
||||
|
||||
@@ -14,7 +14,7 @@ class GaussianInterface(Interface):
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def start(self):
|
||||
def start(self, cycle: int):
|
||||
pass
|
||||
|
||||
def reset(self):
|
||||
|
||||
Reference in New Issue
Block a user