Skip to content

Commit faa1051

Browse files
committed
Fixes #24; Add branch_name
1 parent 530359a commit faa1051

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

codeclash/agents/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ def get_agent(config: dict, game: CodeGame) -> Player:
1111
}.get(config["agent"])
1212
if agents is None:
1313
raise ValueError(f"Unknown agent type: {config['agent']}")
14-
environment = game.get_environment(f"{game.game_id}_{config['name']}")
14+
environment = game.get_environment(
15+
f"{game.game_id}.{config['name']}"
16+
) # NOTE: MUST be branch_name (defined in agents/abstract.py)
1517
template_vars = {
1618
"game_name": game.name,
1719
"game_id": game.game_id,

codeclash/agents/abstract.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(
1919
template_vars: dict,
2020
):
2121
self.config = config
22-
self.name = f"{template_vars['game_id']}_{config['name']}"
22+
self.name = config["name"]
2323
self.environment = environment
2424
self.template_vars = template_vars
2525
self.logger = get_logger(
@@ -28,6 +28,11 @@ def __init__(
2828
emoji="👤",
2929
)
3030

31+
@property
32+
def branch_name(self):
33+
"""Get the branch name for the agent's codebase."""
34+
return f"{self.template_vars['game_id']}.{self.name}"
35+
3136
def commit(self):
3237
"""Commit changes to the agent's codebase."""
3338
rounds = self.template_vars["rounds"]
@@ -54,11 +59,11 @@ def push(self):
5459
for cmd in [
5560
"git remote remove origin",
5661
f"git remote add origin https://x-access-token:{token}@github.com/{GH_ORG}/{self.template_vars['game_name']}.git",
57-
f"git push origin {self.name}",
62+
f"git push origin {self.branch_name}",
5863
]:
5964
assert_zero_exit_code(self.environment.execute(cmd), logger=self.logger)
6065
self.logger.info(
61-
f"Pushed {self.name} commit history to remote repository (branch {self.name})"
66+
f"Pushed {self.name} commit history to remote repository (branch {self.branch_name})"
6267
)
6368

6469
@abstractmethod

codeclash/agents/minisweagent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ def run(self):
9393
result = exc_message
9494
print(exc_message)
9595
finally:
96-
player_id = self.name.split("_")[-1]
9796
save_traj(
9897
self.agent, # type: ignore
9998
DIR_LOGS
100-
/ f"{self.template_vars['game_id']}/{player_id}_r{self.template_vars['round']}.traj.json",
99+
/ f"{self.template_vars['game_id']}/{self.name}_r{self.template_vars['round']}.traj.json",
101100
exit_status=exit_status,
102101
result=result,
103102
)

codeclash/games/abstract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, config: dict):
2626
self.config: dict = config["game"]
2727
self.rounds: int = self.config.get("rounds", 1)
2828
self.round: int = 0
29-
self.game_id: str = f"{self.name}{time.strftime('%y%m%d%H%M')}"
29+
self.game_id: str = f"{self.name}{time.strftime('%y%m%d%H%M%S')}"
3030
self.log_path: Path = (DIR_WORK / DIR_LOGS / self.game_id).resolve()
3131
self.logger = get_logger(
3232
self.name, log_path=DIR_LOGS / self.game_id / "game.log", emoji="🏓"

0 commit comments

Comments
 (0)