Handle ArrowNotImplementedError caused by try_type being Image or Audio in cast
CONTRIBUTOR
_The documentation is not available anymore as the PR was closed or merged._
2022-11-14T14:43:41Z
https://github.com/huggingface/datasets/pull/5236#issuecomment-1313864151
https://api.github.com/repos/huggingface/datasets/issues/5236
IC_kwDODunzps5OT_nX
https://api.github.com/repos/huggingface/datasets/issues/comments/1313864151/reactions
2022-11-14T16:04:29Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1313864151
https://avatars.githubusercontent.com/u/97597362?v=4
https://api.github.com/users/HuggingFaceDocBuilder/events{/privacy}
https://api.github.com/users/HuggingFaceDocBuilder/followers
https://api.github.com/users/HuggingFaceDocBuilder/following{/other_user}
https://api.github.com/users/HuggingFaceDocBuilder/gists{/gist_id}
https://github.com/HuggingFaceDocBuilder
HuggingFaceDocBuilder
U_kgDOBdE3sg
https://api.github.com/users/HuggingFaceDocBuilder/orgs
https://api.github.com/users/HuggingFaceDocBuilder/received_events
https://api.github.com/users/HuggingFaceDocBuilder/repos
https://api.github.com/users/HuggingFaceDocBuilder/starred{/owner}{/repo}
https://api.github.com/users/HuggingFaceDocBuilder/subscriptions
User
https://api.github.com/users/HuggingFaceDocBuilder
public
COLLABORATOR
> Not sure how we can have a test that is relevant for this though - feel free to add one if you have ideas

Yes, this was my reasoning for not adding a test. This change is pretty simple, so I think it's OK not to have a test for it.
2022-11-14T16:01:39Z
https://github.com/huggingface/datasets/pull/5236#issuecomment-1313984950
https://api.github.com/repos/huggingface/datasets/issues/5236
IC_kwDODunzps5OUdG2
https://api.github.com/repos/huggingface/datasets/issues/comments/1313984950/reactions
2022-11-14T16:01:39Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1313984950
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
Handle the `ArrowNotImplementedError` thrown when `try_type` is `Image` or `Audio` and the input array cannot be converted to their storage formats.

Reproducer:
```python
from datasets import Dataset
from PIL import Image
import requests

ds = Dataset.from_dict({"image": [Image.open(requests.get("https://upload.wikimedia.org/wikipedia/commons/e/e9/Felis_silvestris_silvestris_small_gradual_decrease_of_quality.png", stream=True).raw)]})
ds.map(lambda x: {"image": True}) # ArrowNotImplementedError 
```

PS: This could also be fixed by raising `TypeError` in `{Image, Audio}.cast_storage` for unsupported types instead of passing the array to `array_cast.`