-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fail gracefully if cache directory is read only #430
Conversation
…'t write to cache directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with the changes - made a very minor comment.
To check my understanding: this means that if latest_versions.conf
is read-only, users won't be able to update atlases (and will need e.g. a sysadmin to do it for them)?
with open(cache_path, "w") as f_out: | ||
config_obj.write(f_out) | ||
except OSError as e: | ||
print(f"Could not update the latest atlas versions cache: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if this used logging.warning
or logging.info
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure, the rest of the file uses print
statements to inform user of error cases so I didn't want to break from what's currently being used. Does brainglobe-atlasapi
keep a log on disk somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like earlier in the utils.py
file it sets the logging level for urllib3
but if print
is used elsewhere, maybe let's stick to print
here and open an issue to make logging consistent... (atlasgen
uses loguru
)
I think so, if the
Thinking more about it, is it worth getting rid of the printed warning? |
What are the warnings? Users may not care too much that their directory is read only, but they may if they're not able to get the latest version of an atlas. |
Currently, they only get a warning that their directory is read only, nothing to do with being able to get the latest version of an atlas. If they're connected to the internet the atlas version check is done by comparing to the data fetched from GIN not the cached |
If nothing else, it's a useful piece of logs for us, so I suggest keeping. |
Before submitting a pull request (PR), please read the contributing guide.
Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)
Description
What is this PR
Why is this PR needed?
If a user doesn't have write permission to the
.brainglobe
directory, instantiating an atlas will cause a crash unlesscheck_latest=False
is set.What does this PR do?
Gracefully handles permission denied errors when caching the
latest_versions.conf
file. The user will be informed of the error without crashes.References
brainglobe/brainglobe-heatmap#65
brainglobe/brainrender#395
Please reference any existing issues/PRs that relate to this PR.
How has this PR been tested?
Tested locally by changing the permissions for the
last_versions.conf
file.New test added to check error is printed once, and
utils.conf_from_url
runs even if.brainglobe
has read only permissions.Is this a breaking change?
No.
Does this PR require an update to the documentation?
No.
Checklist: