Skip to content

Commit 298956c

Browse files
authored
[Eval] initialize llm inside process_instance to circumvent "AttributeError:… (#2805)
* initialize llm inside process_instance to circumvent "AttributeError: Can't pickle local object" * update kwargs
1 parent 0d3b3ff commit 298956c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

evaluation/swe_bench/run_infer.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,17 @@ def get_test_result(instance, sandbox, workspace_dir_name):
193193

194194

195195
def process_instance(
196-
agent: Agent,
196+
agent_class: str,
197+
llm_config: dict,
197198
instance: Any,
198199
metadata: dict,
199200
skip_workspace_mount: bool,
200201
eval_output_dir: str,
201202
reset_logger: bool = True,
202203
):
204+
# Create the agent
205+
agent = Agent.get_cls(agent_class)(llm=LLM(llm_config=llm_config))
206+
203207
workspace_mount_path = os.path.join(config.workspace_mount_path, '_eval_workspace')
204208
# create process-specific workspace dir
205209
# if `not skip_workspace_mount` - we will create a workspace directory for EACH process
@@ -496,17 +500,15 @@ def update_progress(future):
496500
skip_workspace_mount = agent_class == 'CodeActAgent'
497501
logger.info(f'Skipping workspace mount: {skip_workspace_mount}')
498502

499-
# Create the agent
500-
agent = Agent.get_cls(agent_class)(llm=LLM(config.llm))
501-
502503
try:
503504
with ProcessPoolExecutor(num_workers) as executor:
504505
futures = []
505506
# This is how we perform multi-processing
506507
for row_idx, instance in swe_bench_tests.iterrows():
507508
future = executor.submit(
508509
process_instance,
509-
agent,
510+
agent_class,
511+
config.llm,
510512
instance,
511513
metadata,
512514
skip_workspace_mount,

0 commit comments

Comments
 (0)