cdsapi icon indicating copy to clipboard operation
cdsapi copied to clipboard

Invalid variable name results in confusing MultiAdaptorNoDataError

Open robmarkcole opened this issue 3 months ago • 0 comments

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

Example below:

import cdsapi

dataset = "reanalysis-era5-land-monthly-means"
request = {
    "product_type": ["monthly_averaged_reanalysis"],
    "variable": ["tp"], # total_precipitation
    "year": ["2025"],
    "month": ["07"],
    "time": ["00:00"],
    "data_format": "netcdf",
    "download_format": "unarchived",
    "area": "global"
}

client = cdsapi.Client()
client.retrieve(dataset, request).download()

Raises error:

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
Cell In[11], [line 2](vscode-notebook-cell:?execution_count=11&line=2)
      1 client = cdsapi.Client()
----> [2](vscode-notebook-cell:?execution_count=11&line=2) client.retrieve(dataset, request).download()

File ~/gitlab/climate-data-store/.venv/lib/python3.11/site-packages/ecmwf/datastores/legacy_client.py:167, in LegacyClient.retrieve(self, name, request, target)
    165 submitted: datastores.Remote | datastores.Results
    166 if self.wait_until_complete:
--> [167](https://file+.vscode-resource.vscode-cdn.net/Users/robin.cole/gitlab/climate-data-store/~/gitlab/climate-data-store/.venv/lib/python3.11/site-packages/ecmwf/datastores/legacy_client.py:167)     submitted = self.client.submit_and_wait_on_results(
    168         collection_id=name,
    169         request=request,
    170     )
    171 else:
    172     submitted = self.client.submit(
    173         collection_id=name,
    174         request=request,
    175     )

File ~/gitlab/climate-data-store/.venv/lib/python3.11/site-packages/ecmwf/datastores/client.py:414, in Client.submit_and_wait_on_results(self, collection_id, request)
    398 def submit_and_wait_on_results(
    399     self, collection_id: str, request: dict[str, Any]
    400 ) -> datastores.Results:
    401     """Submit a request and wait for the results to be ready.
    402 
...
    100 response.raise_for_status()

HTTPError: 400 Client Error: Bad Request for url: https://cds.climate.copernicus.eu/api/retrieve/v1/jobs/7e7c72fc-2191-4cd6-86f0-18fa957435d2/results
The job has failed
The job failed with: MultiAdaptorNoDataError

Describe the solution you'd like

Suggest a more informative error description, or the library could handle validation of variables

Describe alternatives you've considered

No response

Additional context

No response

Organisation

No response

robmarkcole avatar Sep 16 '25 12:09 robmarkcole