test
Browse files
test
DELETED
|
@@ -1,86 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from pdb import set_trace
|
| 3 |
-
|
| 4 |
-
import datasets
|
| 5 |
-
import pandas as pd
|
| 6 |
-
|
| 7 |
-
_CITATION = """\
|
| 8 |
-
Put your dataset citation here.
|
| 9 |
-
"""
|
| 10 |
-
|
| 11 |
-
_DESCRIPTION = """\
|
| 12 |
-
Description of your dataset goes here.
|
| 13 |
-
"""
|
| 14 |
-
|
| 15 |
-
_HOMEPAGE = "https://your-dataset-homepage.com"
|
| 16 |
-
|
| 17 |
-
_LICENSE = "License information goes here."
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
class Test(datasets.GeneratorBasedBuilder):
|
| 21 |
-
"""Your dataset description"""
|
| 22 |
-
|
| 23 |
-
BUILDER_CONFIGS = [
|
| 24 |
-
datasets.BuilderConfig(
|
| 25 |
-
name="customers",
|
| 26 |
-
version=datasets.Version("1.0.0"),
|
| 27 |
-
description="This is subset A"),
|
| 28 |
-
datasets.BuilderConfig(
|
| 29 |
-
name="products",
|
| 30 |
-
version=datasets.Version("1.0.0"),
|
| 31 |
-
description="This is subset B"),
|
| 32 |
-
]
|
| 33 |
-
|
| 34 |
-
def _info(self):
|
| 35 |
-
# set_trace()
|
| 36 |
-
if self.config.name == "customers":
|
| 37 |
-
features = datasets.Features(
|
| 38 |
-
{
|
| 39 |
-
"customer_id": datasets.Value("int64"),
|
| 40 |
-
"name": datasets.Value("string"),
|
| 41 |
-
"age": datasets.Value("int64"),
|
| 42 |
-
}
|
| 43 |
-
)
|
| 44 |
-
elif self.config.name == "products":
|
| 45 |
-
features = datasets.Features(
|
| 46 |
-
{
|
| 47 |
-
"product_id": datasets.Value("int64"),
|
| 48 |
-
"name": datasets.Value("string"),
|
| 49 |
-
"price": datasets.Value("double"),
|
| 50 |
-
}
|
| 51 |
-
)
|
| 52 |
-
else:
|
| 53 |
-
raise ValueError(f"Unknown subset: {self.config.name}")
|
| 54 |
-
|
| 55 |
-
return datasets.DatasetInfo(
|
| 56 |
-
description=_DESCRIPTION,
|
| 57 |
-
features=features,
|
| 58 |
-
supervised_keys=None,
|
| 59 |
-
homepage=_HOMEPAGE,
|
| 60 |
-
license=_LICENSE,
|
| 61 |
-
citation=_CITATION,
|
| 62 |
-
)
|
| 63 |
-
|
| 64 |
-
def _split_generators(self, dl_manager):
|
| 65 |
-
set_trace()
|
| 66 |
-
data_dir = os.path.join(self.config.data_dir, self.config.name)
|
| 67 |
-
return [
|
| 68 |
-
datasets.SplitGenerator(
|
| 69 |
-
name=datasets.Split.TRAIN,
|
| 70 |
-
gen_kwargs={"filepath": os.path.join(data_dir, "train.csv")},
|
| 71 |
-
),
|
| 72 |
-
datasets.SplitGenerator(
|
| 73 |
-
name=datasets.Split.VALIDATION,
|
| 74 |
-
gen_kwargs={"filepath": os.path.join(data_dir, "val.csv")},
|
| 75 |
-
),
|
| 76 |
-
datasets.SplitGenerator(
|
| 77 |
-
name=datasets.Split.TEST,
|
| 78 |
-
gen_kwargs={"filepath": os.path.join(data_dir, "test.csv")},
|
| 79 |
-
),
|
| 80 |
-
]
|
| 81 |
-
|
| 82 |
-
def _generate_examples(self, filepath):
|
| 83 |
-
with open(filepath, encoding="utf-8") as f:
|
| 84 |
-
df = pd.read_csv(filepath, index_col=0)
|
| 85 |
-
for id_, item in df.iterrows():
|
| 86 |
-
yield id_, item.to_dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test.py
CHANGED
|
@@ -23,12 +23,10 @@ class Test(datasets.GeneratorBasedBuilder):
|
|
| 23 |
BUILDER_CONFIGS = [
|
| 24 |
datasets.BuilderConfig(
|
| 25 |
name="customers",
|
| 26 |
-
data_dir="./",
|
| 27 |
version=datasets.Version("1.0.0"),
|
| 28 |
description="This is subset A"),
|
| 29 |
datasets.BuilderConfig(
|
| 30 |
name="products",
|
| 31 |
-
data_dir="./",
|
| 32 |
version=datasets.Version("1.0.0"),
|
| 33 |
description="This is subset B"),
|
| 34 |
]
|
|
@@ -64,6 +62,7 @@ class Test(datasets.GeneratorBasedBuilder):
|
|
| 64 |
)
|
| 65 |
|
| 66 |
def _split_generators(self, dl_manager):
|
|
|
|
| 67 |
data_dir = os.path.join(self.config.data_dir, self.config.name)
|
| 68 |
return [
|
| 69 |
datasets.SplitGenerator(
|
|
|
|
| 23 |
BUILDER_CONFIGS = [
|
| 24 |
datasets.BuilderConfig(
|
| 25 |
name="customers",
|
|
|
|
| 26 |
version=datasets.Version("1.0.0"),
|
| 27 |
description="This is subset A"),
|
| 28 |
datasets.BuilderConfig(
|
| 29 |
name="products",
|
|
|
|
| 30 |
version=datasets.Version("1.0.0"),
|
| 31 |
description="This is subset B"),
|
| 32 |
]
|
|
|
|
| 62 |
)
|
| 63 |
|
| 64 |
def _split_generators(self, dl_manager):
|
| 65 |
+
set_trace()
|
| 66 |
data_dir = os.path.join(self.config.data_dir, self.config.name)
|
| 67 |
return [
|
| 68 |
datasets.SplitGenerator(
|