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

Internally process the request kwargs to optimize caching #208

Open
malmans2 opened this issue Sep 29, 2023 · 3 comments · May be fixed by #228
Open

Internally process the request kwargs to optimize caching #208

malmans2 opened this issue Sep 29, 2023 · 3 comments · May be fixed by #228
Labels
enhancement New feature or request

Comments

@malmans2
Copy link
Contributor

malmans2 commented Sep 29, 2023

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

The following snippet triggers 2 requests from the CDS, although the only difference in the requests is the order of the variables requested.

import earthkit.data
from earthkit.data import settings

settings.auto_save_settings = False
settings.set("cache-policy", "temporary")

request_kwargs = {
    "product_type": "reanalysis",
    "area": [50, -10, 40, 10],  # N,W,S,E
    "grid": [2, 2],
    "date": "2012-05-10",
    "time": "12:00",
}
for reverse in (True, False):
    earthkit.data.from_source(
        "cds",
        "reanalysis-era5-single-levels",
        variable=sorted(["2t", "msl"], reverse=reverse),
        **request_kwargs
    )

Describe the solution you'd like

Internally process the request kwargs to optimize caching.
For example, sort lists (all but area/grid), squeeze single element lists (or do the opposite), change types when possible, ...

Describe alternatives you've considered

No response

Additional context

No response

Organisation

B-Open / CADS-EQC

@malmans2 malmans2 added the enhancement New feature or request label Sep 29, 2023
@sandorkertesz
Copy link
Collaborator

Internally process the request kwargs to optimize caching. For example, sort lists (all but area/grid), squeeze single element lists (or do the opposite), change types when possible, ...

Should not all these be implemented in the cdsapi itself?

@malmans2
Copy link
Contributor Author

malmans2 commented Oct 6, 2023

I don't think cdsapi uses any local cache, does it?

I'd expect that earthkit uses the CDS request dictionary to construct the keys/hashes of its own cache items.
When keys/hashes are available in the cache database (i.e., a cds file is already available in the cache), I'd expect that earthkit doesn't use cdsapi at all.

But maybe I misunderstood how earthkit cache works.

@sandorkertesz
Copy link
Collaborator

I am sorry but I thought that "sort lists (all but area/grid), squeeze single element lists (or do the opposite), change types when possible, ..." are not about caching.

@malmans2 malmans2 linked a pull request Oct 13, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants