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

Split atmospheric products by variables and time #889

Draft
wants to merge 80 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
aa7eaae
feat: first steps for split products by time
jlahovnik Aug 25, 2023
1c57dd0
feat: first steps for split products by time
jlahovnik Aug 28, 2023
72d90b4
feat: split ecmwf products by time and variable
jlahovnik Sep 1, 2023
6bde8ea
feat: download asset of ecmwf product
jlahovnik Sep 5, 2023
aa650de
feat: split ecmwf products - download + constraints
jlahovnik Sep 6, 2023
2097447
feat: only create assets for available varaibles based on constraints
jlahovnik Sep 7, 2023
932e783
test: adapt tests after changes for ecmwf products
jlahovnik Sep 8, 2023
52e7c37
refactor: avoid not available in product id in build search result
jlahovnik Sep 11, 2023
ea1928a
feat: split cop_cds products by configured intervals
jlahovnik Sep 11, 2023
ff52293
feat: one asset per variable for cop_cds products
jlahovnik Sep 12, 2023
badf0fb
feat: enhancements for splitting cop cds products
jlahovnik Sep 13, 2023
b54c956
refactor: fixes and adaptions for cds plugin + remove dummy constrain…
jlahovnik Sep 14, 2023
348b994
refactor: really remove dummy constraint file
jlahovnik Sep 14, 2023
dde80ec
test: fix file path in test
jlahovnik Sep 14, 2023
a163684
test: fix post search test
jlahovnik Sep 14, 2023
6eff827
test: adapt test after merge
jlahovnik Sep 14, 2023
bc23792
feat: option to use constraints file url
jlahovnik Sep 14, 2023
29d2d4b
feat: split products for cop_ads
jlahovnik Sep 15, 2023
30a3e10
test: adapt tests for cop_ads
jlahovnik Sep 18, 2023
29d7dab
refactor: fix rebase error
jlahovnik Sep 19, 2023
1f020da
style: fix format
jlahovnik Sep 19, 2023
403df39
feat: first steps for split products by time
jlahovnik Aug 25, 2023
f51a44e
feat: first steps for split products by time
jlahovnik Aug 28, 2023
ffbfd8b
feat: split ecmwf products by time and variable
jlahovnik Sep 1, 2023
89c1b94
feat: download asset of ecmwf product
jlahovnik Sep 5, 2023
20fdced
feat: split ecmwf products - download + constraints
jlahovnik Sep 6, 2023
325a1e2
feat: only create assets for available varaibles based on constraints
jlahovnik Sep 7, 2023
9e9f6f4
test: adapt tests after changes for ecmwf products
jlahovnik Sep 8, 2023
3d442d9
refactor: avoid not available in product id in build search result
jlahovnik Sep 11, 2023
5bc893d
feat: split cop_cds products by configured intervals
jlahovnik Sep 11, 2023
8c85f7f
feat: one asset per variable for cop_cds products
jlahovnik Sep 12, 2023
3f2344d
feat: enhancements for splitting cop cds products
jlahovnik Sep 13, 2023
fd1cb2a
refactor: fixes and adaptions for cds plugin + remove dummy constrain…
jlahovnik Sep 14, 2023
4215f2d
refactor: really remove dummy constraint file
jlahovnik Sep 14, 2023
465a9d4
test: fix file path in test
jlahovnik Sep 14, 2023
31a0954
test: fix post search test
jlahovnik Sep 14, 2023
00673db
test: adapt test after merge
jlahovnik Sep 14, 2023
54eb7b5
feat: option to use constraints file url
jlahovnik Sep 14, 2023
946e940
refactor: fix rebase error
jlahovnik Sep 18, 2023
4c81f51
refactor fix another rebase error
jlahovnik Sep 18, 2023
11fdc0d
feat: add variable to download url for catalogs endpoint
jlahovnik Sep 19, 2023
b9654a2
feat: implement split products for wekeo
jlahovnik Sep 22, 2023
0f69881
feat: split products by time and variable - fixes + new config for fo…
jlahovnik Sep 26, 2023
4445270
feat: split config for ERA5 land from wekeo + fix times in result
jlahovnik Sep 27, 2023
7dd2b69
test: add test for product split with wekeo + fix test
jlahovnik Sep 27, 2023
934fa4f
feat: product split for wekeo: add new config + fixes
jlahovnik Sep 28, 2023
d206b7f
feat: introduce pagination for split products with long or no given i…
jlahovnik Sep 29, 2023
54430a2
refactor: fixes for pagination with split products
jlahovnik Sep 29, 2023
4ece05f
feat: product splitting for wekeo - search without request to wekeo api
jlahovnik Oct 2, 2023
753a79f
feat: download of splitted products for wekeo
jlahovnik Oct 3, 2023
d4e278b
feat: introduce param for splitting search results
jlahovnik Oct 3, 2023
a482539
refactor: fix pagination with product splitting
jlahovnik Oct 4, 2023
5dad034
test: adapt tests after refactoring
jlahovnik Oct 4, 2023
2cf6632
test: fix tests
jlahovnik Oct 5, 2023
097bd68
feat: configure product split for UERRA_EUROPE_SL + add constraint va…
jlahovnik Oct 6, 2023
cfd9a05
feat: configure product splitting for fire historical and satellite s…
jlahovnik Oct 6, 2023
b94167e
feat: split products by additional parameters + GLOFAS config
jlahovnik Oct 9, 2023
86037e5
feat: add other split params in id of splitted products
jlahovnik Oct 10, 2023
d6c369e
feat: configure product splitting for GLOFAS collections
jlahovnik Oct 12, 2023
2cab733
feat: wekeo - configure product splitting for EFAS collections
jlahovnik Oct 12, 2023
b51e63d
feat: add product split config for more products types
jlahovnik Oct 16, 2023
2eeba20
feat: split config for seasonal monthly collections + some fixes
jlahovnik Oct 16, 2023
4bd1716
refactor: fix some small bugs in product splitting
jlahovnik Oct 17, 2023
f1d1032
refactor: possibility to define one constraint url per provider
jlahovnik Oct 26, 2023
b42f2ab
style: fix formatting and import
jlahovnik Nov 17, 2023
72ade30
refactor: remove unused variable
jlahovnik Nov 17, 2023
aa90ef0
Merge branch 'split-atmostpheric-products-by-variables-and-time-ads' …
jlahovnik Nov 21, 2023
aea8ba9
Merge branch 'develop' into configure-split-params-wekeo
jlahovnik Nov 21, 2023
148a463
refactor: correct incorrect merge conflict resulution
jlahovnik Nov 21, 2023
2c7e5c8
refactor: remove split_result param
jlahovnik Nov 21, 2023
12ae69a
refactor: correct merge and refactoring errors
jlahovnik Nov 22, 2023
f6219a7
test: fix tests
jlahovnik Nov 22, 2023
56be246
feat: split assets by variable in client mode for cds
jlahovnik Nov 23, 2023
c4f5e43
refactor: add logging, header and error handling tp fetching of const…
jlahovnik Nov 24, 2023
0efcef6
feat: cached_request usage
sbrunato Nov 24, 2023
bbfef3e
fix: bug at fetching variables for constraint values
jlahovnik Nov 24, 2023
8f6b939
refactor: remove unnused method that came back with merge
jlahovnik Nov 24, 2023
4deb677
refactor: change variable names + add timeout
jlahovnik Nov 30, 2023
123baf9
fix: split items without start and end date
jlahovnik Nov 30, 2023
e1a315f
test: adapt split product result order
jlahovnik Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion eodag/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,13 @@ def _prepare_search(

return search_plugins, kwargs

def _do_search(self, search_plugin, count=True, raise_errors=False, **kwargs):
def _do_search(
self,
search_plugin,
count=True,
raise_errors=False,
**kwargs,
):
"""Internal method that performs a search on a given provider.

:param search_plugin: A search plugin
Expand Down Expand Up @@ -1537,6 +1543,12 @@ def _do_search(self, search_plugin, count=True, raise_errors=False, **kwargs):
if need_auth and auth_plugin and can_authenticate:
search_plugin.auth = auth_plugin.authenticate()

variable = kwargs.pop("variable", None)
if variable:
split_param = getattr(
search_plugin.config, "assets_split_parameter", "variable"
)
kwargs[split_param] = variable
res, nb_res = search_plugin.query(count=count, auth=auth_plugin, **kwargs)

# Only do the pagination computations when it makes sense. For example,
Expand Down
1 change: 1 addition & 0 deletions eodag/api/product/_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(self, provider, properties, **kwargs):
self.provider = provider
self.product_type = kwargs.get("productType")
self.location = self.remote_location = properties.get("downloadLink", "")

self.properties = {
key: value
for key, value in properties.items()
Expand Down
46 changes: 44 additions & 2 deletions eodag/api/product/metadata_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def convert_to_iso_date(datetime_string, time_delta_args_str="0,0,0,0,0,0,0"):
"2021-04-21" => "2021-04-21"
"2021-04-21T00:00:00+06:00" => "2021-04-20" !
"""
datetime_string = datetime_string.replace('"', "")
dt = isoparse(datetime_string)
if not dt.tzinfo:
dt = dt.replace(tzinfo=UTC)
Expand Down Expand Up @@ -706,6 +707,31 @@ def convert_get_ecmwf_time(date: str) -> list:
MetadataFormatter.convert_to_datetime_dict(date, "str")["hour"] + ":00"
]

