Dataset fails loading
#1
by
droussis
- opened
Hi,
First of all. congratulations for the great work and thank you for releasing this dataset publicly!
I started this discussion because I am trying to load the dataset using load_dataset('PleIAs/WTO-Text'), but the data generation process stops with a CastError:
Downloading data: 100%|βββββββββββββββββ| 131/131 [00:00<00:00, 14136.41files/s]
Generating train split: 24%|β| 156709/642627 [00:12<00:41, 11634.22 examples/s]Failed to read file '/home/ubuntu/.cache/huggingface/datasets/downloads/49b31ed901efdcd70f20365c959a81ba7762959181c1414f2a1f6e40f008f0b7' with error <class 'datasets.table.CastError'>: Couldn't cast
filepath: string
file_id: string
text: string
word_count: int64
character_count: int64
root_directory: string
-- schema metadata --
pandas: '{"index_columns": [{"kind": "range", "name": null, "start": 0, "' + 972
to
{'filepath': Value(dtype='string', id=None), 'file_id': Value(dtype='string', id=None), 'text': Value(dtype='string', id=None), 'word_count': Value(dtype='int64', id=None), 'character_count': Value(dtype='int64', id=None), 'root_directory': Value(dtype='string', id=None), 'collection': Value(dtype='string', id=None)}
because column names don't match
Generating train split: 24%|β| 156709/642627 [00:12<00:39, 12257.51 examples/s]
---------------------------------------------------------------------------
CastError Traceback (most recent call last)
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/builder.py:1997, in ArrowBasedBuilder._prepare_split_single(self, gen_kwargs, fpath, file_format, max_shard_size, job_id)
1996 _time = time.time()
-> 1997 for _, table in generator:
1998 if max_shard_size is not None and writer._num_bytes > max_shard_size:
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/packaged_modules/parquet/parquet.py:93, in Parquet._generate_tables(self, files)
90 # Uncomment for debugging (will print the Arrow table size and elements)
91 # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
92 # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
---> 93 yield f"{file_idx}_{batch_idx}", self._cast_table(pa_table)
94 except ValueError as e:
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/packaged_modules/parquet/parquet.py:71, in Parquet._cast_table(self, pa_table)
68 if self.info.features is not None:
69 # more expensive cast to support nested features with keys in a different order
70 # allows str <-> int/float or str to Audio for example
---> 71 pa_table = table_cast(pa_table, self.info.features.arrow_schema)
72 return pa_table
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/table.py:2302, in table_cast(table, schema)
2301 if table.schema != schema:
-> 2302 return cast_table_to_schema(table, schema)
2303 elif table.schema.metadata != schema.metadata:
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/table.py:2256, in cast_table_to_schema(table, schema)
2255 if sorted(table.column_names) != sorted(features):
-> 2256 raise CastError(
2257 f"Couldn't cast\n{_short_str(table.schema)}\nto\n{_short_str(features)}\nbecause column names don't match",
2258 table_column_names=table.column_names,
2259 requested_column_names=list(features),
2260 )
2261 arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()]
CastError: Couldn't cast
filepath: string
file_id: string
text: string
word_count: int64
character_count: int64
root_directory: string
-- schema metadata --
pandas: '{"index_columns": [{"kind": "range", "name": null, "start": 0, "' + 972
to
{'filepath': Value(dtype='string', id=None), 'file_id': Value(dtype='string', id=None), 'text': Value(dtype='string', id=None), 'word_count': Value(dtype='int64', id=None), 'character_count': Value(dtype='int64', id=None), 'root_directory': Value(dtype='string', id=None), 'collection': Value(dtype='string', id=None)}
because column names don't match
The above exception was the direct cause of the following exception:
DatasetGenerationError Traceback (most recent call last)
Cell In[3], line 1
----> 1 ds = load_dataset('PleIAs/WTO-Text', trust_remote_code=True)
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/load.py:2616, in load_dataset(path, name, data_dir, data_files, split, cache_dir, features, download_config, download_mode, verification_mode, ignore_verifications, keep_in_memory, save_infos, revision, token, use_auth_token, task, streaming, num_proc, storage_options, trust_remote_code, **config_kwargs)
2613 return builder_instance.as_streaming_dataset(split=split)
2615 # Download and prepare data
-> 2616 builder_instance.download_and_prepare(
2617 download_config=download_config,
2618 download_mode=download_mode,
2619 verification_mode=verification_mode,
2620 num_proc=num_proc,
2621 storage_options=storage_options,
2622 )
2624 # Build dataset for splits
2625 keep_in_memory = (
2626 keep_in_memory if keep_in_memory is not None else is_small_dataset(builder_instance.info.dataset_size)
2627 )
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/builder.py:1029, in DatasetBuilder.download_and_prepare(self, output_dir, download_config, download_mode, verification_mode, ignore_verifications, try_from_hf_gcs, dl_manager, base_path, use_auth_token, file_format, max_shard_size, num_proc, storage_options, **download_and_prepare_kwargs)
1027 if num_proc is not None:
1028 prepare_split_kwargs["num_proc"] = num_proc
-> 1029 self._download_and_prepare(
1030 dl_manager=dl_manager,
1031 verification_mode=verification_mode,
1032 **prepare_split_kwargs,
1033 **download_and_prepare_kwargs,
1034 )
1035 # Sync info
1036 self.info.dataset_size = sum(split.num_bytes for split in self.info.splits.values())
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/builder.py:1124, in DatasetBuilder._download_and_prepare(self, dl_manager, verification_mode, **prepare_split_kwargs)
1120 split_dict.add(split_generator.split_info)
1122 try:
1123 # Prepare split will record examples associated to the split
-> 1124 self._prepare_split(split_generator, **prepare_split_kwargs)
1125 except OSError as e:
1126 raise OSError(
1127 "Cannot find data file. "
1128 + (self.manual_download_instructions or "")
1129 + "\nOriginal error:\n"
1130 + str(e)
1131 ) from None
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/builder.py:1884, in ArrowBasedBuilder._prepare_split(self, split_generator, file_format, num_proc, max_shard_size)
1882 job_id = 0
1883 with pbar:
-> 1884 for job_id, done, content in self._prepare_split_single(
1885 gen_kwargs=gen_kwargs, job_id=job_id, **_prepare_split_args
1886 ):
1887 if done:
1888 result = content
File ~/miniconda3/envs/transformers/lib/python3.11/site-packages/datasets/builder.py:2040, in ArrowBasedBuilder._prepare_split_single(self, gen_kwargs, fpath, file_format, max_shard_size, job_id)
2038 if isinstance(e, DatasetGenerationError):
2039 raise
-> 2040 raise DatasetGenerationError("An error occurred while generating the dataset") from e
2042 yield job_id, True, (total_num_examples, total_num_bytes, writer._features, num_shards, shard_lengths)
DatasetGenerationError: An error occurred while generating the dataset