ANTsPyNet icon indicating copy to clipboard operation
ANTsPyNet copied to clipboard

Environment variable for antsxnet_cache_directory

Open cookpa opened this issue 3 years ago • 3 comments

The default cache directory of "~/.keras/ANTsXNet" is troublesome for Singularity users because singularity has to run as the user calling singularity, so users either have to mount their own home directory or ensure every call to get_antsxnet_data or get_pretrained_network specifies antsxnet_cache_directory (with an absolute path) at run time.

I've tried using TF_CACHE_DIR and KERAS_HOME, but they don't work with the tensorflow.keras.utils.get_file function.

So I was thinking of having a variable ANTSXNET_CACHE_DIR, so that data / network downloads would go to

antsxnet_cache_directory if defined in the function call

else

os.environ['ANTSXNET_CACHE_DIR'] if defined

else

~/.keras/ANTsXNet (current default).

Happy to make a PR for this, but wanted to check in first @stnava @ntustison (+anyone else with an opinion)

cookpa avatar Mar 18 '22 16:03 cookpa

We'd also have to port this over to ANTsRNet but this sounds like a really good idea. In the interest of simplification, what would you think about just removing the variable antsxnet_cache_directory in favor of the the environmental variable with the default still being ~/.keras/ANTsXNet/?

ntustison avatar Mar 18 '22 17:03 ntustison

That's fine with me if you don't mind a break in backwards compatibility

cookpa avatar Mar 18 '22 20:03 cookpa

Yeah, let's do that. Thanks @cookpa

ntustison avatar Mar 18 '22 22:03 ntustison