Skip to content

Commit

Permalink
Fix decoding multi part extension (#6904)
Browse files Browse the repository at this point in the history
* fix decoding multi part extension

* also fix numpy arrays
  • Loading branch information
lhoestq authored May 17, 2024
1 parent b7d71ff commit b3f7724
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/datasets/features/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,8 @@ def encode_nested_example(schema, obj, level=0):
sub_schema = schema[0]
if obj is None:
return None
elif isinstance(obj, np.ndarray):
return encode_nested_example(schema, obj.tolist())
else:
if len(obj) > 0:
for first_elmt in obj:
Expand Down
4 changes: 2 additions & 2 deletions src/datasets/packaged_modules/webdataset/webdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def _get_pipeline_from_tar(cls, tar_path, tar_iterator):
current_example["__key__"] = example_key
current_example["__url__"] = tar_path
current_example[field_name.lower()] = f.read()
if field_name in cls.DECODERS:
current_example[field_name] = cls.DECODERS[field_name](current_example[field_name])
if field_name.split(".")[-1] in cls.DECODERS:
current_example[field_name] = cls.DECODERS[field_name.split(".")[-1]](current_example[field_name])
if current_example:
yield current_example

Expand Down

0 comments on commit b3f7724

Please sign in to comment.