ecmwf-projects / cads-api-client

CADS API Python client
https://ecmwf-projects.github.io/cads-api-client/
Apache License 2.0
4 stars 3 forks source link

get_request() or get_remote() #75

Closed ti-sanjid closed 1 month ago

ti-sanjid commented 1 month ago

I am having this problem with the newer version. But it works fine with the older version (1.3.0). Can anyone help? am i doing it wrong? @mcucchi9 @malmans2

import cads_api_client

url = 'https://cds-beta.climate.copernicus.eu/api'
key_tisanjid = '45b3b45b-a89c-47c9-87bd-76249d963***' # changed it to keep it secret.

client=cads_api_client.ApiClient(key_tisanjid,url)

request_id='4224adc8-29a0-4961-ad54-e6c8f89ff2c2'
print(type(request_id))
r=client.get_request(request_id).make_remote()
reply=r.status
print(reply)
---------------------------------------------------------------------------
MissingSchema                             Traceback (most recent call last)
[<ipython-input-5-43d533076d30>](https://localhost:8080/#) in <cell line: 11>()
      9 request_id='4224adc8-29a0-4961-ad54-e6c8f89ff2c2'
     10 print(type(request_id))
---> 11 r=client.get_request(request_id).make_remote()
     12 reply=r.status
     13 print(reply)

7 frames
[/usr/local/lib/python3.10/dist-packages/requests/models.py](https://localhost:8080/#) in prepare_url(self, url, params)
    436 
    437         if not scheme:
--> 438             raise MissingSchema(
    439                 f"Invalid URL {url!r}: No scheme supplied. "
    440                 f"Perhaps you meant [https://{url}?](https://{url}/?)"

MissingSchema: Invalid URL '45b3b45b-a89c-47c9-87bd-76249d963814/retrieve/v1/jobs/4224adc8-29a0-4961-ad54-e6c8f89ff2c2': No scheme supplied. Perhaps you meant https://45b3b45b-a89c-47c9-87bd-76249d963814/retrieve/v1/jobs/4224adc8-29a0-4961-ad54-e6c8f89ff2c2?
malmans2 commented 1 month ago

Hi @ti-sanjid,

This is a breaking change in cads-api-client, sorry about that! Please note that at the moment cads-api-client is not stable.

We inverted the order of the arguments key/url to align with cdsapi. Any of the following should work:

client=cads_api_client.ApiClient(url, key_tisanjid)

client=cads_api_client.ApiClient(key=key_tisanjid, url=url)
ti-sanjid commented 1 month ago

Thanks a lot. Now it works perfectly fine.