Skip to content
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

fix cds_credentials #1034

Closed
veenstrajelmer opened this issue Oct 28, 2024 · 0 comments · Fixed by #1035
Closed

fix cds_credentials #1034

veenstrajelmer opened this issue Oct 28, 2024 · 0 comments · Fixed by #1035

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Oct 28, 2024

Failing when there is no ~/.cdsapirc file present yet:

Downloading CDS/ERA5 data requires a ECMWF API-key, copy your API-key from https://cds.climate.copernicus.eu/profile (first register, login and accept the terms). More info in https://forum.ecmwf.int/t/3743.

Warning: QtConsole does not support password mode, the text you type will be visible.
Enter your ECMWF API-key (string with dashes): aaa
Traceback (most recent call last):

  File C:\DATA\dfm_tools\dfm_tools\download.py:108 in cds_credentials
    c = cdsapi.Client()

  File ~\AppData\Local\miniforge3\envs\dfm_tools_env\Lib\site-packages\cdsapi\api.py:281 in __new__
    _, token, _ = get_url_key_verify(url, key, None)

  File ~\AppData\Local\miniforge3\envs\dfm_tools_env\Lib\site-packages\cdsapi\api.py:69 in get_url_key_verify
    raise Exception("Missing/incomplete configuration file: %s" % (dotrc))

Exception: Missing/incomplete configuration file: C:\Users\veenstra/.cdsapirc


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\AppData\Local\miniforge3\envs\dfm_tools_env\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\data\dfm_tools\dfm_tools\untitled0.py:10
    dfmt.download.cds_credentials()

  File C:\DATA\dfm_tools\dfm_tools\download.py:119 in cds_credentials
    cds_set_credentials(cds_url, cds_apikey)

UnboundLocalError: cannot access local variable 'cds_url' where it is not associated with a value`

To reproduce

import dfm_tools as dfmt
dfmt.download.cds_credentials()

Workaround

import os
os.environ["CDSAPI_KEY"] = "put-your-apikey-here"
@veenstrajelmer veenstrajelmer linked a pull request Oct 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant