Fix heurigen-data download
Browse files- heurigen-data.py +17 -9
heurigen-data.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import glob
|
| 2 |
import os
|
| 3 |
import datasets
|
|
|
|
| 4 |
|
| 5 |
_CITATION = """TO BE ADDED."""
|
| 6 |
|
|
@@ -9,6 +10,8 @@ HeuriGen is a collection of combinatorial-optimization problems
|
|
| 9 |
for benchmarking heuristic-program generation by LLMs.
|
| 10 |
"""
|
| 11 |
|
|
|
|
|
|
|
| 12 |
|
| 13 |
class HeuriGenConfig(datasets.BuilderConfig):
|
| 14 |
def __init__(self, **kwargs):
|
|
@@ -52,12 +55,17 @@ class HeuriGen(datasets.GeneratorBasedBuilder):
|
|
| 52 |
}
|
| 53 |
),
|
| 54 |
supervised_keys=None,
|
| 55 |
-
homepage="https://huggingface.co/datasets/
|
| 56 |
)
|
| 57 |
|
| 58 |
def _split_generators(self, dl_manager):
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
# helper – returns all files in that split, including files in subfolders but not the folders themselves
|
| 63 |
def files(pattern):
|
|
@@ -67,20 +75,20 @@ class HeuriGen(datasets.GeneratorBasedBuilder):
|
|
| 67 |
all_files.append(os.path.abspath(path))
|
| 68 |
return sorted(all_files)
|
| 69 |
|
|
|
|
|
|
|
|
|
|
| 70 |
return [
|
| 71 |
datasets.SplitGenerator(
|
| 72 |
name=datasets.Split.TRAIN,
|
| 73 |
-
gen_kwargs={"files":
|
| 74 |
),
|
| 75 |
datasets.SplitGenerator(
|
| 76 |
name=datasets.Split.TEST,
|
| 77 |
-
gen_kwargs={"files":
|
| 78 |
),
|
| 79 |
]
|
| 80 |
|
| 81 |
def _generate_examples(self, files):
|
| 82 |
for idx, path in enumerate(files):
|
| 83 |
-
|
| 84 |
-
# read the first line, just for avoiding lazy loading
|
| 85 |
-
first_line = f.readline()
|
| 86 |
-
yield idx, {"file_path": path}
|
|
|
|
| 1 |
import glob
|
| 2 |
import os
|
| 3 |
import datasets
|
| 4 |
+
from huggingface_hub import snapshot_download
|
| 5 |
|
| 6 |
_CITATION = """TO BE ADDED."""
|
| 7 |
|
|
|
|
| 10 |
for benchmarking heuristic-program generation by LLMs.
|
| 11 |
"""
|
| 12 |
|
| 13 |
+
REPO_ID = "heurigen/heurigen-data"
|
| 14 |
+
|
| 15 |
|
| 16 |
class HeuriGenConfig(datasets.BuilderConfig):
|
| 17 |
def __init__(self, **kwargs):
|
|
|
|
| 55 |
}
|
| 56 |
),
|
| 57 |
supervised_keys=None,
|
| 58 |
+
homepage=f"https://huggingface.co/datasets/{REPO_ID}",
|
| 59 |
)
|
| 60 |
|
| 61 |
def _split_generators(self, dl_manager):
|
| 62 |
+
local_root = snapshot_download(
|
| 63 |
+
repo_id=REPO_ID,
|
| 64 |
+
repo_type="dataset",
|
| 65 |
+
revision="main",
|
| 66 |
+
allow_patterns=[f"{self.config.name}/**"],
|
| 67 |
+
)
|
| 68 |
+
base = os.path.join(local_root, self.config.name)
|
| 69 |
|
| 70 |
# helper – returns all files in that split, including files in subfolders but not the folders themselves
|
| 71 |
def files(pattern):
|
|
|
|
| 75 |
all_files.append(os.path.abspath(path))
|
| 76 |
return sorted(all_files)
|
| 77 |
|
| 78 |
+
demo_paths = files("demo/**/*")
|
| 79 |
+
eval_paths = files("eval/**/*")
|
| 80 |
+
|
| 81 |
return [
|
| 82 |
datasets.SplitGenerator(
|
| 83 |
name=datasets.Split.TRAIN,
|
| 84 |
+
gen_kwargs={"files": demo_paths},
|
| 85 |
),
|
| 86 |
datasets.SplitGenerator(
|
| 87 |
name=datasets.Split.TEST,
|
| 88 |
+
gen_kwargs={"files": eval_paths},
|
| 89 |
),
|
| 90 |
]
|
| 91 |
|
| 92 |
def _generate_examples(self, files):
|
| 93 |
for idx, path in enumerate(files):
|
| 94 |
+
yield idx, {"file_path": path}
|
|
|
|
|
|
|
|
|