Skip to content

Commit c004bf2

Browse files
committed
Merge branch 'main' of github.com:emagedoc/CodeClash
2 parents 3f5c024 + 83640d4 commit c004bf2

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
BUILD_SCRIPT="$THIS_DIR/build_and_push_aws.sh"
7+
GAMES_DOCKER_DIR="$THIS_DIR/../../docker"
8+
9+
# AWSCodeClash -> codeclash
10+
"$BUILD_SCRIPT" AWSCodeClash.Dockerfile codeclash "$THIS_DIR"
11+
12+
# Games -> codeclash/<game>
13+
"$BUILD_SCRIPT" "$GAMES_DOCKER_DIR/BattleSnake.Dockerfile" codeclash/battlesnake "$GAMES_DOCKER_DIR"
14+
"$BUILD_SCRIPT" "$GAMES_DOCKER_DIR/BattleCode.Dockerfile" codeclash/battlecode "$GAMES_DOCKER_DIR"
15+
"$BUILD_SCRIPT" "$GAMES_DOCKER_DIR/CoreWar.Dockerfile" codeclash/corewar "$GAMES_DOCKER_DIR"
16+
"$BUILD_SCRIPT" "$GAMES_DOCKER_DIR/DummyGame.Dockerfile" codeclash/dummygame "$GAMES_DOCKER_DIR"
17+
"$BUILD_SCRIPT" "$GAMES_DOCKER_DIR/HuskyBench.Dockerfile" codeclash/huskybench "$GAMES_DOCKER_DIR"
18+
"$BUILD_SCRIPT" "$GAMES_DOCKER_DIR/RoboCode.Dockerfile" codeclash/robocode "$GAMES_DOCKER_DIR"
19+
"$BUILD_SCRIPT" "$GAMES_DOCKER_DIR/RobotRumble.Dockerfile" codeclash/robotrumble "$GAMES_DOCKER_DIR"

codeclash/analysis/matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from codeclash.games import get_game
1313
from codeclash.tournaments.utils.git_utils import filter_git_diff
1414
from codeclash.utils.atomic_write import atomic_write
15-
from codeclash.utils.log import add_file_handler, get_logger
15+
from codeclash.utils.log import add_root_file_handler, get_logger
1616

1717
# todo: add visualization code
1818
# todo: Should start from initial commit set in metadata rather than last commit
@@ -29,7 +29,7 @@ def __init__(self, pvp_output_dir: Path, n_repetitions: int = 3, max_workers: in
2929

3030
# Set up logging with thread safety
3131
self.logger = get_logger("MatrixEvaluator", log_path=self.pvp_output_dir / "matrix_eval.log", emoji="📊")
32-
add_file_handler(get_logger("."), self.pvp_output_dir / "matrix_eval.log")
32+
add_root_file_handler(self.pvp_output_dir / "matrix_everything.log")
3333

3434
# Thread safety for progress saving
3535
self._save_lock = Lock()

codeclash/tournaments/tournament.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from codeclash.utils.aws import get_aws_metadata
77
from codeclash.utils.environment import create_file_in_container
8-
from codeclash.utils.log import add_file_handler, get_logger
8+
from codeclash.utils.log import add_root_file_handler, get_logger
99

1010

1111
class AbstractTournament:
@@ -22,7 +22,7 @@ def __init__(self, config: dict, *, name: str, output_dir: Path, **kwargs):
2222
"aws": get_aws_metadata(),
2323
}
2424
self.logger = get_logger(self.name, log_path=self.local_output_dir / "tournament.log", emoji="🏆")
25-
add_file_handler(get_logger("."), self.local_output_dir / "everything.log")
25+
add_root_file_handler(self.local_output_dir / "everything.log")
2626

2727
@property
2828
def local_output_dir(self) -> Path:

codeclash/utils/log.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def add_file_handler(logger: logging.Logger, log_path: Path) -> None:
8080
logger.addHandler(file_handler)
8181

8282

83+
def add_root_file_handler(log_path: Path) -> None:
84+
"""Add a file handler to the root logger to capture all log messages."""
85+
add_file_handler(logging.getLogger(), log_path)
86+
87+
8388
def get_logger(name: str, *, emoji: str = "", log_path: Path | None = None) -> logging.Logger:
8489
"""Get logger. Use this instead of `logging.getLogger` to ensure
8590
that the logger is set up with the correct handlers.

0 commit comments

Comments
 (0)