Fix #213: handle PermissionError and update tarfile extraction #232
+40
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @ageron,
This PR fixes the PermissionError reported in issue #213, which occurs when the Jupyter environment (specifically within Docker or restricted Linux/Windows directories) lacks write permissions to create the datasets folder.
Changes and Improvements:
Graceful Error Handling: Wrapped the directory creation and download logic in a try-except block. Instead of a crash, the user now receives a clear instruction on how to resolve the permission issue.
Python 3.12+ Compatibility: Added filter='data' to tarfile.extractall(). This resolves the DeprecationWarning regarding the change in default extraction behavior in future Python versions, making the notebook more future-proof.
Verified Robustness: * Simulated permission denials on Windows using icacls to ensure the exception is caught correctly.
Verified the "Success Path" to ensure data is still downloaded and loaded correctly when permissions are available.
Ran local tests using pytest to validate both scenarios.