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

Improve error message when invalid parameter is used #21

Open
sandorkertesz opened this issue May 16, 2024 · 0 comments
Open

Improve error message when invalid parameter is used #21

sandorkertesz opened this issue May 16, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@sandorkertesz
Copy link

sandorkertesz commented May 16, 2024

What happened?

When I use this retrieval:

import ecmwfapi

req = {
    "accumulation_period": 3,
    "grid": "O96",
    "levtype": "sfc",
    "param": ["cp", "sf", "tp"],
    "type": "fc",
    "date": 20240514,
    "number": 0,
    "stream": "scda",
    "time": 1800,
    "step": [3, 6],
}

service = ecmwfapi.ECMWFService("mars")
service.execute(req, "_res.grib")

it fails with:

File /opt/homebrew/Caskroom/miniforge/base/envs/dev_ecc/lib/python3.10/site-packages/ecmwfapi/api.py:183, in robust.<locals>.wrapped(self, *args, **kwargs)
    181 while tries > 0:
    182     try:
--> 183         return func(self, *args, **kwargs)
    184     except HTTPError as e:
    185         if self.verbose:

File /opt/homebrew/Caskroom/miniforge/base/envs/dev_ecc/lib/python3.10/site-packages/ecmwfapi/api.py:386, in Connection.call(self, url, payload, method)
    383     self.done = True
    385 if "error" in self.last:
--> 386     raise APIException("ecmwf.API error 1: %s" % (self.last["error"],))
    388 if error:
    389     raise APIException("ecmwf.API error 2: %s" % (res,))

APIException: "ecmwf.API error 1: Invalid MARS request(s): Expected end of string, found u','  (at char 32), (line:1, col:33)"

This problem actually comes from using accumulation_period, which is not a valid MARS key. Unfortunately this is very hard to figure from error message so it should be improved.

What are the steps to reproduce the bug?

See above

Version

1.6.3

Platform (OS and architecture)

Any

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF

@sandorkertesz sandorkertesz added the bug Something isn't working label May 16, 2024
@sandorkertesz sandorkertesz added enhancement New feature or request and removed bug Something isn't working labels May 16, 2024
@sandorkertesz sandorkertesz reopened this May 16, 2024
@sandorkertesz sandorkertesz changed the title Cannot retrieve data when using the accumulation_period key Improve error message when invalid parameter is used May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant