Skip to content

Commit

Permalink
Remove extra period in task BigCodeBench/16
Browse files Browse the repository at this point in the history
  • Loading branch information
hvaara committed Sep 1, 2024
1 parent aa74075 commit db8200e
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tools/fix_020.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from datasets import load_dataset, Dataset, DatasetDict
from huggingface_hub import HfApi

import json
import copy

BIGCODEBENCH_HF = "bigcode/bigcodebench"
BIGCODEBENCH_HARD_HF = "bigcode/bigcodebench-hard"
BIGCODEBENCH_VERSION = "v0.1.0_hf"
BIGCODEBENCH_UPDATE = "bigcode/bcb_update"
BIGCODEBENCH_NEW_VERSION = "v0.1.1" # TODO(hvaara): [DO NOT MERGE] Figure out which version we're targeting


def map_ds(sample):

if sample["task_id"] in ["BigCodeBench/16"]:
for k in sample.keys():
sample[k] = sample[k].replace(
"No logs found to backup.", "No logs found to backup"
)

return sample


if __name__ == "__main__":
api = HfApi()
ds_dict = load_dataset(BIGCODEBENCH_HF)
hard_ds_dict = load_dataset(BIGCODEBENCH_HARD_HF)
ds = ds_dict[BIGCODEBENCH_VERSION]
hard_ds = hard_ds_dict[BIGCODEBENCH_VERSION]
function_id = [16]

new_ds = ds.map(map_ds)
new_ds.to_json("BigCodeBench.jsonl")
ds_dict[BIGCODEBENCH_NEW_VERSION] = new_ds
ds_dict.push_to_hub(BIGCODEBENCH_HF)

new_hard_ds = hard_ds.map(map_ds)
new_hard_ds.to_json("BigCodeBench-Hard.jsonl")
hard_ds_dict[BIGCODEBENCH_NEW_VERSION] = new_hard_ds
hard_ds_dict.push_to_hub(BIGCODEBENCH_HARD_HF)

for i in function_id:
old_sample = ds.select([i])
new_sample = new_ds.select([i])
old_sample.to_json("old.jsonl")
new_sample.to_json("new.jsonl")
api.upload_file(
path_or_fileobj="old.jsonl",
path_in_repo=f"{i}/old.jsonl",
repo_id=BIGCODEBENCH_UPDATE,
# repo_type="dataset"
)
api.upload_file(
path_or_fileobj="new.jsonl",
path_in_repo=f"{i}/new.jsonl",
repo_id=BIGCODEBENCH_UPDATE,
# repo_type="dataset"
)

0 comments on commit db8200e

Please sign in to comment.