|
| 1 | +import getpass |
1 | 2 | import os |
2 | 3 | import subprocess |
3 | 4 | import time |
@@ -30,9 +31,10 @@ def __init__(self, config: dict): |
30 | 31 | self.rounds: int = self.config.get("rounds", 1) |
31 | 32 | self.round: int = 0 |
32 | 33 | self.game_id: str = f"{self.name}{time.strftime('%y%m%d%H%M%S')}" |
33 | | - self.log_path: Path = (DIR_WORK / DIR_LOGS / self.game_id).resolve() |
| 34 | + self.log_env: Path = (DIR_WORK / DIR_LOGS / self.game_id).resolve() |
| 35 | + self.log_local: Path = (DIR_LOGS / getpass.getuser() / self.game_id).resolve() |
34 | 36 | self.logger = get_logger( |
35 | | - self.name, log_path=DIR_LOGS / self.game_id / "game.log", emoji="🏓" |
| 37 | + self.name, log_path=self.log_local / "game.log", emoji="🏓" |
36 | 38 | ) |
37 | 39 | self.environment: DockerEnvironment = self.get_environment() |
38 | 40 | assert len(config["players"]) >= 2, "At least two players are required" |
@@ -120,7 +122,8 @@ def _pre_round_setup(self, agents: list[Player]): |
120 | 122 |
|
121 | 123 | # Ensure the log path + file exists |
122 | 124 | assert_zero_exit_code( |
123 | | - self.environment.execute(f"mkdir -p {self.log_path}"), logger=self.logger |
| 125 | + self.environment.execute(f"mkdir -p {self.log_env}"), |
| 126 | + logger=self.logger, |
124 | 127 | ) |
125 | 128 | assert_zero_exit_code( |
126 | 129 | self.environment.execute(f"touch {self.round_log_path}"), logger=self.logger |
@@ -156,7 +159,7 @@ def _post_round_setup(self, agents: list[Player]): |
156 | 159 | copy_file_from_container( |
157 | 160 | self.environment, |
158 | 161 | self.round_log_path, |
159 | | - DIR_LOGS / f"{self.game_id}/round_{self.round}.log", |
| 162 | + self.log_local / self.round_log_path.name, |
160 | 163 | ) |
161 | 164 | except Exception: |
162 | 165 | self.logger.error( |
@@ -186,4 +189,4 @@ def round_log_path(self) -> Path: |
186 | 189 | """ |
187 | 190 | Get the path to the current round's log file. |
188 | 191 | """ |
189 | | - return self.log_path / f"round_{self.round}.log" |
| 192 | + return self.log_env / f"round_{self.round}.log" |
0 commit comments