-
Notifications
You must be signed in to change notification settings - Fork 128
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
Provide a global method to set the tidal data directory #1109
Comments
Hey @omad, I've wondered about this myself... could we do both? Have it use the global environment param if it exists, but revert to the path if it doesn't (or vice versa)? Just thinking it may be easier for some users to specify the path directly rather than set up a global environmental variable. Do you have example code of loading a global var into Python? |
Perhaps something like this actually:
For backwards compatibility, we might also want to at least temporarily fall back to the global variable if a custom path is provided by Eventually, we can set the default path to None, so the global var becomes the default option. |
I'm thinking something roughly like: def model_tides(directory=None):
"""
:directory: defaults to environment variable DEA_TOOLS_TIDE_MODELS if set, or /var/share/tide_models
"""
if directory is None:
if 'DEA_TOOLS_TIDE_MODELS' in os.environ:
directory = os.environ['DEA_TOOLS_TIDE_MODELS']
else:
directory = '/var/share/tide_models'
... |
@omad That looks great, I have some planned updates to these funcs in progress, so I can easily make that change. What would we need to do to get that environment variable set in the Sandbox? |
I think this is what I'm going with:
|
The
dea_tools.coastal.model_tides()
function has adirectory
argument which defaults to/var/share/tide_models
. This works fine when running or testingdea_tools
in DEA Sandbox or inside a Docker container, but is awkward anywhere else.I don't want to overcomplicate things, but would like to do something like allowing changing this default with an Environment variable, to allow a bit more flexibility.
For example, I could create a
~/tide_models
directory in my home directory, and setDEA_TOOLS_TIDE_MODELS
to point to it.The text was updated successfully, but these errors were encountered: