TypeError when using save_to_disk in a dataset loaded with ReadInstruction split
MEMBER
Hi !
I think this has been fixed recently on `master`.
Can you try again by installing `datasets` from `master` ?
```
pip install git+https://github.com/huggingface/datasets.git
```
2021-03-30T08:32:31Z
https://github.com/huggingface/datasets/issues/2139#issuecomment-810028710
https://api.github.com/repos/huggingface/datasets/issues/2139
MDEyOklzc3VlQ29tbWVudDgxMDAyODcxMA==
https://api.github.com/repos/huggingface/datasets/issues/comments/810028710/reactions
2021-03-30T08:32:31Z
https://api.github.com/repos/huggingface/datasets/issues/comments/810028710
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
NONE
Hi!

Using that version of the code solves the issue. Thanks!
2021-03-30T09:12:52Z
https://github.com/huggingface/datasets/issues/2139#issuecomment-810056803
https://api.github.com/repos/huggingface/datasets/issues/2139
MDEyOklzc3VlQ29tbWVudDgxMDA1NjgwMw==
https://api.github.com/repos/huggingface/datasets/issues/comments/810056803/reactions
2021-03-30T09:12:52Z
https://api.github.com/repos/huggingface/datasets/issues/comments/810056803
https://avatars.githubusercontent.com/u/22480495?v=4
https://api.github.com/users/PedroMLF/events{/privacy}
https://api.github.com/users/PedroMLF/followers
https://api.github.com/users/PedroMLF/following{/other_user}
https://api.github.com/users/PedroMLF/gists{/gist_id}
https://github.com/PedroMLF
PedroMLF
MDQ6VXNlcjIyNDgwNDk1
https://api.github.com/users/PedroMLF/orgs
https://api.github.com/users/PedroMLF/received_events
https://api.github.com/users/PedroMLF/repos
https://api.github.com/users/PedroMLF/starred{/owner}{/repo}
https://api.github.com/users/PedroMLF/subscriptions
User
https://api.github.com/users/PedroMLF
public
Hi,

Loading a dataset with `load_dataset` using a split defined via `ReadInstruction` and then saving it to disk results in the following error: `TypeError: Object of type ReadInstruction is not JSON serializable`.

Here is the minimal reproducible example:

```python
from datasets import load_dataset
from datasets import ReadInstruction

data_1 = load_dataset(
    "wikiann",
    "en",
    split="validation",
)

data_1.save_to_disk("temporary_path_1")

print("Save with regular split works.")

data_2 = load_dataset(
    "wikiann",
    "en",
    split=ReadInstruction("validation", to=50, unit="%"),
)

data_2.save_to_disk("temporary_path_2")
```

and the corresponding output:

```
Reusing dataset wikiann (/xxxxx/.cache/huggingface/datasets/wikiann/en/1.1.0/0b11a6fb31eea02f38ca17610657bfba3206100685283014daceb8da291c3be9)
Save with regular split works.
Reusing dataset wikiann (/xxxxx/.cache/huggingface/datasets/wikiann/en/1.1.0/0b11a6fb31eea02f38ca17610657bfba3206100685283014daceb8da291c3be9)
Traceback (most recent call last):
  File "bug.py", line 20, in <module>
    data_2.save_to_disk("temporary_path_2")
  File "/xxxxx/lib/python3.7/site-packages/datasets/arrow_dataset.py", line 645, in save_to_disk
    json.dump(state, state_file, indent=2, sort_keys=True)
  File "/usr/lib/python3.7/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/usr/lib/python3.7/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ReadInstruction is not JSON serializable
```

Let me know if there is some misuse from my end.

Thanks in advance.
 