@staticmethod
def convert_download_id_to_dates(product_id):
dates_str = re.search("[0-9]{8}_[0-9]{8}", product_id).group()
if not dates_str:
dates_str = re.search("[0-9]{6}_[0-9]{6}", product_id).group()
dates = dates_str.split("_")
if len(dates[0]) == 8:
start_date = datetime(
int(dates[0][:4]), int(dates[0][4:6]), int(dates[0][6:8])
)
else:
start_date = datetime(int(dates[0][:4]), int(dates[0][4:6]), 1)
if len(dates[0]) == 8:
end_date = datetime(
int(dates[1][:4]), int(dates[1][4:6]), int(dates[1][6:8])
)
else:
end_date = datetime(
int(dates[1][:4]), int(dates[1][4:6]) + 1, 1
) - timedelta(days=1)
return {
"start_date": start_date.strftime("%Y-%m-%d"),
"end_date": end_date.strftime("%Y-%m-%d"),
}

@staticmethod
def convert_get_dates_from_string(text: str, split_param="-"):
reg = "[0-9]{8}" + split_param + "[0-9]{8}"
Expand Down Expand Up @@ -767,6 +793,8 @@ def properties_from_json(json, mapping, discovery_config=None):
extracted_value = NOT_AVAILABLE
if extracted_value is None:
properties[metadata] = None
elif extracted_value == NOT_AVAILABLE:
properties[metadata] = NOT_AVAILABLE
else:
if conversion_or_none is None:
properties[metadata] = extracted_value
Expand Down Expand Up @@ -1095,6 +1123,7 @@ def format_query_params(product_type, config, **kwargs):
# retrieve values from hashes where keys are given in the param
if "}[" in formatted_query_param:
formatted_query_param = _resolve_hashes(formatted_query_param)

