Skip to content

Commit dbc2dd6

Browse files
committed
fix CI warnings when PR
Signed-off-by: Jerry Guan <jerryguan777@gmail.com>
1 parent f5771ff commit dbc2dd6

4 files changed

Lines changed: 75 additions & 29 deletions

File tree

examples/evaluation_and_profiling/swe_bench/src/nat_swe_bench/config.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,40 @@
2121

2222
from nat.data_models.common import BaseModelRegistryTag
2323
from nat.data_models.common import TypedBaseModel
24-
from nat.data_models.component_ref import FunctionRef
2524
from nat.data_models.component_ref import LLMRef
2625
from nat.data_models.function import FunctionBaseConfig
2726

2827

2928
class SweBenchPredictorBaseConfig(TypedBaseModel, BaseModelRegistryTag):
29+
"""Base configuration class for SWE-bench predictors."""
3030
description: str = "Swe Bench Problem Solver"
3131

3232

3333
class SweBenchPredictorGoldConfig(SweBenchPredictorBaseConfig, name="gold"):
34+
"""Configuration for the gold predictor that uses the provided patch directly.
35+
36+
Attributes:
37+
verbose: Whether to enable verbose output for debugging.
38+
"""
3439
verbose: bool = True
3540

3641

3742
class SweBenchPredictorSkeletonConfig(SweBenchPredictorBaseConfig, name="skeleton"):
43+
"""Configuration for the skeleton predictor template.
44+
45+
Attributes:
46+
verbose: Whether to enable verbose output for debugging.
47+
"""
3848
verbose: bool = False
3949

4050
class SweBenchPredictorIterativeConfig(SweBenchPredictorBaseConfig, name="iterative"):
51+
"""Configuration for the iterative predictor that solves problems step-by-step.
52+
53+
Attributes:
54+
llm_name: Reference to the LLM to use for iterative problem solving.
55+
step_limit: Maximum number of agent steps before termination.
56+
timeout: Command execution timeout in seconds.
57+
"""
4158
llm_name: LLMRef = Field(description="LLM to use for iterative agent")
4259
step_limit: int = Field(default=250, description="Maximum number of agent steps")
4360
timeout: int = Field(default=60, description="Command execution timeout in seconds")
@@ -49,4 +66,9 @@ class SweBenchPredictorIterativeConfig(SweBenchPredictorBaseConfig, name="iterat
4966
Discriminator(TypedBaseModel.discriminator)]
5067

5168
class SweBenchWorkflowConfig(FunctionBaseConfig, name="swe_bench"):
69+
"""Configuration for the SWE-bench workflow.
70+
71+
Attributes:
72+
predictor: The predictor configuration (gold, skeleton, or iterative).
73+
"""
5274
predictor: SweBenchPredictorConfig

examples/evaluation_and_profiling/swe_bench/src/nat_swe_bench/configs/config_iterative.yml

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
llms:
17+
nim_llm:
18+
_type: nim
19+
model_name: mistralai/mistral-nemotron
20+
temperature: 0.6
21+
max_tokens: 4096
22+
123
llms:
224
claude_sonnet_llm:
325
_type: litellm
@@ -12,14 +34,6 @@ llms:
1234
# temperature: 0.0
1335
# api_key: "${OPENAI_API_KEY}" # Set this environment variable before running
1436

15-
16-
# llms:
17-
# nim_llm:
18-
# _type: nim
19-
# model_name: meta/llama-3.3-70b-instruct
20-
# temperature: 0.6
21-
# max_tokens: 4096
22-
2337
workflow:
2438
_type: swe_bench
2539
predictor:
@@ -49,18 +63,15 @@ eval:
4963
field:
5064
instance_id:
5165
- sympy__sympy-20590
52-
#- sympy__sympy-21055
53-
#- sympy__sympy-11400
54-
#- sympy__sympy-11870
55-
#- astropy__astropy-12907
56-
#- astropy__astropy-6938
57-
#- django__django-15781
58-
#- django__django-11001
59-
#- matplotlib__matplotlib-25332
60-
#- mwaskom__seaborn-3010
61-
#- pallets__flask-4045
62-
#- psf__requests-1963
63-
#- pydata__xarray-3364
66+
# - sympy__sympy-21055
67+
# - sympy__sympy-11400
68+
# - astropy__astropy-12907
69+
# - astropy__astropy-6938
70+
# - django__django-15781
71+
# - django__django-11001
72+
# - mwaskom__seaborn-3010
73+
# - pallets__flask-4045
74+
# - psf__requests-1963
6475

6576
evaluators:
6677
swe_bench:

examples/evaluation_and_profiling/swe_bench/src/nat_swe_bench/predictors/predict_iterative/tools/git_tool.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
import asyncio
1617
import logging
1718
from dataclasses import dataclass
1819
from pathlib import Path
@@ -69,17 +70,23 @@ async def cleanup(self):
6970

7071
def get_repo_path(workspace_dir: str, repo_url: str) -> Path:
7172
"""Generate a unique path for the repository."""
72-
repo_name = repo_url.split('/')[-1].replace('.git', '')
73-
return Path(workspace_dir) / repo_name
73+
parts = repo_url.rstrip('/').split('/')
74+
repo_name = parts[-1].replace('.git', '')
75+
org_name = parts[-2] # Organization name
76+
77+
# Return: workspace_dir/org/repo
78+
return Path(workspace_dir) / org_name / repo_name
7479

7580

7681
async def clone_repository(repo_url: str, target_path: Path) -> Repo:
7782
"""Clone a repository to the specified path."""
7883
logger.info("Cloning repository %s to %s", repo_url, target_path)
79-
return Repo.clone_from(repo_url, target_path)
84+
# Use asyncio.to_thread to avoid blocking the event loop during clone operation
85+
return await asyncio.to_thread(Repo.clone_from, repo_url, target_path)
8086

8187

8288
async def checkout_commit(repo: Repo, commit_hash: str):
8389
"""Checkout a specific commit in the repository."""
8490
logger.info("Checking out commit %s", commit_hash)
85-
repo.git.checkout(commit_hash)
91+
# Use asyncio.to_thread to avoid blocking the event loop during checkout
92+
await asyncio.to_thread(repo.git.checkout, commit_hash)

examples/evaluation_and_profiling/swe_bench/src/nat_swe_bench/predictors/predict_iterative/tools/register.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,18 +39,24 @@ async def git_repo_tool(tool_config: GitRepoToolConfig, builder: Builder):
3939

4040
# Simple async function that accepts a JSON string
4141
async def git_operations(args_str: str) -> str:
42-
args = json.loads(args_str)
42+
try:
43+
args = json.loads(args_str)
44+
except json.JSONDecodeError as e:
45+
raise ValueError(f"Invalid JSON input: {e}") from e
46+
4347
operation = args.get('operation')
4448

4549
if operation == "setup":
50+
if 'repo_url' not in args or 'base_commit' not in args:
51+
raise ValueError("setup operation requires 'repo_url' and 'base_commit'")
4652
context = await repo_manager.setup_repository(args['repo_url'], args['base_commit'])
4753
return str(context.repo_path)
4854

4955
if operation == "cleanup":
5056
await repo_manager.cleanup()
5157
return "Cleanup complete"
5258

53-
raise ValueError(f"Unknown operation: {operation}")
59+
raise ValueError(f"Unknown operation: {operation}. Supported: 'setup', 'cleanup'")
5460

5561
try:
5662
yield FunctionInfo.from_fn(git_operations,

0 commit comments

Comments
 (0)