Skip to content

Commit 2c97749

Browse files
committed
initial run bug run
1 parent 18a4f55 commit 2c97749

6 files changed

Lines changed: 123 additions & 21 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "cache"]
1414
path = cache
1515
url = https://github.com/ASSERT-KTH/elle-elle-aime-cache.git
16+
[submodule "benchmarks/run_bug_run"]
17+
path = benchmarks/run_bug_run
18+
url = https://github.com/giganticode/run_bug_run.git

benchmarks/run_bug_run

Submodule run_bug_run added at 5c023d6

elleelleaime/core/benchmarks/runbugrun/__init__.py

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from pathlib import Path
2+
from unidiff import PatchSet
3+
from elleelleaime.core.benchmarks.benchmark import Benchmark
4+
from elleelleaime.core.benchmarks.runbugrun.runbugrunbug import RunBugRunBug
5+
6+
import subprocess
7+
import logging
8+
9+
import pandas as pd
10+
11+
class RunBugRun(Benchmark):
12+
"""
13+
The class for representing the RunBugRun benchmark.
14+
"""
15+
16+
def __init__(
17+
self, path: Path = Path("benchmarks/run_bug_run").absolute()
18+
) -> None:
19+
super().__init__("runbugrun", path)
20+
21+
def initialize(self) -> None:
22+
"""
23+
Initializes the RunBugRun benchmark object by collecting all the bugs.
24+
"""
25+
logging.info("Initializing RunBugRun benchmark...")
26+
27+
python_path = Path(self.get_path(), 'python_valid0.jsonl')
28+
# test_path = Path(self.get_path(), 'tests_all.jsonl')
29+
30+
python_df = pd.read_json(python_path, lines=True).set_index('problem_id')
31+
32+
for prob_id, (buggy_submission_id, buggy_code, fixed_submission_id, fixed_code) \
33+
in python_df.drop_duplicates(subset=['buggy_submission_id'])[
34+
['buggy_submission_id','buggy_code', 'fixed_submission_id', 'fixed_code']
35+
].iterrows():
36+
37+
buggy_file = Path(self.path, f'{prob_id}_{buggy_submission_id}.py')
38+
fixed_file = Path(self.path, f'{prob_id}_{fixed_submission_id}.py')
39+
40+
run = subprocess.run(
41+
f"""cd {self.get_path()} &&
42+
echo '''{buggy_code}''' > {buggy_file} &&
43+
echo '''{fixed_code}''' > {fixed_file} &&
44+
diff --unified {fixed_file.relative_to(self.path)} {buggy_file.relative_to(self.path)}""",
45+
shell=True,
46+
capture_output=True
47+
)
48+
if run.returncode:
49+
print (run)
50+
51+
diff = PatchSet(run.stdout.decode("utf-8"))
52+
# Change the source file path to point to the buggy version
53+
diff[0].source_file = f"{buggy_file.relative_to(self.path)}"
54+
55+
self.add_bug(RunBugRunBug(self, f"{prob_id}_{buggy_submission_id}", str(diff)))
56+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import subprocess
2+
import shutil
3+
import os
4+
from elleelleaime.core.benchmarks.benchmark import Benchmark
5+
6+
from elleelleaime.core.benchmarks.bug import Bug
7+
from elleelleaime.core.benchmarks.test_result import TestResult
8+
from elleelleaime.core.benchmarks.compile_result import CompileResult
9+
10+
class RunBugRunBug(Bug):
11+
"""
12+
The class for representing RunBugRun bugs
13+
"""
14+
15+
def __init__(self, benchmark: Benchmark, bid: str, ground_truth: str) -> None:
16+
super().__init__(benchmark, bid, ground_truth, True)
17+
18+
def checkout(self, path: str, fixed: bool = False) -> bool:
19+
pass
20+
21+
def compile(self, path: str) -> CompileResult:
22+
pass
23+
24+
def test(self, path: str) -> TestResult:
25+
pass

setup.sh

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
11
#!/bin/bash
22

33
### Submodules
4-
git submodule init;
5-
git submodule update;
6-
7-
### Java and Maven images
8-
docker pull openjdk:11;
9-
docker pull maven:3.9.8-eclipse-temurin-8;
10-
11-
### Defects4J image
12-
cd benchmarks/defects4j;
13-
cpanm --installdeps .;
14-
./init.sh;
15-
cd ../..;
16-
17-
### GitBug-Java
18-
cd benchmarks/gitbug-java;
19-
chmod +x gitbug-java;
20-
poetry install --no-root;
21-
# Skip setup if in CI
22-
if [ -z "$CI" ]; then
23-
poetry run ./gitbug-java setup;
24-
fi
4+
# git submodule init;
5+
# git submodule update;
6+
7+
# ### Java and Maven images
8+
# docker pull openjdk:11;
9+
# docker pull maven:3.9.8-eclipse-temurin-8;
10+
11+
# ### Defects4J image
12+
# cd benchmarks/defects4j;
13+
# cpanm --installdeps .;
14+
# ./init.sh;
15+
# cd ../..;
16+
17+
# ### GitBug-Java
18+
# cd benchmarks/gitbug-java;
19+
# chmod +x gitbug-java;
20+
# poetry install --no-root;
21+
# # Skip setup if in CI
22+
# if [ -z "$CI" ]; then
23+
# poetry run ./gitbug-java setup;
24+
# fi
25+
26+
# mkdir benchmarks/run_bug_run
27+
# cd benchmarks/run_bug_run
28+
# wget https://github.com/giganticode/run_bug_run_data/releases/download/v0.0.1/python_valid0.jsonl.gz
29+
# wget https://github.com/giganticode/run_bug_run_data/releases/download/v0.0.1/tests_all.jsonl.gz
30+
31+
# gzip -d python_valid0.jsonl.gz
32+
# gzip -d tests_all.jsonl.gz
33+
# cd ../..
34+
35+
apt-get install php-cli nodejs gcc g++ default-jdk ruby python3 golang-go bubblewrap
36+
cd benchmarks/run_bug_run
37+
gem install bundler
38+
bundle install
39+
bundle exec rbugr download 0.0.1
40+
41+

0 commit comments

Comments
 (0)