# json query string (for POST request)
update_nested_dict(
query_params,
Expand All @@ -1106,9 +1135,20 @@ def format_query_params(product_type, config, **kwargs):
query_params[eodag_search_key] = formatted_query_param
else:
provider_search_key, provider_value = parts
query_params.setdefault(provider_search_key, []).append(
format_metadata(provider_value, product_type, **kwargs)
formatted_query_param = format_metadata(
provider_value, product_type, **kwargs
)
if "}[" in formatted_query_param:
formatted_query_param = _resolve_hashes(
formatted_query_param.replace("'", '"')
)
query_params.setdefault(provider_search_key, []).append(
formatted_query_param
)
else:
query_params.setdefault(provider_search_key, []).append(
format_metadata(provider_value, product_type, **kwargs)
)
else:
query_params[provider_search_key] = user_input
# Now get all the literal search params (i.e params to be passed "as is"
Expand Down Expand Up @@ -1148,6 +1188,8 @@ def _resolve_hashes(formatted_query_param):
ind_open = formatted_query_param.find('}["')
ind_close = formatted_query_param.find('"]', ind_open)
hash_start = formatted_query_param[:ind_open].rfind(": {") + 2
if hash_start < 2:
hash_start = formatted_query_param[:ind_open].rfind("{")
h = orjson.loads(formatted_query_param[hash_start : ind_open + 1])
# find key and get value
ind_key_start = formatted_query_param.find('"', ind_open) + 1
Expand Down
Loading