Harness API
swebench.harness
__all__
module-attribute
__all__ = ['docker_utils', 'grading', 'reporting', 'utils', 'constants', 'log_parsers', 'modal_eval']
constants
INFERENCE_LOG_DIR
module-attribute
INFERENCE_LOG_DIR = Path('logs/inference')
RUN_EVALUATION_LOG_DIR
module-attribute
RUN_EVALUATION_LOG_DIR = Path('logs/evaluation')
FAIL_TO_PASS
module-attribute
FAIL_TO_PASS = 'FAIL_TO_PASS'
FAIL_TO_FAIL
module-attribute
FAIL_TO_FAIL = 'FAIL_TO_FAIL'
PASS_TO_PASS
module-attribute
PASS_TO_PASS = 'PASS_TO_PASS'
PASS_TO_FAIL
module-attribute
PASS_TO_FAIL = 'PASS_TO_FAIL'
CONTAINER_PATCH_FILE
module-attribute
CONTAINER_PATCH_FILE = '/tmp/patch.diff'
LOG_REPORT
module-attribute
LOG_REPORT = 'report.json'
LOG_RUN_METADATA
module-attribute
LOG_RUN_METADATA = 'run.json'
LOG_INSTANCE
module-attribute
LOG_INSTANCE = 'run_instance.log'
LOG_TEST_OUTPUT
module-attribute
LOG_TEST_OUTPUT = 'test_output.txt'
APPLY_PATCH_FAIL
module-attribute
APPLY_PATCH_FAIL = '>>>>> Patch Apply Failed'
APPLY_PATCH_PASS
module-attribute
APPLY_PATCH_PASS = '>>>>> Applied Patch'
RESET_FAILED
module-attribute
RESET_FAILED = '>>>>> Reset Failed'
TESTS_ERROR
module-attribute
TESTS_ERROR = '>>>>> Tests Errored'
TESTS_FAILED
module-attribute
TESTS_FAILED = '>>>>> Some Tests Failed'
TESTS_PASSED
module-attribute
TESTS_PASSED = '>>>>> All Tests Passed'
TESTS_TIMEOUT
module-attribute
TESTS_TIMEOUT = '>>>>> Tests Timed Out'
START_TEST_OUTPUT
module-attribute
START_TEST_OUTPUT = '>>>>> Start Test Output'
END_TEST_OUTPUT
module-attribute
END_TEST_OUTPUT = '>>>>> End Test Output'
TEST_EXIT_CODE
module-attribute
TEST_EXIT_CODE = '>>>>> Test Exit Code'
TEST_EXIT_CODE_VAR
module-attribute
TEST_EXIT_CODE_VAR = 'SWEBENCH_TEST_EXIT_CODE'
NON_TEST_EXTS
module-attribute
NON_TEST_EXTS = ['.json', '.png', 'csv', '.txt', '.md', '.jpg', '.jpeg', '.pkl', '.yml', '.yaml', '.toml']
SWE_BENCH_URL_RAW
module-attribute
SWE_BENCH_URL_RAW = 'https://raw.githubusercontent.com/'
FAIL_ONLY_REPOS
module-attribute
FAIL_ONLY_REPOS = {'chartjs/Chart.js', 'processing/p5.js', 'markedjs/marked', 'bpmn-io/bpmn-js', 'openlayers/openlayers', 'eslint/eslint'}
ResolvedStatus
Bases: Enum
NO
class-attribute
instance-attribute
NO = 'RESOLVED_NO'
PARTIAL
class-attribute
instance-attribute
PARTIAL = 'RESOLVED_PARTIAL'
FULL
class-attribute
instance-attribute
FULL = 'RESOLVED_FULL'
TestStatus
Bases: Enum
FAILED
class-attribute
instance-attribute
FAILED = 'FAILED'
PASSED
class-attribute
instance-attribute
PASSED = 'PASSED'
SKIPPED
class-attribute
instance-attribute
SKIPPED = 'SKIPPED'
ERROR
class-attribute
instance-attribute
ERROR = 'ERROR'
XFAIL
class-attribute
instance-attribute
XFAIL = 'XFAIL'
EvalType
Bases: Enum
PASS_AND_FAIL
class-attribute
instance-attribute
PASS_AND_FAIL = 'pass_and_fail'
FAIL_ONLY
class-attribute
instance-attribute
FAIL_ONLY = 'fail_only'
docker_utils
copy_to_container
copy_to_container(container: Container, src: Path, dst: Path)
Copy a file from local to a docker container
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
Container
|
Docker container to copy to |
required |
src
|
Path
|
Source file path |
required |
dst
|
Path
|
Destination file path in the container |
required |
Source code in swebench/harness/docker_utils.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
write_to_container
write_to_container(container: Container, data: str, dst: Path)
Write a string to a file in a docker container
Source code in swebench/harness/docker_utils.py
39 40 41 42 43 44 45 | |
cleanup_container
cleanup_container(client, container, logger)
Stop and remove a Docker container using subprocess commands. Performs this forcefully if the container cannot be stopped with the standard docker stop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
DockerClient
|
Docker client (unused, kept for compatibility). |
required |
container
|
Container
|
Container to remove. |
required |
logger
|
Logger
|
Logger to use for output. If None, print to stdout |
required |
Source code in swebench/harness/docker_utils.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
exec_run_with_timeout
exec_run_with_timeout(container, cmd, timeout: int | None = 60)
Run a command in a container with a timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
Container
|
Container to run the command in. |
required |
cmd
|
str
|
Command to run. |
required |
timeout
|
int
|
Timeout in seconds. |
60
|
Source code in swebench/harness/docker_utils.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
grading
SUITE_RAN
module-attribute
SUITE_RAN = re.compile("Executed [1-9]\\d* of \\d+|TOTAL: [1-9]\\d* (?:SUCCESS|FAILED)|[1-9]\\d* passing|Tests:\\s+[1-9]\\d*|Test Suites:\\s+(?:\\d+ \\w+, )*[1-9]\\d* total|^# tests [1-9]\\d*|[1-9]\\d* specs?, \\d+ failures?|': ok$", re.M)
TEST_EXIT_CODE_RE
module-attribute
TEST_EXIT_CODE_RE = re.compile(f'{re.escape(TEST_EXIT_CODE)}:\\s*(-?\\d+)')
parse_test_exit_code
parse_test_exit_code(content: str) -> int | None
Return the recorded test command exit status, or None if absent.
Source code in swebench/harness/grading.py
55 56 57 58 | |
test_passed
test_passed(case: str, sm: dict[str, str]) -> bool
Source code in swebench/harness/grading.py
85 86 87 88 89 90 | |
test_maintained
test_maintained(case: str, sm: dict[str, str]) -> bool
P2P semantics: a skipped test is not a regression, unlike for F2P.
Source code in swebench/harness/grading.py
93 94 95 96 97 98 | |
test_failed
test_failed(case: str, sm: dict[str, str]) -> bool
Source code in swebench/harness/grading.py
101 102 103 104 105 106 107 108 109 | |
get_logs_eval
get_logs_eval(test_spec: TestSpec, log_fp: str) -> tuple[dict[str, str], bool]
Retrieve evaluation results for a task instance from its corresponding log file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_fp
|
str
|
path to log file |
required |
Returns: bool: whether the patch applied successfully dict: status map
TODO(john-b-yang): Check this is working properly...
Source code in swebench/harness/grading.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
get_eval_tests_report
get_eval_tests_report(eval_status_map: dict[str, str], gold_results: dict[str, str], calculate_to_fail: bool = False, eval_type: EvalType = PASS_AND_FAIL) -> dict[str, dict[str, list[str]]]
Create a report based on failure/pass change from gold results to eval results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eval_sm
|
dict
|
evaluation status map |
required |
gold_results
|
dict
|
gold results |
required |
calculate_to_fail
|
bool
|
whether to calculate metrics for "x to fail" tests |
False
|
Returns: report (dict): report of metrics
Metric Definitions (Gold Result Pair + Eval Result): - Fail-Pass (F2P) + P: Success (Resolution) - Pass-Pass (P2P) + P: Success (Maintenance) - Fail-Pass (F2P) + F: Failure - Pass-Pass (P2P) + F: Failure
Miscellaneous Definitions - Fail-Fail (F2F) + F: Failure Maintenance - Pass-Fail (P2F) + F: Not considered - Fail-Fail (F2F) + P: Success (Extra Credit) - Pass-Fail (P2F) + P: Not considered
Source code in swebench/harness/grading.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
compute_fail_to_pass
compute_fail_to_pass(report: dict[str, dict[str, Any]]) -> float
Compute fail-to-pass metric. Accepts single report as argument.
Source code in swebench/harness/grading.py
288 289 290 291 292 293 294 295 | |
compute_pass_to_pass
compute_pass_to_pass(report: dict[str, dict[str, Any]]) -> float
Compute pass-to-pass metric. Accepts single report as argument.
Source code in swebench/harness/grading.py
298 299 300 301 302 303 304 305 306 | |
get_resolution_status
get_resolution_status(report: dict[str, dict[str, Any]]) -> str
Determine resolved status of an evaluation instance
Criteria
- If fail-to-pass (Resolution) = 1 and pass-to-pass (Maintenance) = 1 -> FULL
- If (fail-to-pass (Resolution) < 1 and > 0) and pass-to-pass (Maintenance) = 1 -> PARTIAL
- Otherwise -> NO
Source code in swebench/harness/grading.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
get_eval_report
get_eval_report(test_spec: TestSpec, prediction: dict[str, str], test_log_path: str, include_tests_status: bool) -> dict[str, Any]
Generate a report of model evaluation results from a prediction, task instance, and evaluation log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_spec
|
dict
|
test spec containing keys "instance_id", "FAIL_TO_PASS", and "PASS_TO_PASS" |
required |
prediction
|
dict
|
prediction containing keys "instance_id", "model_name_or_path", and "model_patch" |
required |
log_path
|
str
|
path to evaluation log |
required |
include_tests_status
|
bool
|
whether to include the status of each test in the returned report |
required |
Returns: report (dict): report of metrics
Source code in swebench/harness/grading.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
infra_failure
Post-hoc classification of infrastructure failures (#586).
Separates "the environment broke" from "the model's patch was wrong" using signatures in logs the harness already writes, so a broken image is not silently counted as a model failure.
Two properties are deliberate:
- Classification is post-hoc and read-only. It never runs commands in a container and never decides whether an instance gets evaluated, so it cannot drop an instance from a run.
- It is advisory. A flagged instance stays in
unresolved_ids/error_idsexactly as before, so the scoring denominator is unchanged.
TIER_ENVIRONMENT
module-attribute
TIER_ENVIRONMENT = 'environment'
TIER_AMBIGUOUS
module-attribute
TIER_AMBIGUOUS = 'ambiguous'
INFRA_FAILURE_SIGNATURES
module-attribute
INFRA_FAILURE_SIGNATURES: tuple[tuple[str, str, str], ...] = (('browser_launch_failed', TIER_ENVIRONMENT, 'Failed to launch|Failed to connect to the bus'), ('display_unavailable', TIER_ENVIRONMENT, 'cannot open display|Missing X server|unable to open X display'), ('out_of_memory', TIER_ENVIRONMENT, 'Cannot allocate memory|OutOfMemoryError|^Killed$'), ('container_unavailable', TIER_ENVIRONMENT, 'Error response from daemon|Cannot connect to the Docker daemon'), ('network_unreachable', TIER_ENVIRONMENT, 'Could not resolve host|Temporary failure in name resolution'), ('missing_module', TIER_AMBIGUOUS, 'Cannot find module|MODULE_NOT_FOUND|ModuleNotFoundError'), ('no_tests_collected', TIER_AMBIGUOUS, 'no tests ran|collected 0 items'), ('tests_timed_out', TIER_AMBIGUOUS, 'Timeout error: \\d+ seconds exceeded'))
classify_text
classify_text(text: str) -> tuple[str, str] | None
Return (reason, tier) for the first matching signature, else None.
Source code in swebench/harness/infra_failure.py
69 70 71 72 73 74 75 76 | |
classify_logs
classify_logs(*log_paths: str | Path) -> tuple[str, str] | None
Classify the concatenated contents of whichever log paths exist.
Source code in swebench/harness/infra_failure.py
79 80 81 82 83 84 85 86 | |
log_parsers
PARSER_REGISTRY
module-attribute
PARSER_REGISTRY = {'parse_log_pytest': parse_log_pytest, 'parse_log_pytest_options': parse_log_pytest_options, 'parse_log_django': parse_log_django, 'parse_log_pytest_v2': parse_log_pytest_v2, 'parse_log_seaborn': parse_log_seaborn, 'parse_log_sympy': parse_log_sympy, 'parse_log_matplotlib': parse_log_matplotlib, 'parse_log_astroid': parse_log_astroid, 'parse_log_flask': parse_log_flask, 'parse_log_marshmallow': parse_log_marshmallow, 'parse_log_pvlib': parse_log_pvlib, 'parse_log_pyvista': parse_log_pyvista, 'parse_log_sqlfluff': parse_log_sqlfluff, 'parse_log_xarray': parse_log_xarray, 'parse_log_pydicom': parse_log_pydicom, 'parse_log_requests': parse_log_requests, 'parse_log_pylint': parse_log_pylint, 'parse_log_astropy': parse_log_astropy, 'parse_log_scikit': parse_log_scikit, 'parse_log_sphinx': parse_log_sphinx, 'parse_log_calypso': parse_log_calypso, 'parse_log_bpmn_js': parse_log_bpmn_js, 'parse_log_carbon': parse_log_carbon, 'parse_log_eslint': parse_log_eslint, 'parse_log_grommet': parse_log_grommet, 'parse_log_highlightjs': parse_log_highlightjs, 'parse_log_lighthouse': parse_log_lighthouse, 'parse_log_next': parse_log_next, 'parse_log_openlayers': parse_log_openlayers, 'parse_log_prismjs': parse_log_prismjs, 'parse_log_quarto_cli': parse_log_quarto_cli, 'parse_log_chart_js': parse_log_chart_js, 'parse_log_marked': parse_log_marked, 'parse_log_p5js': parse_log_p5js, 'parse_log_react_pdf': parse_log_react_pdf, 'parse_log_jest': parse_log_jest, 'parse_log_jest_json': parse_log_jest_json, 'parse_log_vitest': parse_log_vitest, 'parse_log_karma': parse_log_karma, 'parse_log_tap': parse_log_tap, 'parse_log_immutable_js': parse_log_immutable_js, 'parse_log_redis': parse_log_redis, 'parse_log_jq': parse_log_jq, 'parse_log_doctest': parse_log_doctest, 'parse_log_micropython_test': parse_log_micropython_test, 'parse_log_googletest': parse_log_googletest, 'parse_log_gotest': parse_log_gotest, 'parse_log_maven': parse_log_maven, 'parse_log_ant': parse_log_ant, 'parse_log_gradle_custom': parse_log_gradle_custom, 'parse_log_phpunit': parse_log_phpunit, 'parse_log_minitest': parse_log_minitest, 'parse_log_cucumber': parse_log_cucumber, 'parse_log_ruby_unit': parse_log_ruby_unit, 'parse_log_rspec_transformed_json': parse_log_rspec_transformed_json, 'parse_log_jekyll': parse_log_jekyll, 'parse_log_cargo': parse_log_cargo}
__all__
module-attribute
__all__ = ['PARSER_REGISTRY']
c
MAP_REPO_TO_PARSER_C
module-attribute
MAP_REPO_TO_PARSER_C = {'redis/redis': parse_log_redis, 'jqlang/jq': parse_log_jq, 'nlohmann/json': parse_log_doctest, 'micropython/micropython': parse_log_micropython_test, 'valkey-io/valkey': parse_log_redis, 'fmtlib/fmt': parse_log_googletest}
parse_log_redis
parse_log_redis(log: str, test_spec: TestSpec) -> dict[str, str]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/c.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
parse_log_jq
parse_log_jq(log: str, test_spec: TestSpec) -> dict[str, str]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/c.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
parse_log_doctest
parse_log_doctest(log: str, test_spec: TestSpec) -> dict[str, str]
Assumes test binary runs with -s -r=xml.
Source code in swebench/harness/log_parsers/c.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
parse_log_micropython_test
parse_log_micropython_test(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/c.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
parse_log_googletest
parse_log_googletest(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/c.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
go
MAP_REPO_TO_PARSER_GO
module-attribute
MAP_REPO_TO_PARSER_GO = {'caddyserver/caddy': parse_log_gotest, 'hashicorp/terraform': parse_log_gotest, 'prometheus/prometheus': parse_log_gotest, 'gohugoio/hugo': parse_log_gotest, 'gin-gonic/gin': parse_log_gotest}
parse_log_gotest
parse_log_gotest(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with 'go test'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
test_spec
|
TestSpec
|
test spec (unused) |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/go.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
java
MAP_REPO_TO_PARSER_JAVA
module-attribute
MAP_REPO_TO_PARSER_JAVA = {'google/gson': parse_log_maven, 'apache/druid': parse_log_maven, 'javaparser/javaparser': parse_log_maven, 'projectlombok/lombok': parse_log_ant, 'apache/lucene': parse_log_gradle_custom, 'reactivex/rxjava': parse_log_gradle_custom}
parse_log_maven
parse_log_maven(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with 'mvn test'. Annoyingly maven will not print the tests that have succeeded. For this log parser to work, each test must be run individually, and then we look for BUILD (SUCCESS|FAILURE) in the logs.
Handles race conditions where multiple test commands appear before their BUILD results due to concurrent output from shell tracing and Maven.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/java.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
parse_log_ant
parse_log_ant(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/java.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
parse_log_gradle_custom
parse_log_gradle_custom(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with 'gradle test'. Assumes that the pre-install script to update the gradle config has run.
Handles race conditions where test name and status appear on different lines due to interleaved log output from concurrent processes.
Source code in swebench/harness/log_parsers/java.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
javascript
MAP_REPO_TO_PARSER_JS
module-attribute
MAP_REPO_TO_PARSER_JS = {'Automattic/wp-calypso': parse_log_calypso, 'chartjs/Chart.js': parse_log_chart_js, 'markedjs/marked': parse_log_marked, 'processing/p5.js': parse_log_p5js, 'diegomura/react-pdf': parse_log_react_pdf, 'babel/babel': parse_log_jest, 'vuejs/core': parse_log_vitest, 'facebook/docusaurus': parse_log_jest, 'immutable-js/immutable-js': parse_log_immutable_js, 'mrdoob/three.js': parse_log_tap, 'preactjs/preact': parse_log_karma, 'axios/axios': parse_log_tap, 'alibaba-fusion/next': parse_log_next, 'bpmn-io/bpmn-js': parse_log_bpmn_js, 'carbon-design-system/carbon': parse_log_carbon, 'cypress-io/cypress': parse_log_cypress, 'emotion-js/emotion': parse_log_emotion, 'eslint/eslint': parse_log_eslint, 'GoogleChrome/lighthouse': parse_log_lighthouse, 'grommet/grommet': parse_log_grommet, 'highlightjs/highlight.js': parse_log_highlightjs, 'openlayers/openlayers': parse_log_openlayers, 'plotly/plotly.js': parse_plotly_js, 'prettier/prettier': parse_log_prettier, 'PrismJS/prism': parse_log_prismjs, 'quarto-dev/quarto-cli': parse_log_quarto_cli, 'scratchfoundation/scratch-gui': parse_log_scratch_gui}
parse_log_highlightjs
parse_log_highlightjs(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by HighlightJS test suite (Mocha test framework)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
Log output from running the test suite |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/javascript.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
parse_log_prismjs
parse_log_prismjs(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by PrismJS test suite
Source code in swebench/harness/log_parsers/javascript.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
parse_log_eslint
parse_log_eslint(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by ESLint test suite
Source code in swebench/harness/log_parsers/javascript.py
73 74 75 76 77 78 79 80 81 82 83 | |
parse_log_bpmn_js
parse_log_bpmn_js(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by BPMN-JS test suite
Source code in swebench/harness/log_parsers/javascript.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
parse_plotly_js
parse_plotly_js(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by PlotlyJS test suite
Source code in swebench/harness/log_parsers/javascript.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
parse_log_openlayers
parse_log_openlayers(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by OpenLayers test suite
Source code in swebench/harness/log_parsers/javascript.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
parse_log_emotion
parse_log_emotion(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Emotion test suite
Source code in swebench/harness/log_parsers/javascript.py
165 166 167 168 169 170 171 172 173 174 | |
parse_log_grommet
parse_log_grommet(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Grommet test suite
Source code in swebench/harness/log_parsers/javascript.py
177 178 179 180 181 182 183 184 185 186 187 188 189 | |
parse_log_next_v1
parse_log_next_v1(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/javascript.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
parse_log_next_v2
parse_log_next_v2(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/javascript.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
parse_log_next
parse_log_next(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Calypso test suite
Source code in swebench/harness/log_parsers/javascript.py
267 268 269 270 271 272 273 274 | |
parse_log_cypress
parse_log_cypress(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Cypress test suite
Source code in swebench/harness/log_parsers/javascript.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
parse_log_carbon
parse_log_carbon(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Carbon test suite
Source code in swebench/harness/log_parsers/javascript.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
parse_log_lighthouse_mocha
parse_log_lighthouse_mocha(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/javascript.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
parse_log_lighthouse
parse_log_lighthouse(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Lighthouse test suite
Source code in swebench/harness/log_parsers/javascript.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
parse_log_quarto_cli
parse_log_quarto_cli(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Quarto test suite
Source code in swebench/harness/log_parsers/javascript.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
parse_log_calypso
parse_log_calypso(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Calypso test suite
Source code in swebench/harness/log_parsers/javascript.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
parse_log_chart_js
parse_log_chart_js(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by ChartJS test suite
Source code in swebench/harness/log_parsers/javascript.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
parse_log_marked
parse_log_marked(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Marked test suite
Source code in swebench/harness/log_parsers/javascript.py
522 523 524 525 526 527 528 529 530 531 | |
parse_log_p5js
parse_log_p5js(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/javascript.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
parse_log_react_pdf
parse_log_react_pdf(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated by Carbon test suite
Source code in swebench/harness/log_parsers/javascript.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | |
parse_log_jest
parse_log_jest(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with Jest. Assumes --verbose flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/javascript.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
parse_log_jest_json
parse_log_jest_json(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with Jest. Assumes the --json flag has been piped into JEST_JSON_JQ_TRANSFORM. Unlike --verbose, tests with the same name in different describe blocks print with different names.
Source code in swebench/harness/log_parsers/javascript.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
parse_log_vitest
parse_log_vitest(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with vitest. Assumes --reporter=verbose flag.
Source code in swebench/harness/log_parsers/javascript.py
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | |
parse_log_karma
parse_log_karma(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with Karma. Handles duplicate test names in different describe blocks. Logic is brittle.
Source code in swebench/harness/log_parsers/javascript.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
parse_log_tap
parse_log_tap(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with TAP
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/javascript.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
parse_log_immutable_js
parse_log_immutable_js(log: str, test_spec: TestSpec) -> dict[str, str]
Different immutable.js instances use different test runners and log formats. This function selects the appropriate log parser based on the instance id.
Source code in swebench/harness/log_parsers/javascript.py
771 772 773 774 775 776 777 778 779 780 781 782 783 | |
php
MAP_REPO_TO_PARSER_PHP
module-attribute
MAP_REPO_TO_PARSER_PHP = {'phpoffice/phpspreadsheet': parse_log_phpunit, 'laravel/framework': parse_log_phpunit, 'php-cs-fixer/php-cs-fixer': parse_log_phpunit, 'briannesbitt/carbon': parse_log_phpunit}
parse_log_phpunit
parse_log_phpunit(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for phpunit logs with the --testdox option. Args: log (str): log content test_spec (TestSpec): test spec (unused) Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/php.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
python
MAP_REPO_TO_PARSER_PY
module-attribute
MAP_REPO_TO_PARSER_PY = {'astropy/astropy': parse_log_astropy, 'django/django': parse_log_django, 'marshmallow-code/marshmallow': parse_log_marshmallow, 'matplotlib/matplotlib': parse_log_matplotlib, 'mwaskom/seaborn': parse_log_seaborn, 'pallets/flask': parse_log_flask, 'psf/requests': parse_log_requests, 'pvlib/pvlib-python': parse_log_pvlib, 'pydata/xarray': parse_log_xarray, 'pydicom/pydicom': parse_log_pydicom, 'pylint-dev/astroid': parse_log_astroid, 'pylint-dev/pylint': parse_log_pylint, 'pytest-dev/pytest': parse_log_pytest, 'pyvista/pyvista': parse_log_pyvista, 'scikit-learn/scikit-learn': parse_log_scikit, 'sqlfluff/sqlfluff': parse_log_sqlfluff, 'sphinx-doc/sphinx': parse_log_sphinx, 'sympy/sympy': parse_log_sympy}
parse_log_pytest
parse_log_pytest(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with PyTest framework
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/python.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
parse_log_pytest_options
parse_log_pytest_options(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with PyTest framework with options
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/python.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
parse_log_django
parse_log_django(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with Django tester framework
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/python.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
parse_log_pytest_v2
parse_log_pytest_v2(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with PyTest framework (Later Version)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/python.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
parse_log_seaborn
parse_log_seaborn(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with seaborn testing framework
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/python.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
parse_log_sympy
parse_log_sympy(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with Sympy framework
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/python.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
parse_log_matplotlib
parse_log_matplotlib(log: str, test_spec: TestSpec) -> dict[str, str]
Parser for test logs generated with PyTest framework
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/python.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
ruby
MAP_REPO_TO_PARSER_RUBY
module-attribute
MAP_REPO_TO_PARSER_RUBY = {'jekyll/jekyll': parse_log_jekyll, 'fluent/fluentd': parse_log_ruby_unit, 'fastlane/fastlane': parse_log_rspec_transformed_json, 'jordansissel/fpm': parse_log_rspec_transformed_json, 'faker-ruby/faker': parse_log_ruby_unit, 'rubocop/rubocop': parse_log_rspec_transformed_json}
parse_log_minitest
parse_log_minitest(log: str, test_spec: TestSpec) -> dict[str, str]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/ruby.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
parse_log_cucumber
parse_log_cucumber(log: str, test_spec: TestSpec) -> dict[str, str]
Assumes --format progress is used.
Source code in swebench/harness/log_parsers/ruby.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
parse_log_ruby_unit
parse_log_ruby_unit(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/ruby.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
parse_log_rspec_transformed_json
parse_log_rspec_transformed_json(log: str, test_spec: TestSpec) -> dict[str, str]
Source code in swebench/harness/log_parsers/ruby.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
parse_log_jekyll
parse_log_jekyll(log: str, test_spec: TestSpec) -> dict[str, str]
Different jekyll instances use different test runners and log formats. This function selects the appropriate log parser based on the instance id.
Source code in swebench/harness/log_parsers/ruby.py
90 91 92 93 94 95 96 97 98 99 100 101 102 | |
rust
MAP_REPO_TO_PARSER_RUST
module-attribute
MAP_REPO_TO_PARSER_RUST = {'burntsushi/ripgrep': parse_log_cargo, 'sharkdp/bat': parse_log_cargo, 'astral-sh/ruff': parse_log_cargo, 'tokio-rs/tokio': parse_log_cargo, 'uutils/coreutils': parse_log_cargo, 'nushell/nushell': parse_log_cargo, 'tokio-rs/axum': parse_log_cargo}
parse_log_cargo
parse_log_cargo(log: str, test_spec: TestSpec) -> dict[str, str]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
str
|
log content |
required |
Returns: dict: test case to test status mapping
Source code in swebench/harness/log_parsers/rust.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
modal_eval
__all__
module-attribute
__all__ = ['run_instances_modal', 'validate_modal_credentials']
run_instances_modal
run_instances_modal(predictions: dict, instances: list, full_dataset: list, run_id: str, timeout: int)
Run all instances for the given predictions on Modal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
dict
|
Predictions dict generated by the model |
required |
instances
|
list
|
List of instances |
required |
run_id
|
str
|
Run ID |
required |
timeout
|
int
|
Timeout for running tests |
required |
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | |
validate_modal_credentials
validate_modal_credentials()
Validate that Modal credentials exist by checking for ~/.modal.toml file. Raises an exception if credentials are not configured.
Source code in swebench/harness/modal_eval/utils.py
4 5 6 7 8 9 10 11 12 13 14 | |
run_evaluation_modal
SANDBOX_ENTRYPOINT
module-attribute
SANDBOX_ENTRYPOINT = 'run_evaluation_modal_entrypoint'
LOCAL_SANDBOX_ENTRYPOINT_PATH
module-attribute
LOCAL_SANDBOX_ENTRYPOINT_PATH = (Path(__file__).parent / f'{SANDBOX_ENTRYPOINT}.py').resolve()
REMOTE_SANDBOX_ENTRYPOINT_PATH
module-attribute
REMOTE_SANDBOX_ENTRYPOINT_PATH = f'/root/{SANDBOX_ENTRYPOINT}.py'
app
module-attribute
app = modal.App('swebench-evaluation')
swebench_image
module-attribute
swebench_image = modal.Image.debian_slim().pip_install('swebench', 'tenacity')
TestOutput
dataclass
TestOutput(instance_id: str, test_output: str, report_json_str: str, run_instance_log: str, patch_diff: str, log_dir: Path, errored: bool)
instance_id
instance-attribute
instance_id: str
test_output
instance-attribute
test_output: str
report_json_str
instance-attribute
report_json_str: str
run_instance_log
instance-attribute
run_instance_log: str
patch_diff
instance-attribute
patch_diff: str
log_dir
instance-attribute
log_dir: Path
errored
instance-attribute
errored: bool
ModalSandboxRuntime
ModalSandboxRuntime(test_spec: TestSpec, timeout: int | None = None, verbose: bool = True)
Runtime for running instances in a Modal Sandbox.
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
59 60 61 62 63 64 65 66 67 68 69 | |
test_spec
instance-attribute
test_spec = test_spec
sandbox
instance-attribute
sandbox = self._get_sandbox(timeout)
verbose
instance-attribute
verbose = verbose
write_file
write_file(file_path: str, content: str)
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
119 120 | |
exec
exec(command: str) -> tuple[str, int]
Execute a command in the sandbox.
Returns:
| Type | Description |
|---|---|
tuple[str, int]
|
tuple[str, int]: Sandbox output and return code. |
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
__exit__
__exit__(exc_type, exc_val, exc_tb)
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
get_instance_image
staticmethod
get_instance_image(test_spec: TestSpec) -> Image
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
get_log_dir
get_log_dir(pred: dict, run_id: str, instance_id: str) -> Path
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
223 224 225 226 227 | |
run_instance_modal
run_instance_modal(test_spec: TestSpec, pred: dict, run_id: str, timeout: int | None = None) -> TestOutput
Run a single instance with the given prediction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_spec
|
TestSpec
|
TestSpec instance |
required |
pred
|
dict
|
Prediction w/ model_name_or_path, model_patch, instance_id |
required |
run_id
|
str
|
Run ID |
required |
timeout
|
int
|
Timeout for running tests |
None
|
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
run_instances_modal
run_instances_modal(predictions: dict, instances: list, full_dataset: list, run_id: str, timeout: int)
Run all instances for the given predictions on Modal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
dict
|
Predictions dict generated by the model |
required |
instances
|
list
|
List of instances |
required |
run_id
|
str
|
Run ID |
required |
timeout
|
int
|
Timeout for running tests |
required |
Source code in swebench/harness/modal_eval/run_evaluation_modal.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | |
run_evaluation_modal_entrypoint
STDIO_RATE_LIMIT_BYTES_PER_SEC
module-attribute
STDIO_RATE_LIMIT_BYTES_PER_SEC = 64 * 1024 // 2
parser
module-attribute
parser = argparse.ArgumentParser(description='Execute a shell command and stream output')
exec
async
exec(command: str) -> int
Source code in swebench/harness/modal_eval/run_evaluation_modal_entrypoint.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
main
async
main(command: str)
Source code in swebench/harness/modal_eval/run_evaluation_modal_entrypoint.py
111 112 113 | |
utils
validate_modal_credentials
validate_modal_credentials()
Validate that Modal credentials exist by checking for ~/.modal.toml file. Raises an exception if credentials are not configured.
Source code in swebench/harness/modal_eval/utils.py
4 5 6 7 8 9 10 11 12 13 14 | |
remove_containers
parser
module-attribute
parser = ArgumentParser(description=__doc__)
main
main(instance_ids=None, predictions_path=None, run_id=None)
Source code in swebench/harness/remove_containers.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
reporting
make_run_report
make_run_report(predictions: dict, full_dataset: list, run_id: str, client: Optional[DockerClient] = None) -> Path
Make a final evaluation and run report of the instances that have been run. Also reports on images and containers that may still running if client is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
dict
|
Predictions dict generated by the model |
required |
full_dataset
|
list
|
List of all instances |
required |
run_id
|
str
|
Run ID |
required |
client
|
DockerClient
|
Docker client (optional) |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to report file |
Source code in swebench/harness/reporting.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
run_evaluation
GIT_APPLY_CMDS
module-attribute
GIT_APPLY_CMDS = ['git apply --verbose', 'git apply --verbose --3way', 'git apply --verbose --reject', 'patch --batch --forward --fuzz=5 -p1 -i']
DOCKER_CLIENT_TIMEOUT
module-attribute
DOCKER_CLIENT_TIMEOUT = int(os.environ.get('SWEBENCH_DOCKER_TIMEOUT', '1800'))
DOCKER_CLIENT_POOL_SIZE
module-attribute
DOCKER_CLIENT_POOL_SIZE = int(os.environ.get('SWEBENCH_DOCKER_POOL_SIZE', '128'))
parser
module-attribute
parser = ArgumentParser(description='Run evaluation harness for the given dataset and predictions.', formatter_class=ArgumentDefaultsHelpFormatter)
create_container
create_container(test_spec: TestSpec, client: DockerClient, run_id: str, logger: Logger)
Creates a container from an instance image for running evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_spec
|
TestSpec
|
Test spec with evaluation details |
required |
client
|
DockerClient
|
Docker client for creating the container |
required |
run_id
|
str
|
Run ID identifying process, used for the container name |
required |
logger
|
Logger
|
Logger to use for logging the creation process |
required |
Source code in swebench/harness/run_evaluation.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
run_instance
run_instance(test_spec: TestSpec, pred: dict, client: DockerClient, run_id: str, timeout: int | None = None, rewrite_reports: bool = False, skip_patch: bool = False, task_repo: str | None = None)
Run a single instance with the given prediction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_spec
|
TestSpec
|
TestSpec instance with pre-built image |
required |
pred
|
dict
|
Prediction w/ model_name_or_path, model_patch, instance_id |
required |
client
|
DockerClient
|
Docker client |
required |
run_id
|
str
|
Run ID |
required |
timeout
|
int
|
Timeout for running tests |
None
|
rewrite_reports
|
bool
|
True if eval run is just to reformat existing report |
False
|
skip_patch
|
bool
|
True to skip applying model patch (negative test mode) |
False
|
Source code in swebench/harness/run_evaluation.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
run_instances
run_instances(predictions: dict, instances: list, max_workers: int, run_id: str, timeout: int, rewrite_reports: bool = False, skip_patch: bool = False, task_repo: str | None = None)
Run all instances for the given predictions in parallel. Expects instances to have pre-built images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
dict
|
Predictions dict generated by the model |
required |
instances
|
list
|
List of instances with 'image' field |
required |
max_workers
|
int
|
Maximum number of workers |
required |
run_id
|
str
|
Run ID |
required |
timeout
|
int
|
Timeout for running tests |
required |
rewrite_reports
|
bool
|
True if eval run is just to reformat existing report |
False
|
Source code in swebench/harness/run_evaluation.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
write_run_metadata
write_run_metadata(run_id: str, dataset_name: str, split: str, task_repo: str | None) -> Path
Record what this run graded against.
Re-grading needs the expected tests and the log parser, which live in the
dataset, not in the run's logs. Without this a later swebench report has to
be told the dataset again, and gets it wrong silently if told the wrong one.
Source code in swebench/harness/run_evaluation.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
read_run_metadata
read_run_metadata(run_id: str) -> dict | None
What a previous run graded against, if it recorded it.
Source code in swebench/harness/run_evaluation.py
509 510 511 512 | |
load_instances
load_instances(dataset_name: str, split: str, instance_ids: list | None, task_repo: str | None) -> list
Instances come from the task repo when one is given, else from the dataset.
A dataset is already one split; a task repo holds every split at once, so the split has to be applied here or a run picks up whatever else is in the tree -- the multimodal repo would evaluate its dev and deprecated tasks alongside test.
Named ids are honoured from any split, matching select_tasks: an instance
being repaired can be run by name while it sits in an unpublished split.
Source code in swebench/harness/run_evaluation.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
get_dataset_from_preds
get_dataset_from_preds(dataset_name: str, split: str, instance_ids: list, predictions: dict, run_id: str, rewrite_reports: bool, exclude_completed: bool = True, task_repo: str | None = None)
Return only instances that have predictions and are in the dataset. If instance_ids is provided, only return instances with those IDs. If exclude_completed is True, only return instances that have not been run yet.
Source code in swebench/harness/run_evaluation.py
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
main
main(dataset_name: str, split: str, instance_ids: list, predictions_path: str, max_workers: int, open_file_limit: int, run_id: str, timeout: int, rewrite_reports: bool, modal: bool, task_repo: str | None = None)
Run evaluation harness for the given dataset and predictions.
Source code in swebench/harness/run_evaluation.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 | |
utils
EvaluationError
EvaluationError(instance_id, message, logger)
Bases: Exception
Source code in swebench/harness/utils.py
23 24 25 26 27 28 | |
super_str
instance-attribute
super_str = super().__str__()
instance_id
instance-attribute
instance_id = instance_id
log_path
instance-attribute
log_path = logger.log_file
logger
instance-attribute
logger = logger
__str__
__str__()
Source code in swebench/harness/utils.py
30 31 32 33 34 | |
get_predictions_from_file
get_predictions_from_file(predictions_path: str, dataset_name: str, split: str, task_repo: str | None = None, instance_ids: list | None = None)
Source code in swebench/harness/utils.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
run_threadpool
run_threadpool(func, payloads, max_workers)
Source code in swebench/harness/utils.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
run_sequential
run_sequential(func, args_list)
Run a function with a list of arguments sequentially
Source code in swebench/harness/utils.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
load_swebench_dataset
load_swebench_dataset(name='SWE-bench/SWE-bench', split='test', instance_ids=None) -> list[SWEbenchInstance]
Load SWE-bench dataset from Hugging Face Datasets or local .json/.jsonl file
Source code in swebench/harness/utils.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
str2bool
str2bool(v)
Minor helper function to convert string to boolean
Source code in swebench/harness/utils.py
190 191 192 193 194 195 196 197 198 199 200 201 | |
optional_str
optional_str(value: str) -> str | None
Convert special string values to None, otherwise return the string as-is.
Source code in swebench/harness/utils.py
204 205 206 207 208 209 210 | |
parse_eval_script
parse_eval_script(eval_script: str) -> list[str]
Parse an eval.sh script into a command list (strip shebang + set flags).
Source code in swebench/harness/utils.py
213 214 215 216 217 218 219 | |
record_test_exit_code
record_test_exit_code(eval_script_list: list[str]) -> list[str]
Make the eval script record the test command's own exit status.
Eval scripts end with a git checkout that resets the test files, and run
under set -uxo pipefail without -e, so the script's exit status is the
reset's, not the tests'. Capturing $? immediately after the test command
and echoing it after the end marker keeps the value out of the parsed region.
Source code in swebench/harness/utils.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
make_test_spec
make_test_spec(instance: dict) -> TestSpec
Build a TestSpec from a dataset instance.
The instance dict must contain: instance_id, image, repo, version, FAIL_TO_PASS, PASS_TO_PASS, log_parser, eval_type, eval_script.
Source code in swebench/harness/utils.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |