---
language:
- en
license: other
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: mixed
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: 48686593
num_examples: 2322
- name: test
num_bytes: 20967.524978466838
num_examples: 1
- name: train
num_bytes: 48665625.47502153
num_examples: 2321
download_size: 34517193
dataset_size: 97373186.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: 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-*
- config_name: mixed
data_files:
- split: dev
path: mixed/dev-*
- split: test
path: mixed/test-*
- split: train
path: mixed/train-*
- config_name: py
data_files:
- split: dev
path: py/dev-*
- split: test
path: py/test-*
- split: train
path: py/train-*
---
# LCA (Bug Localization)
This is the data for **Bug Localization** benchmark as part of LCA.
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 required components for evaluation of **Bug Localization** approaches in real project-level large-scale data collected from GitHub, including:
* Bug issue description
* Repository content with 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 approach development
The collected dataset was carefully filtered, inhances with useful metrics and, what is more, manually labeled, which assures the data quality and provides a golden subset of good examples for evaluation.
The following sections will describe the utilities around the dataset as well as detailed dataset content description.
## 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", "mixed"]
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="paths.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 by [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 data point for running baseline along with the content of the repository in the state the bug is reproducible (aka `base_sha` commit of the pull request which resloves the bug issue). \
All source code for working with the GitHub history of repositories (commits, diffs, etc.) are available in [`git_utils.py`](https://github.com/JetBrains-Research/lca-baselines/blob/main/bug_localization/src/utils/git_utils.py) as so as example of baselines, utilizes this dataset.
## Dataset Structure
TODO: some overall structure or repo
### Bug localization data
Each data point contains main subset of field as well as additional metrics calculated upon them.
The core fields are:
| **Field** | **Description** |
|:------------------:|:----------------------------------------:|
| `repo_owner` | Bug issue repository owner. |
| `repo_name` | Bug issue repository name. |
| `issue_url` | GitHub link to issue
`https://github.com/{repo_owner}/{repo_name}/issues/{issue_id}`. |
| `pull_url` | GitHub link to pull request
`https://github.com/{repo_owner}/{repo_name}/pull/{pull_id}`. |
| `comment_url` | GitHub link to comment with pull request to issue reference
`https://github.com/{repo_owner}/{repo_name}/pull/{pull_id}#issuecomment-{comment_id}`. |
| `issue_title` | Issue title. |
| `issue_body` | Issue body. |
| `base_sha` | Pull request base SHA. |
| `head_sha` | Pull request head SHA. |
| `diff_url` | Pull request diff link between base and head SHA
`https://github.com/{repo_owner}/{repo_name}/compare/{base_sha}...{head_sha}`. |
| `diff` | Pull request diff content. |
| `pull_create_at` | Data of pull request creation in format yyyy-mm-ddThh:mm:ssZ. |
| `repo_stars` | Number of repo stars. |
| `changed_files`* | List of 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` | Licenses assigned to the repository. |
\* Excluding test files that do not contain bug causes, rather changed in order to add test for proving that bug is gone.
The metrics fields are:
| **Field** | **Description** |
|:------------------:|:----------------------------------------:|
| `changed_files_exts` | Dict from changed files extension to 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 repository. |
| `repo_tokens_count`* | Number of tokens** in files in repository. |
| `repo_lines_count`* | Number of lines in files in repository. |
| `repo_files_without_tests_count`* | Number of files in repository. |
| `changed_symbols_count`* | Number of symbols in changed lines in diff. |
| `changed_tokens_count`* | Number of tokens** in 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 issue body. |
| `issue_words_count`* | Number of words in issue body (separated by space symbols). |
| `issue_tokens_count`* | Number of tokens** in issue body. |
| `issue_lines_count`* | Number of text lines in issue body (separated by \\n). |
| `issue_links_count` | Number of links (\[...\](...)) presented in issue body. |
| `issue_code_blocks_count` | Number of code blocks (\`\`\`...\`\`\`) presented in issue body. |
\* Excluding test files that do not contain bug causes, rather changed in order to add test for proving that bug is gone. \
\*\* Using GPT-4 tokenizer via ticktoken.
### Repos data
TODO: describe repos data as `.zip` archives with list of repos metadata