15
15
from typing import Optional , Type
16
16
from types import TracebackType
17
17
from hydra .core .config_store import ConfigStore
18
- from baselines .class_types import AgentConfig , Commit0Config
18
+ from baselines .class_types import AgentConfig
19
19
from commit0 .harness .constants import SPLIT
20
20
from commit0 .harness .get_pytest_ids import main as get_tests
21
21
from commit0 .harness .constants import RUN_AIDER_LOG_DIR , RepoInstance
22
22
from tqdm import tqdm
23
+ from commit0 .cli import read_commit0_dot_file
23
24
24
25
25
26
class DirContext :
@@ -40,7 +41,7 @@ def __exit__(
40
41
41
42
42
43
def run_agent_for_repo (
43
- commit0_config : Commit0Config ,
44
+ repo_base_dir : str ,
44
45
agent_config : AgentConfig ,
45
46
example : RepoInstance ,
46
47
) -> None :
@@ -55,7 +56,7 @@ def run_agent_for_repo(
55
56
test_files_str = get_tests (repo_name , verbose = 0 )
56
57
test_files = sorted (list (set ([i .split (":" )[0 ] for i in test_files_str ])))
57
58
58
- repo_path = os .path .join (commit0_config . base_dir , repo_name )
59
+ repo_path = os .path .join (repo_base_dir , repo_name )
59
60
repo_path = os .path .abspath (repo_path )
60
61
try :
61
62
local_repo = Repo (repo_path )
@@ -82,13 +83,15 @@ def run_agent_for_repo(
82
83
local_repo .git .reset ("--hard" , example ["base_commit" ])
83
84
target_edit_files = get_target_edit_files (repo_path )
84
85
with DirContext (repo_path ):
85
- if commit0_config is None or agent_config is None :
86
+ if agent_config is None :
86
87
raise ValueError ("Invalid input" )
87
88
88
89
if agent_config .run_tests :
89
90
# when unit test feedback is available, iterate over test files
90
91
for test_file in test_files :
91
- test_cmd = f"python -m commit0 test { repo_path } { run_id } { test_file } "
92
+ test_cmd = (
93
+ f"python -m commit0 test { repo_path } { test_file } --branch { run_id } "
94
+ )
92
95
test_file_name = test_file .replace (".py" , "" ).replace ("/" , "__" )
93
96
log_dir = RUN_AIDER_LOG_DIR / "with_tests" / test_file_name
94
97
lint_cmd = get_lint_cmd (local_repo , agent_config .use_lint_info )
@@ -119,26 +122,26 @@ def main() -> None:
119
122
Will run in parallel for each repo.
120
123
"""
121
124
cs = ConfigStore .instance ()
122
- cs .store (name = "user" , node = Commit0Config )
123
125
cs .store (name = "user" , node = AgentConfig )
124
126
hydra .initialize (version_base = None , config_path = "configs" )
125
127
config = hydra .compose (config_name = "agent" )
126
- commit0_config = Commit0Config (** config .commit0_config )
127
128
agent_config = AgentConfig (** config .agent_config )
128
129
130
+ commit0_config = read_commit0_dot_file (".commit0.yaml" )
131
+
129
132
dataset = load_dataset (
130
- commit0_config . dataset_name , split = commit0_config . dataset_split
133
+ commit0_config [ " dataset_name" ] , split = commit0_config [ " dataset_split" ]
131
134
)
132
135
filtered_dataset = [
133
136
example
134
137
for example in dataset
135
- if commit0_config . repo_split == "all"
138
+ if commit0_config [ " repo_split" ] == "all"
136
139
or (
137
140
isinstance (example , dict )
138
141
and "repo" in example
139
142
and isinstance (example ["repo" ], str )
140
143
and example ["repo" ].split ("/" )[- 1 ]
141
- in SPLIT .get (commit0_config . repo_split , [])
144
+ in SPLIT .get (commit0_config [ " repo_split" ] , [])
142
145
)
143
146
]
144
147
assert len (filtered_dataset ) > 0 , "No examples available"
@@ -149,14 +152,14 @@ def main() -> None:
149
152
with tqdm (
150
153
total = len (filtered_dataset ), smoothing = 0 , desc = "Running Aider for repos"
151
154
) as pbar :
152
- with multiprocessing .Pool (processes = commit0_config . num_workers ) as pool :
155
+ with multiprocessing .Pool (processes = 10 ) as pool :
153
156
results = []
154
157
155
158
# Use apply_async to submit jobs and add progress bar updates
156
159
for example in filtered_dataset :
157
160
result = pool .apply_async (
158
161
run_agent_for_repo ,
159
- args = (commit0_config , agent_config , example ),
162
+ args = (commit0_config [ "base_dir" ] , agent_config , example ),
160
163
callback = lambda _ : pbar .update (
161
164
1
162
165
), # Update progress bar on task completion
0 commit comments