Skip to content

Commit a4d47af

Browse files
committed
small cleanups
1 parent d06836e commit a4d47af

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

baselines/agents.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
import os
13
from abc import ABC, abstractmethod
24
from pathlib import Path
35

@@ -7,14 +9,18 @@
79

810

911
class Agents(ABC):
12+
def __init__(self, max_iteration: int):
13+
self.max_iteration = max_iteration
14+
1015
@abstractmethod
1116
def run(self) -> None:
1217
"""Start agent"""
1318
raise NotImplementedError
1419

1520

1621
class AiderAgents(Agents):
17-
def __init__(self, model_name: str):
22+
def __init__(self, max_iteration: int, model_name: str):
23+
super().__init__(max_iteration)
1824
self.model = Model(model_name)
1925

2026
def run(
@@ -37,6 +43,10 @@ def run(
3743
log_dir.mkdir(parents=True, exist_ok=True)
3844
input_history_file = log_dir / ".aider.input.history"
3945
chat_history_file = log_dir / ".aider.chat.history.md"
46+
print(
47+
f"check {os.path.abspath(chat_history_file)} for prompts and lm generations",
48+
file=sys.stderr,
49+
)
4050
io = InputOutput(
4151
yes=True,
4252
input_history_file=input_history_file,
@@ -51,4 +61,6 @@ def run(
5161
test_cmd=test_cmd,
5262
io=io,
5363
)
64+
coder.max_reflection = self.max_iteration
65+
coder.stream = False
5466
coder.run(message)

baselines/class_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ class AgentConfig:
2626
max_lint_info_length: int
2727
pre_commit_config_path: str
2828
run_tests: bool
29+
max_iteration: int

baselines/configs/base.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ agent_config:
2525
max_unit_tests_info_length: 10000
2626
max_reference_info_length: 10000
2727
max_lint_info_length: 10000
28+
max_iteration: 3
2829

2930
hydra:
3031
run:

baselines/run_agent.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import hydra
34
from datasets import load_dataset
45
import traceback
@@ -57,7 +58,7 @@ def run_agent_for_repo(
5758
target_edit_files = get_target_edit_files(repo_path)
5859

5960
if agent_config.agent_name == "aider":
60-
agent = AiderAgents(agent_config.model_name)
61+
agent = AiderAgents(agent_config.max_iteration, agent_config.model_name)
6162
else:
6263
raise NotImplementedError(
6364
f"{agent_config.agent_name} is not implemented; please add your implementations in baselines/agents.py."
@@ -127,6 +128,9 @@ def main() -> None:
127128
]
128129
assert len(filtered_dataset) > 0, "No examples available"
129130

131+
if len(filtered_dataset) > 1:
132+
sys.stdout = open(os.devnull, "w")
133+
130134
with tqdm(
131135
total=len(filtered_dataset), smoothing=0, desc="Running Aider for repos"
132136
) as pbar:

0 commit comments

Comments
 (0)