Skip to content

Commit 1f98d7b

Browse files
committed
Minor fix
1 parent 94463b9 commit 1f98d7b

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

configs/generate_confs.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ def get_name(p):
5454
return p["model_name"].split("/")[-1]
5555

5656

57-
def main(models, rounds, simulations, output):
57+
def main(models, rounds, simulations, output: Path):
5858
# Get all unique pairs of models
5959
models = yaml.safe_load(open(models))
60-
Path(output).mkdir(parents=True, exist_ok=True)
60+
output.mkdir(parents=True, exist_ok=True)
6161
pairs = []
6262
for i in range(len(models)):
6363
for j in range(i + 1, len(models)):
@@ -92,18 +92,29 @@ def main(models, rounds, simulations, output):
9292
"prompts": {"game_description": prompt_game_desc(arena, rounds)},
9393
}
9494
config_name = f"{arena.name}__{get_name(pair[0])}__{get_name(pair[1])}__r{rounds}__s{simulations}.yaml"
95-
with open(f"{output}/{config_name}", "w") as f:
95+
with open(output / config_name, "w") as f:
9696
yaml.dump(config, f, default_style=None, sort_keys=False)
9797

98+
# Post-process to remove quotes around include paths
99+
with open(output / config_name) as f:
100+
content = f.read()
101+
102+
# Remove quotes around include paths
103+
content = content.replace("!include 'mini/", "!include mini/")
104+
content = content.replace(".yaml'", ".yaml")
105+
106+
with open(output / config_name, "w") as f:
107+
f.write(content)
108+
98109
tracking_csv.append(
99110
f"{config_name},{arena.name},{get_name(pair[0])},{get_name(pair[1])},{rounds},{simulations},"
100111
+ ",".join([""] * NUM_TOURNAMENTS)
101112
+ "\n"
102113
)
103114

104-
with open(f"{output}/tracking.csv", "w") as f:
115+
with open(output / "tracking.csv", "w") as f:
105116
f.writelines(tracking_csv)
106-
print(f"Wrote tracking file to '{output}/tracking.csv'.")
117+
print(f"Wrote tracking file to '{output / 'tracking.csv'}'.")
107118

108119
print(f"Generated {len(pairs) * len(ARENAS)} configuration files in '{output}'.")
109120
print(f"- # Models: {len(models)}")
@@ -115,7 +126,7 @@ def main(models, rounds, simulations, output):
115126
print("\n(Assuming each tournament is run once)")
116127
print(f"- Total rounds played across all models: {total_rounds}")
117128
rounds_per_model = total_rounds // len(models)
118-
print(f"- Each model: {rounds_per_model}.")
129+
print(f"- Each model: {rounds_per_model}")
119130

120131

121132
if __name__ == "__main__":
@@ -144,8 +155,8 @@ def main(models, rounds, simulations, output):
144155
parser.add_argument(
145156
"-o",
146157
"--output",
147-
type=str,
148-
default="configs/main/",
158+
type=Path,
159+
default=Path("configs/main/"),
149160
help="Output directory for configuration files (default: main/).",
150161
)
151162
args = parser.parse_args()

0 commit comments

Comments
 (0)