Datasets:

Formats:
parquet
Languages:
English
ArXiv:
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
File size: 16,922 Bytes
69f0ad5
4f94681
 
d6a8676
69f0ad5
 
4f94681
69f0ad5
 
4f94681
56320b9
133e751
 
 
630ee32
 
133e751
 
 
 
 
 
 
 
 
 
1c13e0a
 
630ee32
 
8ca14f1
 
133e751
 
 
 
 
 
 
 
 
 
 
 
8ca14f1
 
133e751
 
 
 
630ee32
 
8ca14f1
 
133e751
 
8ca14f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
630ee32
 
8ca14f1
133e751
8ca14f1
786c08e
8ca14f1
786c08e
8ca14f1
786c08e
133e751
23ef333
e8a7eb9
8ca14f1
3e13584
 
 
b30f40b
 
 
 
 
56320b9
5c30ebc
 
 
ad8b5da
 
5c30ebc
 
 
 
 
 
 
 
 
 
dee72cf
 
ad8b5da
 
5cd404e
 
5c30ebc
 
 
 
 
 
 
 
 
 
 
 
5cd404e
 
5c30ebc
 
 
 
ad8b5da
 
5cd404e
 
5c30ebc
 
5cd404e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad8b5da
 
5cd404e
5c30ebc
5cd404e
2fd601e
5cd404e
2fd601e
5cd404e
2fd601e
5c30ebc
e986bef
f20d65d
5cd404e
2739527
 
 
a871dce
 
 
 
 
56320b9
8eaf533
 
 
e5bca67
 
8eaf533
 
 
 
 
 
 
 
 
 
99406f9
 
e5bca67
 
2341e22
 
8eaf533
 
 
 
 
 
 
 
 
 
 
 
2341e22
 
8eaf533
 
 
 
e5bca67
 
2341e22
 
8eaf533
 
2341e22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e5bca67
 
2341e22
8eaf533
2341e22
bd7d34d
2341e22
bd7d34d
2341e22
bd7d34d
8eaf533
3b3a831
a680add
2341e22
3862658
 
 
9e56f55
 
 
 
 
4f94681
7cc09af
 
 
 
 
 
 
 
133e751
 
 
 
3e13584
 
b30f40b
 
5c30ebc
 
 
 
2739527
 
a871dce
 
69f0ad5
e96494f
b2e929c
055406a
 
 
33818ef
f275a3d
3922100
055406a
 
 
 
 
f275a3d
33818ef
 
055406a
 
0263e45
 
 
 
 
da6485d
0263e45
055406a
0263e45
 
055406a
 
 
0263e45
055406a
f3e5607
055406a
0cbcd06
 
 
0c0b96e
0cbcd06
f970a6a
 
 
fbec0e3
f970a6a
 
 
 
 
0cbcd06
f970a6a
055406a
f970a6a
 
0cbcd06
0d2aa65
 
 
f970a6a
338c524
f970a6a
 
0d2aa65
 
f970a6a
0d2aa65
 
 
cf324f6
 
0d2aa65
f970a6a
0d2aa65
f970a6a
bff3956
f970a6a
0cbcd06
cf324f6
0d2aa65
 
 
f970a6a
0cbcd06
055406a
 
 
0cbcd06
 
 
055406a
8abe931
0cbcd06
 
 
055406a
 
 
 
 
f970a6a
 
055406a
 
 
 
 
 
 
3922100
 
055406a
3922100
055406a
3922100
8abe931
3922100
 
055406a
f970a6a
 
 
 
055406a
 
 
 
 
 
 
3922100
 
055406a
 
 
 
 
 
