Skip to content

Commit d80a044

Browse files
authored
Merge pull request #63 from commit-0/agent
fix modal version
2 parents ecbef53 + acb57c0 commit d80a044

File tree

6 files changed

+59
-76
lines changed

6 files changed

+59
-76
lines changed

agent/agents.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def run(
6262
lint_cmd: str,
6363
fnames: list[str],
6464
log_dir: Path,
65+
test_first: bool = False,
6566
) -> AgentReturn:
6667
"""Start aider agent"""
6768
if test_cmd:
@@ -111,7 +112,14 @@ def run(
111112
coder.stream = True
112113

113114
# Run the agent
114-
coder.run(message)
115+
if test_first:
116+
test_errors = coder.commands.cmd_test(test_cmd)
117+
if test_errors:
118+
coder.run(test_errors)
119+
else:
120+
coder.run(message)
121+
122+
# #### TMP
115123

116124
# #### TMP
117125
# import time

agent/cli.py

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -190,52 +190,28 @@ def run(
190190
5,
191191
help="Display the agent progress",
192192
),
193-
) -> None:
194-
"""Run the agent on the repository."""
195-
run_agent(
196-
branch,
197-
override_previous_changes,
198-
backend,
199-
agent_config_file,
200-
log_dir,
201-
max_parallel_repos,
202-
display_repo_progress_num,
203-
)
204-
205-
206-
@agent_app.command()
207-
def run_test_no_rich(
208-
branch: str = typer.Argument(
209-
...,
210-
help="Branch name of current run",
211-
),
212-
override_previous_changes: bool = typer.Option(
213-
False,
214-
help="If override the previous agent changes on `branch` or run the agent continuously on the new changes",
215-
),
216-
backend: str = typer.Option(
217-
"modal",
218-
help="Test backend to run the agent on, ignore this option if you are not adding `test` option to agent",
219-
),
220-
agent_config_file: str = typer.Option(
221-
".agent.yaml",
222-
help="Path to the agent config file",
223-
),
224-
log_dir: str = typer.Option(
225-
str(RUN_AGENT_LOG_DIR.resolve()),
226-
help="Log directory to store the logs",
227-
),
228-
max_parallel_repos: int = typer.Option(
229-
1,
230-
help="Maximum number of repositories for agent to run in parallel",
193+
show_rich_progress: bool = typer.Option(
194+
True,
195+
help="Display the agent progress with rich",
231196
),
232197
) -> None:
233198
"""Run the agent on the repository."""
234-
run_agent_no_rich(
235-
branch,
236-
override_previous_changes,
237-
backend,
238-
agent_config_file,
239-
log_dir,
240-
max_parallel_repos,
241-
)
199+
if show_rich_progress:
200+
run_agent(
201+
branch,
202+
override_previous_changes,
203+
backend,
204+
agent_config_file,
205+
log_dir,
206+
max_parallel_repos,
207+
display_repo_progress_num,
208+
)
209+
else:
210+
run_agent_no_rich(
211+
branch,
212+
override_previous_changes,
213+
backend,
214+
agent_config_file,
215+
log_dir,
216+
max_parallel_repos,
217+
)

agent/display.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ def __init__(self, total_repos: int):
120120
self.layout["progress"]["pbar"].update(
121121
Panel(self.overall_progress, title="Overall Progress", border_style="blue")
122122
)
123-
self.time_display = Text("Time Taken So Far: 0s", justify="center")
123+
self.time_display = Text("0s", justify="center")
124124
self.layout["progress"]["time"].update(
125-
Panel(self.time_display, title="Time", border_style="blue")
125+
Panel(self.time_display, title="Time Taken", border_style="blue")
126126
)
127-
self.money_display = Text("Money Spent So Far: $0.00", justify="center")
127+
self.money_display = Text("$0.00", justify="center")
128128
self.layout["progress"]["money"].update(
129129
Panel(self.money_display, title="$$$$", border_style="blue")
130130
)
@@ -222,9 +222,9 @@ def update_time_display(self, time_in_seconds: int) -> None:
222222
else:
223223
time_str = f"{seconds:02d}s"
224224
self.total_time_spent = time_in_seconds
225-
self.time_display = Text(f"Time Spent So Far: {time_str}", justify="center")
225+
self.time_display = Text(f"{time_str}", justify="center")
226226
self.layout["progress"]["time"].update(
227-
Panel(self.time_display, title="Time", border_style="blue")
227+
Panel(self.time_display, title="Time Taken", border_style="blue")
228228
)
229229

230230
def update_backend_display(self, backend: str) -> None:
@@ -251,7 +251,7 @@ def update_money_display(
251251
sum(repo_money.values()) for repo_money in self.repo_money_spent.values()
252252
)
253253
self.money_display = Text(
254-
f"Money Spent So Far: ${total_money_spent_for_all_repos:.2f}",
254+
f"${total_money_spent_for_all_repos:.2f}",
255255
justify="center",
256256
)
257257
self.layout["progress"]["money"].update(

agent/run_agent.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ def run_agent_for_repo(
6767
repo_path = os.path.join(repo_base_dir, repo_name)
6868
repo_path = os.path.abspath(repo_path)
6969

70-
# # TODO: remove this to make web3.py work
71-
# if repo_name == "web3-py":
72-
# repo_path = repo_path.replace("web3-py", "web3.py")
70+
target_edit_files = get_target_edit_files(
71+
repo_path, example["src_dir"], example["test"]["test_dir"]
72+
)
73+
# Call the commit0 get-tests command to retrieve test files
74+
test_files_str = get_tests(repo_name, verbose=0)
75+
test_files = sorted(list(set([i.split(":")[0] for i in test_files_str])))
7376

7477
try:
7578
local_repo = Repo(repo_path)
@@ -118,15 +121,7 @@ def run_agent_for_repo(
118121
if agent_config is None:
119122
raise ValueError("Invalid input")
120123

121-
target_edit_files = get_target_edit_files(
122-
repo_path, example["src_dir"], example["test"]["test_dir"]
123-
)
124-
125124
if agent_config.run_tests:
126-
# Call the commit0 get-tests command to retrieve test files
127-
test_files_str = get_tests(repo_name, verbose=0)
128-
test_files = sorted(list(set([i.split(":")[0] for i in test_files_str])))
129-
130125
update_queue.put(("start_repo", (original_repo_name, len(test_files))))
131126
# when unit test feedback is available, iterate over test files
132127
for test_file in test_files:
@@ -144,6 +139,7 @@ def run_agent_for_repo(
144139
lint_cmd,
145140
target_edit_files,
146141
test_log_dir,
142+
test_first=True,
147143
)
148144
# after running the agent, update the money display
149145
update_queue.put(

agent/run_agent_no_rich.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,22 @@ def run_agent_for_repo(
5353
"""Run Aider for a given repository."""
5454
# get repo info
5555
_, repo_name = example["repo"].split("/")
56+
print("Working on repo: ", repo_name)
5657

57-
repo_name = repo_name.lower()
58-
repo_name = repo_name.replace(".", "-")
58+
# repo_name = repo_name.lower()
59+
# repo_name = repo_name.replace(".", "-")
5960

6061
repo_path = os.path.join(repo_base_dir, repo_name)
6162
repo_path = os.path.abspath(repo_path)
6263

64+
# get target files to edit and test files to run
65+
target_edit_files = get_target_edit_files(
66+
repo_path, example["src_dir"], example["test"]["test_dir"]
67+
)
68+
# Call the commit0 get-tests command to retrieve test files
69+
test_files_str = get_tests(repo_name, verbose=0)
70+
test_files = sorted(list(set([i.split(":")[0] for i in test_files_str])))
71+
6372
try:
6473
local_repo = Repo(repo_path)
6574
except Exception:
@@ -102,22 +111,15 @@ def run_agent_for_repo(
102111

103112
# TODO: make this path more general
104113
commit0_dot_file_path = str(Path(repo_path).parent.parent / ".commit0.yaml")
114+
105115
with DirContext(repo_path):
106116
if agent_config is None:
107117
raise ValueError("Invalid input")
108118

109-
target_edit_files = get_target_edit_files(
110-
repo_path, example["src_dir"], example["test"]["test_dir"]
111-
)
112-
113119
if agent_config.run_tests:
114-
# Call the commit0 get-tests command to retrieve test files
115-
test_files_str = get_tests(repo_name, verbose=0)
116-
test_files = sorted(list(set([i.split(":")[0] for i in test_files_str])))
117-
118120
# when unit test feedback is available, iterate over test files
119121
for test_file in test_files:
120-
test_cmd = f"python -m commit0 test {repo_path} {test_file} --branch {branch} --backend {backend} --commit0_dot_file_path {commit0_dot_file_path}"
122+
test_cmd = f"python -m commit0 test {repo_path} {test_file} --branch {branch} --backend {backend} --commit0-dot-file-path {commit0_dot_file_path}"
121123
test_file_name = test_file.replace(".py", "").replace("/", "__")
122124
test_log_dir = experiment_log_dir / test_file_name
123125
lint_cmd = get_lint_cmd(repo_name, agent_config.use_lint_info)
@@ -128,6 +130,7 @@ def run_agent_for_repo(
128130
lint_cmd,
129131
target_edit_files,
130132
test_log_dir,
133+
test_first=True,
131134
)
132135
# cost = agent_return.last_cost
133136
else:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"pre-commit>=3.8.0",
1414
"PyMuPDF>=1.24.5",
1515
"aider-chat>=0.56.0",
16-
"modal>=0.64.95",
16+
"modal==0.64.95",
1717
"typer>=0.12.0",
1818
"tenacity>=8.5.0",
1919
"datasets>=3.0.0",

0 commit comments

Comments
 (0)