Preserve split type when realoding dataset
{'login': 'mariosasko', 'id': 47462742, 'node_id': 'MDQ6VXNlcjQ3NDYyNzQy', 'avatar_url': 'https://avatars.githubusercontent.com/u/47462742?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/mariosasko', 'html_url': 'https://github.com/mariosasko', 'followers_url': 'https://api.github.com/users/mariosasko/followers', 'following_url': 'https://api.github.com/users/mariosasko/following{/other_user}', 'gists_url': 'https://api.github.com/users/mariosasko/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/mariosasko/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/mariosasko/subscriptions', 'organizations_url': 'https://api.github.com/users/mariosasko/orgs', 'repos_url': 'https://api.github.com/users/mariosasko/repos', 'events_url': 'https://api.github.com/users/mariosasko/events{/privacy}', 'received_events_url': 'https://api.github.com/users/mariosasko/received_events', 'type': 'User', 'site_admin': False}
[]
[]
['Thanks for diving into this !\r\n\r\nBefore going further, I just want to make sure if using `eval` is the right solution\r\nPersonally I\'m not a big fan of `eval` since it has many security concerns. Also storing string representations of python objects in the json files is not ideal either IMO, so maybe it\'s possible to change this aspect instead.\r\n\r\nMaybe it would be better to convert the `_RelativeInstruction` to a string (or "specs") ?\r\nIt looks like `ReadInstruction.from_spec` already exists, but not the other way around.\r\nThe specs are the string representation of instructions. For example: `train+validation[:50%]`.\r\n\r\nLet me know what you think ! And thanks again, this issue has been here for a while now ^^'
 '@lhoestq Yes, before going with `eval`, I thought about this approach with the "spec". The only issue with this approach is that we have to come up with a represenation for the `rounding` arg.\r\n\r\nWhat do you think about this (maybe too verbose)?\r\n```python\r\n>>> print(ReadInstruction("train", rounding="pct1_dropremainder", from_=10, to=30).to_spec())\r\ntrain[10:30](pct1_dropremainder)'
 'Good idea !\r\n\r\nFirst we must note that the rounding is only used for percentage instructions.\r\nFor absolute instructions there\'s no rounding ambiguity.\r\n\r\nBy default the rounding is set to `closest`. For example if you have a train set of 999 examples and if you provide an instruction spec `"train[:1%]"`, you\'re going to get the first ten examples (while the `pct1_dropremainder ` rounding would return 9 examples).\r\n\r\nCurrently there\'s no way to get an instruction with a `pct1_dropremainder` rounding strategy from an instruction spec.\r\nSo we can either drop the support of `pct1_dropremainder` or define a way to use this strategy from a spec.\r\nI don\'t think dropping `pct1_dropremainder` would be a good idea since it allows to load each percent to all have the same number of examples (even the last one). Therefore I think your suggestion makes total sense and we should add a representation of this rounding strategy.\r\n\r\nI like what you suggested `train[10%:30%](pct1_dropremainder)` is fine, and it seems compatible with the regex that parses the instructions specs.'
 "@lhoestq I've made the changes as you suggested. Ready for the review."
 "@lhoestq I've added a test and addressed the comments.\r\n\r\nAdditionally, `ReadInstruction` is converted to its spec form in `builder.py` to avoid a circular import that would happen if this logic was in `arrow_reader.py`.  If you think it's better to have this logic in `arrow_reader.py`, the import can be delayed by putting it inside a function."]
{'url': 'https://api.github.com/repos/huggingface/datasets/pulls/2168', 'html_url': 'https://github.com/huggingface/datasets/pull/2168', 'diff_url': 'https://github.com/huggingface/datasets/pull/2168.diff', 'patch_url': 'https://github.com/huggingface/datasets/pull/2168.patch', 'merged_at': datetime.datetime(2021, 4, 19, 9, 8, 55)}
Fixes #2167 

Using `eval` is not ideal for security reasons (in web apps I assume), but without it the code would be much more complex IMO.

In terms of style, instead of explicitly importing a private member (`_RelativeInstruction`), we can add these imports at the top of the module:
```python
from . import arrow_reader  # gives us access to ReadInstruction and _RelativeInstruction
from . import splits # gives us access to NamedSplit
```

and then define the `eval` globals as follows:
```python
{**arrow_reader.__dict__, **splits.__dict__}
```



{'url': 'https://api.github.com/repos/huggingface/datasets/issues/2168/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}