[Windows] Fix Access Denied when using os.rename()
{'login': 'DougTrajano', 'id': 8703022, 'node_id': 'MDQ6VXNlcjg3MDMwMjI=', 'avatar_url': 'https://avatars.githubusercontent.com/u/8703022?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/DougTrajano', 'html_url': 'https://github.com/DougTrajano', 'followers_url': 'https://api.github.com/users/DougTrajano/followers', 'following_url': 'https://api.github.com/users/DougTrajano/following{/other_user}', 'gists_url': 'https://api.github.com/users/DougTrajano/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/DougTrajano/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/DougTrajano/subscriptions', 'organizations_url': 'https://api.github.com/users/DougTrajano/orgs', 'repos_url': 'https://api.github.com/users/DougTrajano/repos', 'events_url': 'https://api.github.com/users/DougTrajano/events{/privacy}', 'received_events_url': 'https://api.github.com/users/DougTrajano/received_events', 'type': 'User', 'site_admin': False}
[]
[]
Cool thank you ! Maybe we can just replace `os.rename` by `shutil.move` instead ? > Cool thank you ! Maybe we can just replace `os.rename` by `shutil.move` instead ?

Yes, I think that could be a better solution, but I didn't test it in Linux (e.g. Ubuntu) to guarantee that `os.rename()` could be completely replaced by `shutil.move()`. AFAIK `shutil.move` does call `os.rename` first before doing extra work to make it work on windows, so this is should be a safe safe change for linux ;) > AFAIK `shutil.move` does call `os.rename` first before doing extra work to make it work on windows, so this is should be a safe safe change for linux ;)

alright, let me change the PR then. The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_4825). All of your documentation changes will be reflected on that endpoint. Hi @lhoestq looks like one of the tests failed, but is not related to this change, do I need to do something from my side?
In this PR, we are including an additional step when `os.rename()` raises a PermissionError.

Basically, we will use `shutil.move()` on the temp files.

Fix #2937 
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/4825/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}
{'url': 'https://api.github.com/repos/huggingface/datasets/pulls/4825', 'html_url': 'https://github.com/huggingface/datasets/pull/4825', 'diff_url': 'https://github.com/huggingface/datasets/pull/4825.diff', 'patch_url': 'https://github.com/huggingface/datasets/pull/4825.patch', 'merged_at': '2022-08-24T13:09:07Z'}