3922100
055406a
7200215
3922100
8abe931
055406a
 
 
f2bb26a
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
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
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
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
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
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
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
471
472
473
474
475
476
477
478
479
480
481
---
language:
- en
license: apache-2.0
task_categories:
- text-generation
pretty_name: LCA (Bug Localization)
tags:
- code
dataset_info:
- config_name: java
  features:
  - name: id
    dtype: int64
  - name: text_id
    dtype: string
  - name: repo_owner
    dtype: string
  - name: repo_name
    dtype: string
  - name: issue_url
    dtype: string
  - name: pull_url
    dtype: string
  - name: comment_url
    dtype: string
  - name: links_count
    dtype: int64
  - name: link_keyword
    dtype: string
  - name: issue_title
    dtype: string
  - name: issue_body
    dtype: string
  - name: base_sha
    dtype: string
  - name: head_sha
    dtype: string
  - name: diff_url
    dtype: string
  - name: diff
    dtype: string
  - name: changed_files
    dtype: string
  - name: changed_files_exts
    dtype: string
  - name: changed_files_count
    dtype: int64
  - name: java_changed_files_count
    dtype: int64
  - name: kt_changed_files_count
    dtype: int64
  - name: py_changed_files_count
    dtype: int64
  - name: code_changed_files_count
    dtype: int64
  - name: repo_symbols_count
    dtype: int64
  - name: repo_tokens_count
    dtype: int64
  - name: repo_lines_count
    dtype: int64
  - name: repo_files_without_tests_count
    dtype: int64
  - name: changed_symbols_count
    dtype: int64
  - name: changed_tokens_count
    dtype: int64
  - name: changed_lines_count
    dtype: int64
  - name: changed_files_without_tests_count
    dtype: int64
  - name: issue_symbols_count
    dtype: int64
  - name: issue_words_count
    dtype: int64
  - name: issue_tokens_count
    dtype: int64
  - name: issue_lines_count
    dtype: int64
  - name: issue_links_count
    dtype: int64
  - name: issue_code_blocks_count
    dtype: int64
  - name: pull_create_at
    dtype: timestamp[s]
  - name: repo_stars
    dtype: int64
  - name: repo_language
    dtype: string
  - name: repo_languages
    dtype: string
  - name: repo_license
    dtype: string
  splits:
  - name: dev
    num_bytes: 22190207
    num_examples: 2522
  - name: test
    num_bytes: 439932.73195876286
    num_examples: 50
  - name: train
    num_bytes: 21750274.26804124
    num_examples: 2472
  download_size: 14252663
  dataset_size: 44380414.0
- config_name: kt
  features:
  - name: id
    dtype: int64
  - name: text_id
    dtype: string
  - name: repo_owner
    dtype: string
  - name: repo_name
    dtype: string
  - name: issue_url
    dtype: string
  - name: pull_url
    dtype: string
  - name: comment_url
    dtype: string
  - name: links_count
    dtype: int64
  - name: link_keyword
    dtype: string
  - name: issue_title
    dtype: string
  - name: issue_body
    dtype: string
  - name: base_sha
    dtype: string
  - name: head_sha
    dtype: string
  - name: diff_url
    dtype: string
  - name: diff
    dtype: string
  - name: changed_files
    dtype: string
  - name: changed_files_exts
    dtype: string
  - name: changed_files_count
    dtype: int64
  - name: java_changed_files_count
    dtype: int64
  - name: kt_changed_files_count
    dtype: int64
  - name: py_changed_files_count
    dtype: int64
  - name: code_changed_files_count
    dtype: int64
  - name: repo_symbols_count
    dtype: int64
  - name: repo_tokens_count
    dtype: int64
  - name: repo_lines_count
    dtype: int64
  - name: repo_files_without_tests_count
    dtype: int64
  - name: changed_symbols_count
    dtype: int64
  - name: changed_tokens_count
    dtype: int64
  - name: changed_lines_count
    dtype: int64
  - name: changed_files_without_tests_count
    dtype: int64
  - name: issue_symbols_count
    dtype: int64
  - name: issue_words_count
    dtype: int64
  - name: issue_tokens_count
    dtype: int64
  - name: issue_lines_count
    dtype: int64
  - name: issue_links_count
    dtype: int64
  - name: issue_code_blocks_count
    dtype: int64
  - name: pull_create_at
    dtype: timestamp[s]
  - name: repo_stars
    dtype: int64
  - name: repo_language
    dtype: string
  - name: repo_languages
    dtype: string
  - name: repo_license
    dtype: string
  splits:
  - name: dev
    num_bytes: 4867349
    num_examples: 618
  - name: test
    num_bytes: 393798.4627831715
    num_examples: 50
  - name: train
    num_bytes: 4473550.537216828
    num_examples: 568
  download_size: 3298535
  dataset_size: 9734698.0
