Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski committed Sep 25, 2024
1 parent 6295319 commit f8b3b25
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
10 changes: 6 additions & 4 deletions experiment/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class Benchmark:
"""Represents a benchmark."""

@classmethod
def to_yaml(cls, benchmarks: list[Benchmark], outdir: str = './', out_basename: str = ''):
def to_yaml(cls,
benchmarks: list[Benchmark],
outdir: str = './',
out_basename: str = ''):
"""Converts and saves selected fields of a benchmark to a YAML file."""
# Register the custom representer
yaml.add_representer(str, quoted_string_presenter)
Expand Down Expand Up @@ -71,8 +74,7 @@ def to_yaml(cls, benchmarks: list[Benchmark], outdir: str = './', out_basename:

if not out_basename:
out_basename = f'{benchmarks[0].project}.yaml'
with open(os.path.join(outdir, out_basename),
'w') as file:
with open(os.path.join(outdir, out_basename), 'w') as file:
yaml.dump(result, file, default_flow_style=False, width=sys.maxsize)

@classmethod
Expand All @@ -83,7 +85,7 @@ def from_yaml(cls, benchmark_path: str) -> List:
data = yaml.safe_load(benchmark_file)
if not data:
return []

project_name = data.get('project', '')
use_context = data.get('use_context', False)
use_project_examples = data.get('use_project_examples', True)
Expand Down
22 changes: 13 additions & 9 deletions run_all_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,16 @@ def _process_total_coverage_gain() -> dict[str, dict[str, Any]]:
if not os.path.isdir(os.path.join(WORK_DIR, benchmark_dir)):
continue

result_benchmark_used_path = os.path.join(os.path.join(WORK_DIR, benchmark_dir, 'benchmark.yaml'))
result_benchmark_used_path = os.path.join(
os.path.join(WORK_DIR, benchmark_dir, 'benchmark.yaml'))
if not os.path.isfile(result_benchmark_used_path):
continue

project_name = ''
ignore_patterns = []

benchmark_used = benchmarklib.Benchmark.from_yaml(result_benchmark_used_path)

benchmark_used = benchmarklib.Benchmark.from_yaml(
result_benchmark_used_path)
if not benchmark_used:
try:
project_name = '-'.join(benchmark_dir.split('-')[1:-1])
Expand All @@ -389,7 +391,7 @@ def _process_total_coverage_gain() -> dict[str, dict[str, Any]]:
project_name = benchmark_used[0].project
target_basename = os.path.basename(benchmark_used[0].target_path)
ignore_patterns = [re.compile(r'^' + re.escape(target_basename) + ':')]

coverage_reports = os.path.join(WORK_DIR, benchmark_dir,
'code-coverage-reports')
if not os.path.isdir(coverage_reports):
Expand All @@ -405,12 +407,14 @@ def _process_total_coverage_gain() -> dict[str, dict[str, Any]]:
for textcov_file in os.listdir(summary):
if textcov_file.endswith('.covreport'):
with open(os.path.join(summary, textcov_file), 'rb') as f:


textcov_dict[project_name].append(textcov.Textcov.from_file(f, ignore_function_patterns=ignore_patterns))

textcov_dict[project_name].append(
textcov.Textcov.from_file(
f, ignore_function_patterns=ignore_patterns))
elif textcov_file == 'all_cov.json':
with open(os.path.join(summary, textcov_file)) as f:
textcov_dict[project_name].append(textcov.Textcov.from_python_file(f))
textcov_dict[project_name].append(
textcov.Textcov.from_python_file(f))
elif textcov_file == 'jacoco.xml':
with open(os.path.join(summary, textcov_file)) as f:
textcov_dict[project_name].append(textcov.Textcov.from_jvm_file(f))
Expand Down
4 changes: 3 additions & 1 deletion run_one_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ def run(benchmark: Benchmark, model: models.LLM, args: argparse.Namespace,
model.cloud_setup()

# Save the benchmark in the working base
Benchmark.to_yaml([benchmark], outdir = work_dirs.base, out_basename='benchmark.yaml')
Benchmark.to_yaml([benchmark],
outdir=work_dirs.base,
out_basename='benchmark.yaml')

if args.agent:
# TODO(dongge): Make this default when it is ready.
Expand Down

0 comments on commit f8b3b25

Please sign in to comment.