cdsapi icon indicating copy to clipboard operation
cdsapi copied to clipboard

New version for CDS-Beta doesn't accept "None" in the retrieval request options

Open fragkoul opened this issue 1 year ago • 0 comments

What happened?

With the previous version we could set options that are not always needed (like 'pressure_level' and 'leadtime_month') to "None". This was really helpful as it allowed us to build versatile functions. This no longer works for version 0.7.1.

As an example, this request works:

c = cdsapi.Client()
c.retrieve('seasonal-original-single-levels',{
'originating_centre':'ecmwf', 
'system':'51', 'variable':'2m_temperature', 
'year':'2024', 
'month':'07', 
'day':'01', 
'leadtime_hour':['12','24','36','48']
}, 'myfile.grib')

while if we add the 'pressure_level' option and set it None:

c = cdsapi.Client()
c.retrieve('seasonal-original-single-levels',{
'originating_centre':'ecmwf', 
'system':'51', 'variable':'2m_temperature', 
'pressure_level':None, 
'year':'2024', 
'month':'07', 
'day':'01', 
'leadtime_hour':['12','24','36','48']
}, 'myfile.grib')

we get the error (only in the new version):

cads_api_client.processing.ProcessingFailedError: The job has failed.
MARS has returned an error, please check your selection.
Request submitted to the MARS server:
[{'step': ['12', '24', '36', '48'], 'origin': 'ecmf', 'pressure_level': None, 'system': '51', 'param': '167', 'time': ['all'], 'type': ['fc'], 'class': ['c3'], 'expect': ['any'], 'expver': ['1'], 'method': ['1'], 'number': ['all'], 'stream': ['mmsf'], 'levtype': ['sfc'], 'database': 'ecmwf', 'date': ['2024-07-01']}]
Full error message:
mars - ERROR  - 20240824.144957 - Ambiguous parameter: pressure_level could be PRODUCT or PROCESS
The job failed with: MarsRuntimeError

In the previous version, if we wanted to retrieve seasonal forecasts on pressure levels ('seasonal-original-pressure-levels') or monthly fields ('seasonal-monthly-single-levels'), we could use the same code and just change the "unused" parameters from None to whatever value.

What are the steps to reproduce the bug?

See examples above

Version

0.7.1

Platform (OS and architecture)

macOS 14.5

Relevant log output

No response

Accompanying data

No response

Organisation

No response

fragkoul avatar Aug 24 '24 18:08 fragkoul