- config_name: py
  features:
  - name: id
    dtype: int64
  - name: text_id
    dtype: string
  - name: repo_owner
    dtype: string
  - name: repo_name
    dtype: string
  - name: issue_url
    dtype: string
  - name: pull_url
    dtype: string
  - name: comment_url
    dtype: string
  - name: links_count
    dtype: int64
  - name: link_keyword
    dtype: string
  - name: issue_title
    dtype: string
  - name: issue_body
    dtype: string
  - name: base_sha
    dtype: string
  - name: head_sha
    dtype: string
  - name: diff_url
    dtype: string
  - name: diff
    dtype: string
  - name: changed_files
    dtype: string
  - name: changed_files_exts
    dtype: string
  - name: changed_files_count
    dtype: int64
  - name: java_changed_files_count
    dtype: int64
  - name: kt_changed_files_count
    dtype: int64
  - name: py_changed_files_count
    dtype: int64
  - name: code_changed_files_count
    dtype: int64
  - name: repo_symbols_count
    dtype: int64
  - name: repo_tokens_count
    dtype: int64
  - name: repo_lines_count
    dtype: int64
  - name: repo_files_without_tests_count
    dtype: int64
  - name: changed_symbols_count
    dtype: int64
  - name: changed_tokens_count
    dtype: int64
  - name: changed_lines_count
    dtype: int64
  - name: changed_files_without_tests_count
    dtype: int64
  - name: issue_symbols_count
    dtype: int64
  - name: issue_words_count
    dtype: int64
  - name: issue_tokens_count
    dtype: int64
  - name: issue_lines_count
    dtype: int64
  - name: issue_links_count
    dtype: int64
  - name: issue_code_blocks_count
    dtype: int64
  - name: pull_create_at
    dtype: timestamp[s]
  - name: repo_stars
    dtype: int64
  - name: repo_language
    dtype: string
  - name: repo_languages
    dtype: string
  - name: repo_license
    dtype: string
  splits:
  - name: dev
    num_bytes: 26666884
    num_examples: 4339
  - name: test
    num_bytes: 307292.97073058307
    num_examples: 50
  - name: train
    num_bytes: 26359591.029269416
    num_examples: 4289
  download_size: 19864708
  dataset_size: 53333768.0
configs:
- config_name: py
  data_files:
  - split: dev
    path: py/dev-*
  - split: test
    path: py/test-*
  - split: train
    path: py/train-*
- config_name: java
  data_files:
  - split: dev
    path: java/dev-*
  - split: test
    path: java/test-*
  - split: train
    path: java/train-*
- config_name: kt
  data_files:
  - split: dev
    path: kt/dev-*
  - split: test
    path: kt/test-*
  - split: train
    path: kt/train-*
---
# 🏟️ Long Code Arena (Bug localization)

