Add cache dir for in-memory datasets
COLLABORATOR
Yes, having `cache_dir` as an attribute looks cleaner.




2021-05-11T12:56:03Z
https://github.com/huggingface/datasets/pull/2329#issuecomment-838425568
https://api.github.com/repos/huggingface/datasets/issues/2329
MDEyOklzc3VlQ29tbWVudDgzODQyNTU2OA==
https://api.github.com/repos/huggingface/datasets/issues/comments/838425568/reactions
2021-05-11T12:56:03Z
https://api.github.com/repos/huggingface/datasets/issues/comments/838425568
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
NONE
Good job! Looking forward to this new feature! 🥂
2021-05-17T06:41:32Z
https://github.com/huggingface/datasets/pull/2329#issuecomment-842046466
https://api.github.com/repos/huggingface/datasets/issues/2329
MDEyOklzc3VlQ29tbWVudDg0MjA0NjQ2Ng==
https://api.github.com/repos/huggingface/datasets/issues/comments/842046466/reactions
2021-05-17T06:41:32Z
https://api.github.com/repos/huggingface/datasets/issues/comments/842046466
https://avatars.githubusercontent.com/u/6883957?v=4
https://api.github.com/users/mymusise/events{/privacy}
https://api.github.com/users/mymusise/followers
https://api.github.com/users/mymusise/following{/other_user}
https://api.github.com/users/mymusise/gists{/gist_id}
https://github.com/mymusise
mymusise
MDQ6VXNlcjY4ODM5NTc=
https://api.github.com/users/mymusise/orgs
https://api.github.com/users/mymusise/received_events
https://api.github.com/users/mymusise/repos
https://api.github.com/users/mymusise/starred{/owner}{/repo}
https://api.github.com/users/mymusise/subscriptions
User
https://api.github.com/users/mymusise
public
COLLABORATOR
@lhoestq Sorry for the late reply. Yes, I'll start working on tests. Thanks for the detailed explanation of the current issues with caching (like the idea of adding the `use_caching` parameter to `load_dataset`) 
2021-05-25T17:19:58Z
https://github.com/huggingface/datasets/pull/2329#issuecomment-848063913
https://api.github.com/repos/huggingface/datasets/issues/2329
MDEyOklzc3VlQ29tbWVudDg0ODA2MzkxMw==
https://api.github.com/repos/huggingface/datasets/issues/comments/848063913/reactions
2021-05-25T17:19:58Z
https://api.github.com/repos/huggingface/datasets/issues/comments/848063913
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
COLLABORATOR
@lhoestq Sure. I'm aware this is a high-priority issue to some extent, so feel free to take over.

Few suggestions I have:
* there is a slight difference between setting `use_caching` to `False` in `load_dataset` and disabling caching globally with `set_caching_enabled(False)` because the former will never execute the following code (`self._cache_dir` is always `False`): 
https://github.com/huggingface/datasets/blob/c231abdb174987419bbde3360b5b9d6a4672c736/src/datasets/arrow_dataset.py#L1807-L1824
, so I'm just checking whether this is intended (if yes, maybe the docs should mention this) or not?
* think we should add the `use_caching` parameter to every method that has the `keep_in_memory` (and `in_memory` 😃) parameter in its signature for better consistency, but I say let's address this in a separate PR. IMO we need one more PR that will deal exclusively with consistency in the caching logic.
2021-06-08T01:29:39Z
https://github.com/huggingface/datasets/pull/2329#issuecomment-856370334
https://api.github.com/repos/huggingface/datasets/issues/2329
MDEyOklzc3VlQ29tbWVudDg1NjM3MDMzNA==
https://api.github.com/repos/huggingface/datasets/issues/comments/856370334/reactions
2021-06-08T01:29:39Z
https://api.github.com/repos/huggingface/datasets/issues/comments/856370334
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
MEMBER
Hi @mariosasko 
We discussed internally and we think that this feature might not be the direction we're doing to take for these reasons:

- it goes against our simple definition of caching: on-disk == uses file cache, and in-memory == nothing is written to disk. I think it adds too much complexity just for a minimal flexibility addition
- there are a few edge cases which are really confusing:
    - map on an in memory dataset with a cache_file_name specified by the user -> should the result be in memory or from disk ?
    - it would require a special cache directory just for in memory datasets, since they don’t have a preferred directory for caching
- it would break a lot of stuff and would require to rewrite significant parts of the core code and the tests


So in the end we're probably going to close this PR.
Let me know what you think, and thank you anyway for your help on this !
2021-06-08T18:01:16Z
https://github.com/huggingface/datasets/pull/2329#issuecomment-856978252
https://api.github.com/repos/huggingface/datasets/issues/2329
MDEyOklzc3VlQ29tbWVudDg1Njk3ODI1Mg==
https://api.github.com/repos/huggingface/datasets/issues/comments/856978252/reactions
2021-06-08T18:01:16Z
https://api.github.com/repos/huggingface/datasets/issues/comments/856978252
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
COLLABORATOR
Hi,

I'm fine with that. I agree this adds too much complexity. Btw, I like the idea of reverting default in-memory for small datasets that led to this PR.
2021-06-08T18:28:46Z
https://github.com/huggingface/datasets/pull/2329#issuecomment-856997801
https://api.github.com/repos/huggingface/datasets/issues/2329
MDEyOklzc3VlQ29tbWVudDg1Njk5NzgwMQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/856997801/reactions
2021-06-08T18:28:46Z
https://api.github.com/repos/huggingface/datasets/issues/comments/856997801
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
MEMBER
Superseded by #2460 (to close issue #2458).
2021-06-08T19:06:45Z
https://github.com/huggingface/datasets/pull/2329#issuecomment-857023995
https://api.github.com/repos/huggingface/datasets/issues/2329
MDEyOklzc3VlQ29tbWVudDg1NzAyMzk5NQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/857023995/reactions
2021-06-08T19:06:45Z
https://api.github.com/repos/huggingface/datasets/issues/comments/857023995
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
Adds the cache dir attribute to DatasetInfo as suggested by @lhoestq.

Should fix #2322 