-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigs.py
More file actions
136 lines (110 loc) · 7.84 KB
/
Copy pathconfigs.py
File metadata and controls
136 lines (110 loc) · 7.84 KB
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
import os
class Configs:
def __init__(self, project_name: str, llm_name: str, quality_level: str = 'L1', prepare_workspace: bool=True):
self.project_name = project_name
self.root_dir = os.path.dirname(os.path.realpath(__file__))
self.quality_level = quality_level
assert quality_level in ('L1', 'L2', 'L3')
if llm_name == 'deepseek-v3.1':
self.openai_key = 'DeeSeekAPIKey' # deepseek
self.openai_base_url = 'https://api.deepseek.com'
else:
self.openai_key = 'xxxx' # for GPT
self.openai_base_url = 'xxxx'
# repo_name allows mini/variant projects to reuse an existing project's source repo
self.repo_name = {
'spark_mini': 'spark',
}.get(project_name, project_name)
self.common_project_dir_no_test_file = f'{self.root_dir}/data/repos/repos_removing_test'
self.common_project_path_no_test_file = f'{self.common_project_dir_no_test_file}/{self.repo_name}'
self.project_dir = f'{self.root_dir}/data/repos/repos_with_test'
self.project_with_test_workspace = None
if prepare_workspace:
self.prepare_workspace()
# model configs
assert llm_name in ['gpt-o4-mini', 'deepseek-v3.1']
self.llm_name = llm_name
# dataset relevant paths
if quality_level != 'L1':
self.coverage_human_labeled_dir = f'{self.root_dir}/data/collected_coverages_{quality_level}'
q = f'{quality_level}/'
else:
self.coverage_human_labeled_dir = f'{self.root_dir}/data/collected_coverages'
q = ''
self.test_desc_dataset_path = f'{self.root_dir}/data/test_desc_dataset/{project_name}.json'
self.fact_set_dir = f'{self.root_dir}/data/fact_set/{project_name}'
self.dataset_with_generalization_path = f'{self.root_dir}/data/dataset/{project_name}.json'
# stage-1 relevent paths
self.generated_exam_save_path = f'{self.root_dir}/data/examination/{q}{llm_name}/{project_name}_exam.json'
self.generated_exam_answer_save_path = f'{self.root_dir}/data/examination/{q}{llm_name}/{project_name}_answer.json'
# stage-2 relevant paths
self.scenario_template_save_path = f'{self.root_dir}/data/generalization/{q}{llm_name}/template_{project_name}.json'
self.scenario_instances_save_path = f'{self.root_dir}/data/generalization/{q}{llm_name}/instances_{project_name}.json'
# stage-3 relevant paths
self.generated_test_case_save_path = f'{self.root_dir}/data/generated_test_cases/{q}{llm_name}/{project_name}.json'
self.generation_message_log_save_path = f'{self.root_dir}/data/generation_message_log/{q}{llm_name}/{project_name}.json'
self.test_case_run_log_dir = f'{self.root_dir}/data/test_case_run_log/{q}{llm_name}/{project_name}'
self.test_case_log_and_coverage_save_path = f'{self.root_dir}/data/generated_test_cases_log_coverage/{q}{llm_name}/{self.project_name}.json'
self.knowledge_base_dir = f'{self.root_dir}/data/knowledge_base/{project_name}'
self.knowledge_base_method_path = f'{self.root_dir}/data/knowledge_base/{project_name}/method_def.json'
self.knowledge_base_method_index_path = f'{self.root_dir}/data/knowledge_base/{project_name}/method_def_index.pt'
self.knowledge_base_field_path = f'{self.root_dir}/data/knowledge_base/{project_name}/field_def.json'
self.knowledge_base_field_index_path = f'{self.root_dir}/data/knowledge_base/{project_name}/field_def_index.pt'
# configurations about program element paths
self.skip_class_files = True
self.collected_paths_dir = f'{self.root_dir}/data/collected_paths/{project_name}'
self.collected_paths_focal2method_path = f'{self.collected_paths_dir}/focal_to_method.json'
self.collected_paths_focal2field_path = f'{self.collected_paths_dir}/focal_to_field.json'
self.collected_path_dataset_path = f'{self.collected_paths_dir}/dataset.json'
# ablation study
self.ablate_scenario_template_save_path = f'{self.root_dir}/data/ablate/{llm_name}/template/template_{project_name}.json'
self.ablate_scenario_instances_save_path = f'{self.root_dir}/data/ablate/{llm_name}/instances/instances_{project_name}.json'
self.ablate_generated_tests_save_path = f'{self.root_dir}/data/ablate/{llm_name}/tests/generated_tests_{project_name}.json'
# evaluation on buggy focal methods
self.buggy_fm_data_raw = f'{self.root_dir}/data/evaluation_on_buggy_fm/dataset_buggy_focal_method/{project_name}_partial_passed.json'
self.buggy_fm_data_organized = f'{self.root_dir}/data/evaluation_on_buggy_fm/dataset_buggy_focal_method/{project_name}_organized.json'
self.buggy_generated_exam_save_path = f'{self.root_dir}/data/evaluation_on_buggy_fm/examination/{llm_name}/{project_name}_exam.json'
self.buggy_generated_exam_answer_save_path = f'{self.root_dir}/data/evaluation_on_buggy_fm/examination/{llm_name}/{project_name}_answer.json'
self.buggy_scenario_template_save_path = f'{self.root_dir}/data/evaluation_on_buggy_fm/generalization/{llm_name}/template_{project_name}.json'
self.buggy_scenario_instances_save_path = f'{self.root_dir}/data/evaluation_on_buggy_fm/generalization/{llm_name}/instances_{project_name}.json'
self.buggy_adjusted_scenario_instances_save_path = f'{self.root_dir}/data/evaluation_on_buggy_fm/generalization/{llm_name}/instances_{project_name}_adjusted.json'
self.buggy_generated_test_case_save_path = f'{self.root_dir}/data/evaluation_on_buggy_fm/generated_test_cases/{llm_name}/{project_name}.json'
# project url used for system prompt
self.project_url = {
"itext-java": 'https://github.com/itext/itext-java',
"hutool": 'https://github.com/chinabugotech/hutool',
"yavi": 'https://github.com/making/yavi',
"lambda": 'https://github.com/palatable/lambda',
"truth": 'https://github.com/google/truth',
"cron-utils": 'https://github.com/jmrozanec/cron-utils',
"imglib": 'https://github.com/nackily/imglib',
"ofdrw": 'https://github.com/ofdrw/ofdrw',
"RocketMQC": 'https://github.com/ProgrammerAnthony/RocketMQC',
"blade": 'https://github.com/lets-blade/blade',
"spark": 'https://github.com/perwendel/spark',
"spark_mini": 'https://github.com/perwendel/spark',
"awesome-algorithm": 'https://github.com/codeartx/awesome-algorithm',
"jInstagram": 'https://github.com/sachin-handiekar/jInstagram'
}[project_name]
def prepare_workspace(self):
# prepare workspace w/o test files for the project
idx = 0
while True:
self.project_dir_no_test_file = f'{self.common_project_dir_no_test_file}/workspace_{idx}'
self.project_path_no_test_file = f'{self.project_dir_no_test_file}/{self.project_name}'
if not os.path.exists(self.project_path_no_test_file):
os.makedirs(self.project_dir_no_test_file, exist_ok=True)
os.system(f'cp -r {self.common_project_path_no_test_file} {self.project_path_no_test_file}')
break
idx += 1
# prepare workspace with test files for the project (evaluation purpose)
idx = 0
while True:
project_dir_with_test_file = f'{self.project_dir}/workspace_{idx}'
project_path_with_test_file = f'{project_dir_with_test_file}/{self.project_name}'
if not os.path.exists(project_path_with_test_file):
os.makedirs(project_dir_with_test_file, exist_ok=True)
os.system(f'cp -r {self.project_dir}/{self.repo_name} {project_path_with_test_file}')
self.project_with_test_workspace = project_dir_with_test_file
break
idx += 1