Fix TestCommand to move dataset_infos instead of copying
MEMBER
All the datasets that are loaded normally with `load_dataset`, if `dataset_infos.json` exists, have this file in the importable directory. So it's fine if we copy the file instead of moving it but it's not a big deal.

Any reason to prefer moving it rather than copying it ?
2022-02-04T15:32:35Z
https://github.com/huggingface/datasets/pull/3681#issuecomment-1030096731
https://api.github.com/repos/huggingface/datasets/issues/3681
IC_kwDODunzps49Zgdb
https://api.github.com/repos/huggingface/datasets/issues/comments/1030096731/reactions
2022-02-04T15:32:35Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1030096731
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
@lvwerra reported than when generating the `dataset_infos.json` for multiple dataset directories containing only JSONL files, subsequent `dataset_infos.json` files contained all previous directories as configs:
- First generate metadata for dataset in dir `dir1`: dataset_infos.json contains one config for `dir1`
- Then generate metadata for dataset in dir `dir2`: dataset_infos.json contains 2 configs, for `dir1` and `dir2`

The reason is that all dataset_infos.json files are first created in the same dir (the one containing the json builder) and then **copied** to the user dir.

Subsequent calls of TestCommand don't replace the dataset_infos.json already present in the dir of the json builder, but append to it.

MAYBE: we should just move for this use case, and copy for the other use cases? See this use case here:
- #3680
2022-02-04T15:49:50Z
https://github.com/huggingface/datasets/pull/3681#issuecomment-1030111780
https://api.github.com/repos/huggingface/datasets/issues/3681
IC_kwDODunzps49ZkIk
https://api.github.com/repos/huggingface/datasets/issues/comments/1030111780/reactions
2022-02-04T15:53:40Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1030111780
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
@lhoestq aren't you mentioning the case in the else clause?
```python
else:  # in case of a remote dataset
    dataset_dir = None
```

In that case `dataset_infos.json` is not copied: `dataset_dir = None`
2022-02-04T15:58:21Z
https://github.com/huggingface/datasets/pull/3681#issuecomment-1030120076
https://api.github.com/repos/huggingface/datasets/issues/3681
IC_kwDODunzps49ZmKM
https://api.github.com/repos/huggingface/datasets/issues/comments/1030120076/reactions
2022-02-04T15:58:21Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1030120076
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
When using the JSON loader, calling `get_imported_module_dir()` returns a path inside the pip installed packages, so we shouldn't write files in it anyway, and the dataset_infos.json file should be written directly in the user's directory instead (some users don't have write access to the pip installed packages for example).

Maybe the packaged modules like `json` should override `_save_infos` to save them in the user's directory instead of next to the builder's script. What do you think ?
2022-02-04T18:46:08Z
https://github.com/huggingface/datasets/pull/3681#issuecomment-1030255861
https://api.github.com/repos/huggingface/datasets/issues/3681
IC_kwDODunzps49aHT1
https://api.github.com/repos/huggingface/datasets/issues/comments/1030255861/reactions
2022-02-04T18:46:08Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1030255861
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
Anyway as a hotfix we can just add an exception for the `json` builder for now, if the issue has to be fixed soon
2022-02-04T18:47:16Z
https://github.com/huggingface/datasets/pull/3681#issuecomment-1030256626
https://api.github.com/repos/huggingface/datasets/issues/3681
IC_kwDODunzps49aHfy
https://api.github.com/repos/huggingface/datasets/issues/comments/1030256626/reactions
2022-02-04T18:47:16Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1030256626
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'm closing this PR.
2023-09-24T09:59:55Z
https://github.com/huggingface/datasets/pull/3681#issuecomment-1732535343
https://api.github.com/repos/huggingface/datasets/issues/3681
IC_kwDODunzps5nRGQv
https://api.github.com/repos/huggingface/datasets/issues/comments/1732535343/reactions
2023-09-24T09:59:55Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1732535343
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
Why do we copy instead of moving the file?

CC: @lhoestq @lvwerra 