Delay example data dir creation, add fallback for unwriteable $HOME #583
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.
Libpysal will try to create the data directory for storing example data at import time, even if no example objects are used.
We are running a tool in a singularity containers and have libpysal as a subdependency. We do not want to mount the user home directory in the container since this can damage reproducibility (eg python module picked up under
~/.local
etc).libpysal causes a failure due to "read-only" OSError exceptions when creating the pysal data directory during the import when running in singularity.
This PR simply moves creation of the data dir to the moment when it is actually needed because an example dataset is used.
This avoids the issue we are having mentioned above. Additionaly this also adds a fallback in
get_data_home
to use a temporary directory instead of the users home dir if that directory cannot be created. This is the same behavior as eg. the matplotlib MPLCONFIGDIR default.