Versioning API
swebench.versioning
constants
MAP_REPO_TO_VERSION_PATHS
module-attribute
MAP_REPO_TO_VERSION_PATHS = {'dbt-labs/dbt-core': ['core/dbt/version.py', 'core/dbt/__init__.py'], 'django/django': ['django/__init__.py'], 'huggingface/transformers': ['src/transformers/__init__.py'], 'marshmallow-code/marshmallow': ['src/marshmallow/__init__.py'], 'mwaskom/seaborn': ['seaborn/__init__.py'], 'pallets/flask': ['src/flask/__init__.py', 'flask/__init__.py'], 'psf/requests': ['requests/__version__.py', 'requests/__init__.py'], 'pyca/cryptography': ['src/cryptography/__about__.py', 'src/cryptography/__init__.py'], 'pylint-dev/astroid': ['astroid/__pkginfo__.py', 'astroid/__init__.py'], 'pylint-dev/pylint': ['pylint/__pkginfo__.py', 'pylint/__init__.py'], 'pytest-dev/pytest': ['src/_pytest/_version.py', '_pytest/_version.py'], 'pyvista/pyvista': ['pyvista/_version.py', 'pyvista/__init__.py'], 'Qiskit/qiskit': ['qiskit/VERSION.txt'], 'scikit-learn/scikit-learn': ['sklearn/__init__.py'], 'sphinx-doc/sphinx': ['sphinx/__init__.py'], 'sympy/sympy': ['sympy/release.py', 'sympy/__init__.py']}
MAP_REPO_TO_VERSION_PATTERNS
module-attribute
MAP_REPO_TO_VERSION_PATTERNS = {k: ['__version__ = [\\\'"](.*)[\\\'"]', 'VERSION = \\((.*)\\)']for k in ['dbt-labs/dbt-core', 'django/django', 'huggingface/transformers', 'marshmallow-code/marshmallow', 'mwaskom/seaborn', 'pallets/flask', 'psf/requests', 'pyca/cryptography', 'pylint-dev/astroid', 'pylint-dev/pylint', 'scikit-learn/scikit-learn', 'sphinx-doc/sphinx', 'sympy/sympy']}
SWE_BENCH_URL_RAW
module-attribute
SWE_BENCH_URL_RAW = 'https://raw.githubusercontent.com/'
get_versions
logger
module-attribute
logger = getLogger(__name__)
INSTALL_CMD
module-attribute
INSTALL_CMD = {'pytest-dev/pytest': 'pip install -e .', 'matplotlib/matplotlib': 'python -m pip install -e .', 'pydata/xarray': 'pip install -e .'}
parser
module-attribute
parser = ArgumentParser()
args
module-attribute
args = parse_args()
get_version
get_version(instance, is_build=False, path_repo=None)
Function for looking up the version of a task instance.
If is_build is True, then the version is looked up by 1. building the repo at the instance's base commit, 2. activating the conda environment, and 3. looking for the version according to a predefined list of paths.
Otherwise, the version is looked up by searching GitHub at the instance's base commit for the version according to a predefined list of paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance
|
dict
|
Instance to find version for |
required |
is_build
|
bool
|
Whether to build the repo and look for the version |
False
|
path_repo
|
str
|
Path to repo to build |
None
|
Returns: str: Version text, if found
Source code in swebench/versioning/get_versions.py
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 |
|
map_version_to_task_instances
map_version_to_task_instances(task_instances: list) -> dict
Create a map of version key to list of task instances
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_instances
|
list
|
List of task instances |
required |
Returns: dict: Map of version key to list of task instances
Source code in swebench/versioning/get_versions.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
get_versions_from_build
get_versions_from_build(data: dict)
Logic for looking up versions by building the repo at the instance's base commit and looking for the version according to repo-specific paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
Dictionary of data for building a repo for any task instance in a given list. |
required |
Source code in swebench/versioning/get_versions.py
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
get_versions_from_web
get_versions_from_web(data: dict)
Logic for looking up versions by searching GitHub at the instance's base commit and looking for the version according to repo-specific paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
Dictionary of data for searching GitHub for any task instance in a given list. |
required |
Source code in swebench/versioning/get_versions.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
merge_results
merge_results(instances_path: str, repo_prefix: str, output_dir: str = None) -> int
Helper function for merging JSON result files generated from multiple threads.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instances_path
|
str
|
Path to original task instances without versions |
required |
repo_prefix
|
str
|
Prefix of result files (repo name) |
required |
output_dir
|
str
|
Path to save merged results to |
None
|
Returns: int: Number of instances in merged results
Source code in swebench/versioning/get_versions.py
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 |
|
main
main(args)
Main function for looking up versions for task instances.
Source code in swebench/versioning/get_versions.py
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 |
|
utils
get_instances
get_instances(instance_path: str) -> list
Get task instances from given path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance_path
|
str
|
Path to task instances |
required |
Returns: task_instances (list): List of task instances
Source code in swebench/versioning/utils.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
split_instances
split_instances(input_list: list, n: int) -> list
Split a list into n approximately equal length sublists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_list
|
list
|
List to split |
required |
n
|
int
|
Number of sublists to split into |
required |
Returns: result (list): List of sublists
Source code in swebench/versioning/utils.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|