Set test cache config
MEMBER
>  why a cache dir per test function does not work?

Probably because we end up with multiple `datasets_module` in the python path. This breaks the import of all the datasets/metrics modules.
If you want to use one modules cache per test, you may need remove the `datasets_module` that was added to the python path during the test.
Indeed if the module cache hasn't been initialized, then it's added to the python path by calling `init_dynamic_modules`:

https://github.com/huggingface/datasets/blob/ba76012a19193a35053b9e20243ff40c2b4204ab/src/datasets/load.py#L291-L291
2021-04-15T13:33:18Z
https://github.com/huggingface/datasets/pull/2223#issuecomment-820425596
https://api.github.com/repos/huggingface/datasets/issues/2223
MDEyOklzc3VlQ29tbWVudDgyMDQyNTU5Ng==
https://api.github.com/repos/huggingface/datasets/issues/comments/820425596/reactions
2021-04-15T13:33:18Z
https://api.github.com/repos/huggingface/datasets/issues/comments/820425596
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
MEMBER
@lhoestq, for the moment, this PR avoids populating the `~/.cache` dir during training, which is already an improvement, isn't it?
2021-04-15T17:56:51Z
https://github.com/huggingface/datasets/pull/2223#issuecomment-820621714
https://api.github.com/repos/huggingface/datasets/issues/2223
MDEyOklzc3VlQ29tbWVudDgyMDYyMTcxNA==
https://api.github.com/repos/huggingface/datasets/issues/comments/820621714/reactions
2021-04-15T17:56:51Z
https://api.github.com/repos/huggingface/datasets/issues/comments/820621714
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
MEMBER
Yes we can merge it this way if you're fine with it !
This is a good improvement
2021-04-15T17:58:09Z
https://github.com/huggingface/datasets/pull/2223#issuecomment-820622496
https://api.github.com/repos/huggingface/datasets/issues/2223
MDEyOklzc3VlQ29tbWVudDgyMDYyMjQ5Ng==
https://api.github.com/repos/huggingface/datasets/issues/comments/820622496/reactions
2021-04-15T17:58:50Z
https://api.github.com/repos/huggingface/datasets/issues/comments/820622496
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
MEMBER
I will eventually try to implement a `cache_dir` per test function in another PR, but I think I should first fix some side effects in tests: each test function should be atomic and able to have its own `cache_dir` without being affected by the `cache_dir` set in other test functions.
2021-04-15T18:14:26Z
https://github.com/huggingface/datasets/pull/2223#issuecomment-820632476
https://api.github.com/repos/huggingface/datasets/issues/2223
MDEyOklzc3VlQ29tbWVudDgyMDYzMjQ3Ng==
https://api.github.com/repos/huggingface/datasets/issues/comments/820632476/reactions
2021-04-15T18:14:26Z
https://api.github.com/repos/huggingface/datasets/issues/comments/820632476
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
MEMBER
Yes this would be ideal !
2021-04-15T18:15:25Z
https://github.com/huggingface/datasets/pull/2223#issuecomment-820633353
https://api.github.com/repos/huggingface/datasets/issues/2223
MDEyOklzc3VlQ29tbWVudDgyMDYzMzM1Mw==
https://api.github.com/repos/huggingface/datasets/issues/comments/820633353/reactions
2021-04-15T18:15:25Z
https://api.github.com/repos/huggingface/datasets/issues/comments/820633353
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
Currently, running the tests populates the default cache directory `"~/.cache"`.

This PR monkey-patches the config to set the cache directory within the temporary test directory, avoiding side effects.