eWaterCycle/era5cli

No error message if using --land and --ensemble

Closed this issue · 4 comments

While I was changing the test for --land and --prelimbe flags, I have realized that a request for a combination of --land and --ensemble goes through and https://github.com/eWaterCycle/era5cli/blob/main/era5cli/fetch.py doesn't raise an error. Should I add it, since I'm anyway working on it?

era5cli monthly --startyear 1990 --endyear 1990 --variables total_precipitation --land --ensemble

Download request is being queued at Copernicus.
It can take some time before downloading starts, please do not kill this process in the meantime.

2022-10-24 16:14:54,411 INFO Welcome to the CDS
2022-10-24 16:14:54,411 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-era5-land-monthly-means
2022-10-24 16:14:54,784 INFO Request is queued
2022-10-24 16:14:55,954 INFO Request is running
2022-10-24 16:14:57,625 INFO Request is failed
2022-10-24 16:14:57,625 ERROR Message: no data is available within your requested subset
2022-10-24 16:14:57,625 ERROR Reason: Request returned no data
2022-10-24 16:14:57,626 ERROR Traceback (most recent call last):
2022-10-24 16:14:57,626 ERROR File "/opt/cdstoolbox/cdscompute/cdscompute/cdshandlers/services/handler.py", line 59, in handle_request
2022-10-24 16:14:57,626 ERROR result = cached(context.method, proc, context, context.args, context.kwargs)
2022-10-24 16:14:57,626 ERROR File "/opt/cdstoolbox/cdscompute/cdscompute/caching.py", line 108, in cached
2022-10-24 16:14:57,626 ERROR result = proc(context, *context.args, **context.kwargs)
2022-10-24 16:14:57,626 ERROR File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 124, in call
2022-10-24 16:14:57,626 ERROR return p(*args, **kwargs)
2022-10-24 16:14:57,626 ERROR File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 60, in call
2022-10-24 16:14:57,626 ERROR return self.proc(context, *args, **kwargs)
2022-10-24 16:14:57,626 ERROR File "/home/cds/cdsservices/services/mars/mars.py", line 47, in internal
2022-10-24 16:14:57,626 ERROR return mars(context, request, **kwargs)
2022-10-24 16:14:57,626 ERROR File "/home/cds/cdsservices/services/mars/mars.py", line 19, in mars
2022-10-24 16:14:57,626 ERROR execute_mars(context, requests)
2022-10-24 16:14:57,626 ERROR File "/home/cds/cdsservices/services/mars/execute_mars.py", line 25, in execute_mars
2022-10-24 16:14:57,626 ERROR raise NoDataException("Request returned no data", '')
2022-10-24 16:14:57,626 ERROR cdsinf.exceptions.NoDataException: Request returned no data
Traceback (most recent call last):
File "/home/acrnemr/miniconda3/envs/era5cl/bin/era5cli", line 8, in
sys.exit(main())
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/era5cli/cli.py", line 435, in main
_execute(args)
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/era5cli/cli.py", line 425, in _execute
era5.fetch(dryrun=args.dryrun)
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/era5cli/fetch.py", line 176, in fetch
self._split_variable_yr()
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/era5cli/fetch.py", line 249, in _split_variable_yr
pool.map(self._getdata, variables, years, outputfiles)
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/pathos/threading.py", line 136, in map
return _pool.map(star(f), zip(*args)) # chunksize
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/multiprocess/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/multiprocess/pool.py", line 771, in get
raise self._value
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/multiprocess/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/multiprocess/pool.py", line 48, in mapstar
return list(map(*args))
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/pathos/helpers/mp_helper.py", line 15, in
func = lambda args: f(*args)
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/era5cli/fetch.py", line 441, in _getdata
connection.retrieve(name, request, outputfile)
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/cdsapi/api.py", line 348, in retrieve
result = self._api("%s/resources/%s" % (self.url, name), request, "POST")
File "/home/acrnemr/miniconda3/envs/era5cl/lib/python3.10/site-packages/cdsapi/api.py", line 505, in _api
raise Exception(
Exception: no data is available within your requested subset. Request returned no data.

Thanks for spotting and raising this issue! I think, if it's small enough, it's fine to do it in #123. Just be careful to avoid monster PRs 👹.

And please include a link to this issue in the PR so this issue will be automatically closed when the PR is merged.

@Peter9192 @bvreede a question, where would it be better to put this error message in cli.py or fetch.py? I tried to put it into fetch.py but for some weird reason it didn't work. I'll double check my coding, but was wondering what is the policy?

I don't think there's a clear policy (we should work on that, and we will have some budget soon). For now I think it might be fine to put it in cli.py. There are some other checks there as well:

era5cli/era5cli/cli.py

Lines 381 to 384 in 2b8e449

assert args.ensemble, (
"Statistics can only be computed over an ensemble, "
"add --ensemble or remove --statistics."
)

After reviewing #123 I thought I'd pick this up in one go; see #131.

I ended up putting the error in Fetch._product_type(); this was the easiest addition that did not require a new method in cli.py, but this is definitely something that should be tackled when we address call verification (already mentioned in #85, and as @Peter9192 says, there is currently no policy or even a clear location in the code).