-
Notifications
You must be signed in to change notification settings - Fork 303
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
Default cache directory should respect XDG Base Directory Specification. #1456
Comments
Pyspectral is already using appdirs and if we are going to follow any specification it needs to work/apply to all three of the major platforms we support (linux, mac, windows) so I vote for appdirs if we have to. Side question: Satpy also defaults to putting output files (from Scene.save_dataset/s) in the current directory. Do you see us needing to follow a different standard practice/specification for this as well? |
I'm not aware of an existing standard for where to put output files. I personally have a small utility def plotdir(basedir=None, create=False):
pd = (pathlib.Path(
(basedir or
os.environ.get("PLOT_BASEDIR") or
"/media/nas/x21308/plots_and_maps/")) /
datetime.datetime.now().strftime("%Y/%m/%d"))
if create:
pd.mkdir(parents=True, exist_ok=True)
return pd that I pass when I'm creating plots or maps, but that's a bit too specific for my personal taste (in particular the sorting into the current date) to suit as a generic default. For logfiles I deliberately don't use |
Although appdirs isn't necessarily a standard, it at least tries to use semi-standard directories for things. I agree that the log thing is a little odd (issue on their github?). For output files, I think the current directory is "good enough" for now and pretty expected by most people. |
I realized this today, Satpy doesn't cache anything by default does it? All of the uses of |
Nothing is cached by default in |
Feature Request
Is your feature request related to a problem? Please describe.
As a default cache directory, satpy uses
'.'
:satpy/satpy/resample.py
Lines 426 to 432 in a18b6e2
This is potentially problematic: the current directory may be unwriteable or otherwise a poor choice to create files.
Describe the solution you'd like
I would like for satpy to respect the XDG Base Directory Specification and use the
$XDG_CACHE_HOME
directory (probably$XDG_CACHE_HOME/satpy
) as a cache directory if none is specified.Describe any changes to existing user workflow
Users who have
$XDG_CACHE_HOME
set will find cache files where they previously didn't.Simply taking
$XDG_CACHE_HOME
will not introduce additional dependencies. Satpy could consider to useappdirs.user_cache_dir("satpy")
using theappdirs
package. This solution would addappdirs
as a satpy dependency.Additional context
I can pass
cache_dir=appdirs.user_cache_dir("satpy")
explicitly to.resample(...)
The text was updated successfully, but these errors were encountered: