ecmwf-projects / cads-api-client

CADS API Python client for developing and testing
Apache License 2.0
2 stars 2 forks source link

Support older pythons #56

Open manfredsc opened 1 month ago

manfredsc commented 1 month ago

With the switch from CDS to CDS-Beta, the python module cads-api-client has become an operational component of the API interface, it is unconditionally needed when downloading data from CDS-Beta.

In cdsapi/api.py, there is the following code:

        if ":" in token:
            return super().__new__(cls)
        import cads_api_client.legacy_api_client
        return super().__new__(cads_api_client.legacy_api_client.LegacyApiClient)

Tokens for CDS-Beta have no colons, and therefore cads_api_client.legacy_api_client.LegacyApiClient is executed.

So far cdsapi was happily running on python 3.6. However, cads-api-client does not work with python 3.6:

[   22s]   File "/usr/lib/python3.6/site-packages/cads_api_client/catalogue.py", line 1
[   22s] SyntaxError: future feature annotations is not defined
[   22s] 
[   22s]   File "/usr/lib/python3.6/site-packages/cads_api_client/legacy_api_client.py", line 1
[   22s] SyntaxError: future feature annotations is not defined
[   22s] 
[   22s]   File "/usr/lib/python3.6/site-packages/cads_api_client/processing.py", line 95
[   22s]     if not (content := message.get("content")):
[   22s]                     ^
[   22s] SyntaxError: invalid syntax

It seems it would be not a lot of effort to make cads-api-client run on python 3.6. On some older Linux distributions, including enterprise distributions, python 3.6 is all one can get, and doing a local, private installation of the whole python stack is not really attractive.

Please keep your API code as generic as possible, cdsapi is the only possibility to do automated requests from CDS.

I also posted this request on the cdsapi project page to increase awareness. Thanks for consideration!

khufkens commented 1 month ago

I'm going to echo the generic comment.

Where the previous cdsapi was rather transparent (even without documentation) I could easily write both CDS/ADS equivalent libraries for R (https://github.com/bluegreen-labs/ecmwfr). cadsapi is however even less transparent and robust (with respect to versioning and wide support).

@manfredsc If you know the specs for the authentication (curl based) I would love to hear it.