Datasets:

Modalities:
Text
Formats:
json
ArXiv:
DOI:
Libraries:
Datasets
Dask

The indentation in the .yaml config is wrong. This leads to an "KeyError: name" when loading the Dataset via load_dataset().

The proposed changes seem to give a different error:

from datasets import load_dataset
dataset = load_dataset("allenai/paloma", revision="2482a6ade69f509af04ca4ec26e6979913e24a21")

Yields this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\load.py", line 2556, in load_dataset
    builder_instance = load_dataset_builder(
                       ^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\load.py", line 2228, in load_dataset_builder
    dataset_module = dataset_module_factory(
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\load.py", line 1879, in dataset_module_factory
    raise e1 from None
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\load.py", line 1861, in dataset_module_factory
    ).get_module()
      ^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\load.py", line 1230, in get_module
    dataset_infos = DatasetInfosDict.from_dataset_card_data(dataset_card_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\info.py", line 455, in from_dataset_card_data
    {
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\info.py", line 456, in <dictcomp>
    dataset_info_yaml_dict.get("config_name", "default"): DatasetInfo._from_yaml_dict(
                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\info.py", line 394, in _from_yaml_dict
    yaml_data["features"] = Features._from_yaml_list(yaml_data["features"])
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\features\features.py", line 1875, in _from_yaml_list
    return cls.from_dict(from_yaml_inner(yaml_data))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\features\features.py", line 1871, in from_yaml_inner
    return {name: from_yaml_inner(_feature) for name, _feature in zip(names, obj)}
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\features\features.py", line 1871, in <dictcomp>
    return {name: from_yaml_inner(_feature) for name, _feature in zip(names, obj)}
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\features\features.py", line 1860, in from_yaml_inner
    Value(obj["dtype"])
  File "<string>", line 5, in __init__
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\features\features.py", line 506, in __post_init__
    self.pa_type = string_to_arrow(self.dtype)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\anaconda3\envs\ais\Lib\site-packages\datasets\features\features.py", line 142, in string_to_arrow
    return pa.__dict__[datasets_dtype]()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: pyarrow.lib.struct() takes exactly one argument (0 given)

I had the same issue. But after spending some hours on finding the bug in the .yaml, I decided to just download the dataset and write my own dataloader around this snippet that loads the .jsonl.gz files:

def load_jsonl_gz(file_path: Path) -> list[dict[str, Any]]:
    with gzip.open(file_path, "rt") as f:
        return [json.loads(line) for line in f]

I suspect that one still needs to adapt the .yaml file or write a loader script similar to the dolma dataset: https://huggingface.co/datasets/allenai/dolma/blob/main/dolma.py.

Thanks so much pointing out this issue and sorry I didn't see this PR before (something wrong with my notification settings). I've merged your fix to the indentation in along with some other changes I made to support loading using HF datasets.

IanMagnusson changed pull request status to closed

Sign up or log in to comment