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

Possible issue in client selection #112

Open
zebengberg opened this issue Aug 16, 2024 · 3 comments
Open

Possible issue in client selection #112

zebengberg opened this issue Aug 16, 2024 · 3 comments

Comments

@zebengberg
Copy link

The key for the now legacy CDS API takes the form {uid}:{api-key}. The new Beta CDS API no longer contains the {uid}: prefix. This new convention is reaffirmed here.

Is the client selection logic in Client.__new__ right? If I'm reading it correctly, the new client is chosen if ":" appears in the token, otherwise the legacy client is chosen. Should this be reversed?

@lorenzo-solcast
Copy link

+1

@LeoBreebaart
Copy link

I arrived at the same conclusion after some inexplicable errors and subsequent debugging.

Only the old CDS/ADS keys contain a :, the newer ones don't, so that's when the new Client() should be created, but instead the logic is reversed and the legacy client is chosen:

class Client(object):
    logger = logging.getLogger("cdsapi")

    def __new__(cls, url=None, key=None, *args, **kwargs):
        _, token, _ = get_url_key_verify(url, key, None)
        if ":" in token:
            return super().__new__(cls)
        import cads_api_client.legacy_api_client

        return super().__new__(cads_api_client.legacy_api_client.LegacyApiClient)

Since ECMWF is disabling the old API next week, I think it's really rather important that this gets fixed? Or am I missing something?

Basically, '+1' is what I'm saying here...

@gilcapote
Copy link

+1

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

No branches or pull requests

4 participants