This is the benchmark for the Bug localization task as part of the
🏟️ [Long Code Arena benchmark](https://huggingface.co/spaces/JetBrains-Research/long-code-arena).


The bug localization problem can be formulated as follows: given an issue with a bug description and a repository snapshot in a state where the bug is reproducible, identify the files within the repository that need to be modified to address the reported bug.

The dataset provides all the required components for evaluation of bug localization approaches in real project-level large-scale data collected from GitHub, including:
* Bug issue description;
* Repositories, from which the content can be extracted at the state of the commit SHA where the bug is reproducible;
* List of files that should be changed in order to solve the bug;
* Other additional data and metrics that can be useful in developing new approaches.

All the repositories are published under permissive licenses (MIT, Apache-2.0, BSD-3-Clause, and BSD-2-Clause). The datapoints can be removed upon request.

The collected dataset was carefully filtered, enhanced with useful metrics and, what's more, manually labeled, which assures the data quality and provides a golden subset of good examples for evaluation.\
Moreover, the dataset was split into several categories, namely:

| **Category**   |  **Description**  |  **Number of data points**  |
|:------------------:|:----------------------------------------:|:----------------------------------------:|
| `py` | Only `.py` files in changes | 4,339 |
| `java` | Only `.java` files in changes | 2,522  | 
| `kt`  | Only `.kt` files in changes | 618  |

...and splits, namely:
| **Split**   |  **Description**  |
|:------------------:|:----------------------------------------:|
| `dev` | All collected datapoints |
| `test` | Manually verified datapoints |
| `train` | Rest of the datapoint from `dev` without `test` | 

The results of evaluation of various bug localization approaches can be found in the [Long Code Arena 🏟 leaderboard](https://huggingface.co/spaces/JetBrains-Research/long-code-arena).

The following sections describe the utilities around the dataset, as well as dataset content.

## How-to

* Load the data via [`load_dataset`](https://huggingface.co/docs/datasets/v2.14.3/en/package_reference/loading_methods#datasets.load_dataset):

    ```py
    from datasets import load_dataset
    
    # Select a configuration from ["py", "java", "kt"]
    configuration = "py"
    # Select a split from ["dev", "train", "test"]
    split = "dev"
    # Load data
    dataset = load_dataset("JetBrains-Research/lca-bug-localization", configuration, split=split)  
    ```

* Load repos via [`hf_hub_download`](https://huggingface.co/docs/huggingface_hub/v0.20.3/en/package_reference/file_download#huggingface_hub.hf_hub_download):
    ```py
    from huggingface_hub import hf_hub_download
    from datasets import load_dataset
    import zipfile
    import os
    
    # Load json with list of repos' .tar.gz file paths
    paths_json = load_dataset("JetBrains-Research/lca-bug-localization", data_files="repos.json")

    # Load each repo in .tar.gz format, unzip, delete archive
    repos = paths_json[configuration][0]
    repos_path = "path/to/repos"

    for i, repo_zip_path in enumerate(repos):
        repo_name = os.path.basename(repo_zip_path).split('.')[0]
        repo_path = os.path.join(repos_path, repo_name)

        # Load repo zip
        local_repo_zip_path = hf_hub_download(
            "JetBrains-Research/lca-bug-localization",
            filename=repo_zip_path,
            repo_type="dataset",
            local_dir="path/to/zips"
        )

        # Unzip repo
        with zipfile.ZipFile(local_repo_zip_path, 'r') as zip_ref:
            zip_ref.extractall(repo_path)
        os.remove(local_repo_zip_path)
   ```

* Data streaming via [HFDataSource](https://github.com/JetBrains-Research/lca-baselines/blob/main/bug_localization/src/baselines/data_sources/hf_data_source.py). 
  Besides data loading, `HFDataSource` returns a datapoint for running the baseline along with the content of the repository at the state where the bug is reproducible (aka `base_sha` commit of the pull request that resloves the bug issue). \
  All source code for working with the Git history of repositories (commits, diffs, etc.) is available in [`git_utils.py`](https://github.com/JetBrains-Research/lca-baselines/blob/main/bug_localization/src/utils/git_utils.py), as is an example of baselines, utilizing this dataset.

### Bug localization data

Each datapoint contains the main fields, as well as additional metrics calculated on them. \
The main fields are:

|     **Field**      |             **Description**              |
|:------------------:|:----------------------------------------:|
|    `repo_owner`    |            Owner of the repository with the bug issue.            |
|    `repo_name`    |            Name of the repository with the bug issue.            |
|    `issue_url`      |       GitHub link to the issue <br> `https://github.com/{repo_owner}/{repo_name}/issues/{issue_id}`.       |
|    `pull_url`      |       GitHub link to the pull request <br> `https://github.com/{repo_owner}/{repo_name}/pull/{pull_id}`.       |
|    `comment_url`      |       GitHub link to the comment with a reference from pull request to issue <br> `https://github.com/{repo_owner}/{repo_name}/pull/{pull_id}#issuecomment-{comment_id}`.       |
|    `issue_title`       | Issue title.  |
|    `issue_body`       | Issue body.  |
|    `base_sha`       | Base SHA of the pull request.  |
|    `head_sha`        | Head SHA of the pull request.  |
|    `diff_url`        | Link to the diff between the base and the head SHA <br> `https://github.com/{repo_owner}/{repo_name}/compare/{base_sha}...{head_sha}`.  |
|    `diff`       | Content of the diff.  |
|    `pull_create_at`       | Date of pull request creation in the `yyyy-mm-ddThh:mm:ssZ` format.  |
|    `repo_stars`       | Number of stars of the repo.  |
|    `changed_files`*       | List of the changed files parsed from diff.  |
|    `repo_language`       | Main programming language used in the repository.  |
|    `repo_languages`       | All programming languages used in the repository.  |
|    `repo_license`       | License assigned to the repository.  |

\* Excluding test files that do not contain bug causes, rather changed in order to add tests for proving that the bug is gone.

The metrics-related fields are:
|     **Field**      |             **Description**              |
|:------------------:|:----------------------------------------:|
|    `changed_files_exts`       | Dictionary from the extension of changed files to their count.  |
|    `changed_files_count`       | Number of changed files.  |
|    `java_changed_files_count`       | Number of changed `.java` files.  |
|    `kt_changed_files_count`       | Number of changed `.kt` files.  |
|    `py_changed_files_count`       | Number of changed `.py` files.  |
|    `code_changed_files_count`       | Number of changed `.java`, `.kt`, or `.py` files. |
|    `repo_symbols_count`*       | Number of symbols in the repository. |
|    `repo_tokens_count`*       | Number of tokens** in the files of the repository. |
|    `repo_lines_count`*       | Number of lines in the files of the repository. |
|    `repo_files_without_tests_count`*       | Number of files in the repository. |
|    `changed_symbols_count`*       | Number of symbols in the changed lines in diff. |
|    `changed_tokens_count`*       | Number of tokens** in the changed lines in diff. |
|    `changed_lines_count`*       | Number of changed lines in diff (including added and deleted). |
|    `changed_files_without_tests_count`*       | Number of files in diff. |
|    `issue_symbols_count`*       | Number of symbols in the issue body. |
|    `issue_words_count`*       | Number of words in the issue body (separated by space symbols). |
|    `issue_tokens_count`*       | Number of tokens** in the issue body. |
|    `issue_lines_count`*       | Number of text lines in the issue body (separated by `\\n`). |
|    `issue_links_count`       | Number of links (\[...\](...)) present in the issue body. |
|    `issue_code_blocks_count`       | Number of code blocks (\`\`\`...\`\`\`) present in the issue body. |
            
\* Excluding test files that do not contain bug causes, rather changed in order to add tests for proving that the bug is gone. \
\*\* Using GPT-4 tokenizer via ticktoken.
  
### Repositories data
The compressed repositories are provided in the [repos](https://huggingface.co/datasets/JetBrains-Research/lca-bug-localization/tree/main/repos) section, separately from datapoints, to provide access to the various stages of repositories, saving their initial structure, as well as to reuse their content for different datapoints connected to the same repository.
To extract the required information from repositories, each `zip` file should be unarchived. Afterwords, we recommend to use [GitPython](https://github.com/gitpython-developers/GitPython) or [PyDriller](https://github.com/ishepard/pydriller) Python libraries to navigate through the repository history and extract its content on the required commit or calculate diff. 
Most of the required utility methods are provided in our repository in the [`git_utils.py`](https://github.com/JetBrains-Research/lca-baselines/blob/main/bug_localization/src/utils/git_utils.py) file, so you may reuse them to access the required repository data.

## Citing
```
@article{bogomolov2024long,
  title={Long Code Arena: a Set of Benchmarks for Long-Context Code Models},
  author={Bogomolov, Egor and Eliseeva, Aleksandra and Galimzyanov, Timur and Glukhov, Evgeniy and Shapkin, Anton and Tigina, Maria and Golubev, Yaroslav and Kovrigin, Alexander and van Deursen, Arie and Izadi, Maliheh and Bryksin, Timofey},
  journal={arXiv preprint arXiv:2406.11612},
  year={2024}
}
```
You can find the paper [here](https://arxiv.org/abs/2406.11612).