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

ek.data.from_source, No longer supports the CDS since the update to the split infrastructure CDS. #499

Open
enyfeo opened this issue Oct 28, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@enyfeo
Copy link

enyfeo commented Oct 28, 2024

Is your feature request related to a problem? Please describe.

Since the update to the CDS, the CDS is no longer available as a source in the from_source function.

Additionally the EWDS, ECDS and the ADS will need to be supported.
The key has changed format for the User Key for the CDS User so this needs to be taken into account.

Describe the solution you'd like

add EWDS and other CDS Infrastructures to the possible list of from_source.

Describe alternatives you've considered

Using the cdsapi

Additional context

No response

Organisation

ECMWF

@enyfeo enyfeo added the enhancement New feature or request label Oct 28, 2024
@sandorkertesz
Copy link
Collaborator

@enyfeo, please can you me an example that shows how you want to access the CDS? What earthkit-data and cdsapi version are you using?

Not sure about the comment related to changed format for the User Key. earthkit-data normally does not have anything to do with it since the credentials are loaded by cdsapi that performs the retrieval under the hood.

@sandorkertesz sandorkertesz self-assigned this Oct 30, 2024
@spmvoss
Copy link

spmvoss commented Nov 1, 2024

Not sure about the comment related to changed format for the User Key. earthkit-data normally does not have anything to do with it since the credentials are loaded by cdsapi that performs the retrieval under the hood.

I think they are referring to the scenario where the user has neither the environment variables set nor a credentials file. In this case, earth kit provides a prompt to provide the URL and the key. However, the regex fails as the key format is now different. Coincidentally, the api how-to page url has also changed from https://cds.climate.copernicus.eu/api-how-to to https://cds.climate.copernicus.eu/how-to-api so that should also be updated in the prompt text.
This is the related announcement.

See below error:

An API key is needed to access this dataset. Please visit
https://cds.climate.copernicus.eu/ to register or sign-in
then visit https://cds.climate.copernicus.eu/api-how-to to retrieve you API key.

You can store the credentials in ~/.cdsapirc or in the file
pointed by the CDSAPI_RC environment variable. If you follow
the instructions below ~/.cdsapirc will be automatically created
for you.
Alternatively, you can use the CDSAPI_URL and CDSAPI_KEY environment variables to specify the credentials.
API url: https://cds.climate.copernicus.eu/api
API key:
Traceback (most recent call last):
File "./ccri/era5.py", line 10, in
ds = earthkit.data.from_source("cds",
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/init.py", line 150, in from_source
src = get_source(name, *args, **kwargs)
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/init.py", line 131, in call
source = klass(*args, **kwargs)
File ".venv/lib/python3.10/site-packages/earthkit/data/core/init.py", line 22, in call
obj.init(*args, **kwargs)
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/cds.py", line 121, in init
self.client() # Trigger password prompt before threading
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/cds.py", line 173, in client
return client(self.prompt)
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/cds.py", line 80, in client
prompt.check()
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/prompt.py", line 174, in check
self.ask_user_and_save()
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/prompt.py", line 191, in ask_user_and_save
input = self.ask_user()
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/prompt.py", line 188, in ask_user
return self.validate(prompt.ask_user())
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/prompt.py", line 108, in ask_user
value = validate(value)
File ".venv/lib/python3.10/site-packages/earthkit/data/sources/prompt.py", line 66, in call
assert re.fullmatch(self.pattern, value), (self.pattern, value)
AssertionError: ('\d+:[\-0-9a-f]+', 'my-redacted-api-key')

@sandorkertesz
Copy link
Collaborator

@spmvoss, thank you for the explanation. This will be fixed. In the meantime you can still turn off the prompt for the cds source by specifying the prompt=False kwarg in from_source()

@sandorkertesz
Copy link
Collaborator

See #504

The EWDS and ECDS sources will be added to the next major release 0.11.0.

@enyfeo
Copy link
Author

enyfeo commented Nov 1, 2024 via email

@sandorkertesz
Copy link
Collaborator

Hi Chris,
Good to hear it works now. Nevertheless, there were issues, which are now fixed in #504. It was released as0.10.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants