Skip to content

Commit 8eac1f8

Browse files
committed
Merge branch 'feat-324/stac-view-of-prip-products' into feat-rspy760/producttype_config
2 parents 45a601b + 178dc04 commit 8eac1f8

File tree

16 files changed

+790
-362
lines changed

16 files changed

+790
-362
lines changed

.github/scripts/git_debug_image.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ BRANCH_NAME="$1" # git branch name
2929
. /etc/os-release
3030
echo "deb http://deb.debian.org/debian $VERSION_CODENAME main" > /etc/apt/sources.list
3131
apt update
32-
apt install -y git vim emacs-nox
32+
apt install -y --no-install-recommends git vim-tiny mg
3333

3434
# Add aliases to bash
3535
cat << EOF >> /home/user/.bashrc
3636
alias ll='ls -alFh'
3737
alias ls='ls --color=auto'
38+
alias vim='vim.tiny'
3839
EOF
3940

4041
# Git clone the project branch with HTTP authentication so we don't need any

services/adgs/rs_server_adgs/adgs_utils.py

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import stac_pydantic
2626
import yaml
2727
from fastapi import HTTPException, status
28-
from rs_server_common.stac_api_common import map_stac_platform
28+
from rs_server_common.utils.utils import reverse_adgs_prip_map_mission
2929

3030
ADGS_CONFIG = Path(osp.realpath(osp.dirname(__file__))).parent / "config"
3131
search_yaml = ADGS_CONFIG / "adgs_search_config.yaml"
@@ -86,70 +86,10 @@ def serialize_adgs_asset(feature_collection, products):
8686
return feature_collection
8787

8888

89-
def auxip_map_mission(platform: str, constellation: str) -> tuple[str | None, str | None]:
90-
"""
91-
Custom function for ADGS, to read constellation mapper and return propper
92-
values for platform and serial.
93-
Eodag maps this values to platformShortName, platformSerialIdentifier
94-
95-
Input: platform = sentinel-1a Output: sentinel-1, A
96-
Input: platform = sentinel-5P Output: sentinel-5p, None
97-
Input: constellation = sentinel-1 Output: sentinel-1, None
98-
"""
99-
data = map_stac_platform()
100-
platform_short_name: str | None = None
101-
platform_serial_identifier: str | None = None
102-
try:
103-
if platform:
104-
config = next(satellite[platform] for satellite in data["satellites"] if platform in satellite)
105-
platform_short_name = config.get("constellation", None)
106-
platform_serial_identifier = config.get("serialid", None)
107-
if constellation:
108-
if platform_short_name and platform_short_name != constellation:
109-
# Inconsistent combination of platform / constellation case
110-
raise HTTPException(
111-
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
112-
detail="Invalid combination of platform-constellation",
113-
)
114-
if any(
115-
satellite[list(satellite.keys())[0]]["constellation"] == constellation
116-
for satellite in data["satellites"]
117-
):
118-
platform_short_name = constellation
119-
platform_serial_identifier = None
120-
else:
121-
raise KeyError
122-
except (KeyError, IndexError, StopIteration) as exc:
123-
raise HTTPException(
124-
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
125-
detail="Cannot map platform/constellation",
126-
) from exc
127-
return platform_short_name, platform_serial_identifier
128-
129-
130-
def adgs_reverse_map_mission(
131-
platform: str | None,
132-
constellation: str | None,
133-
) -> tuple[str | None, str | None]:
134-
"""Function used to re-map platform and constellation based on satellite value."""
135-
if not (constellation or platform):
136-
return None, None
137-
138-
if constellation:
139-
constellation = constellation.lower() # type: ignore
140-
141-
for satellite in map_stac_platform()["satellites"]:
142-
for key, info in satellite.items():
143-
# Check for matching serialid and constellation
144-
if info.get("serialid") == platform and info.get("constellation").lower() == constellation:
145-
return key, info.get("constellation")
146-
return None, None
147-
148-
14989
def prepare_collection(collection: stac_pydantic.ItemCollection) -> stac_pydantic.ItemCollection:
15090
"""Used to create a more complex mapping on platform/constallation from odata to stac."""
15191
for feature in collection.features:
152-
feature.properties.platform, feature.properties.constellation = adgs_reverse_map_mission(
92+
feature.properties.platform, feature.properties.constellation = reverse_adgs_prip_map_mission(
15393
feature.properties.platform,
15494
feature.properties.constellation,
15595
)

services/adgs/rs_server_adgs/api/adgs_search.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from fastapi.responses import RedirectResponse
3333
from rs_server_adgs import adgs_retriever, adgs_tags
3434
from rs_server_adgs.adgs_utils import (
35-
auxip_map_mission,
3635
auxip_odata_to_stac_template,
3736
auxip_stac_mapper,
3837
prepare_collection,
@@ -59,7 +58,11 @@
5958
split_multiple_values,
6059
)
6160
from rs_server_common.utils.logging import Logging
62-
from rs_server_common.utils.utils import validate_inputs_format, validate_sort_input
61+
from rs_server_common.utils.utils import (
62+
map_auxip_prip_mission,
63+
validate_inputs_format,
64+
validate_sort_input,
65+
)
6366
from stac_fastapi.api.models import GeoJSONResponse
6467

6568
# pylint: disable=duplicate-code # with cadip_search
@@ -89,7 +92,7 @@ def __init__(self, request: Request | None = None, readwrite: Literal["r", "w"]
8992
all_collections=lambda: read_conf()["collections"],
9093
select_config=select_config,
9194
stac_to_odata=stac_to_odata,
92-
map_mission=auxip_map_mission,
95+
map_mission=map_auxip_prip_mission,
9396
temporal_mapping={"start_datetime": "ContentDate/Start", "end_datetime": "ContentDate/End"},
9497
)
9598

services/cadip/rs_server_cadip/cadip_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@
3030
import yaml
3131
from fastapi import HTTPException, status
3232
from rs_server_common.rspy_models import Item
33-
from rs_server_common.stac_api_common import map_stac_platform
3433
from rs_server_common.utils.logging import Logging
35-
from rs_server_common.utils.utils import strftime_millis
34+
from rs_server_common.utils.utils import map_stac_platform, strftime_millis
3635
from stac_pydantic import ItemCollection, ItemProperties
3736
from stac_pydantic.shared import Asset
3837

services/common/config/prip_queryables.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,66 @@ sat:orbit_state:
105105
format: string
106106
description: string
107107
enum: [ascending, descending]
108+
processing:lineage:
109+
type: string
110+
title: processing:lineage
111+
format: string
112+
description: string
113+
eopf:origin_datetime:
114+
type: datetime
115+
title: eopf:origin_datetime
116+
format: datetime
117+
description: string
118+
eopf:datatake_id:
119+
type: string
120+
title: eopf:datatake_id
121+
format: string
122+
description: string
123+
eopf:instrument_configuration_id:
124+
type: string
125+
title: eopf:instrument_configuration_id
126+
format: string
127+
description: string
128+
expires:
129+
type: datetime
130+
title: expires
131+
format: datetime
132+
description: string
133+
eviction_datetime:
134+
type: datetime
135+
title: eviction_datetime
136+
format: datetime
137+
description: string
138+
file:size:
139+
type: integer
140+
title: file:size
141+
format: integer
142+
description: string
143+
type:
144+
type: string
145+
title: type
146+
format: string
147+
description: string
148+
file:checksum:
149+
type: string
150+
title: file:checksum
151+
format: string
152+
description: string
153+
instruments:
154+
type: string
155+
title: instruments
156+
format: string
157+
description: string
158+
sat:orbit_cycle:
159+
type: integer
160+
title: sat:orbit_cycle
161+
format: integer
162+
description: string
163+
sar:polarizations:
164+
type: string
165+
title: sar:polarizations
166+
format: string
167+
description: string
108168
intersects:
109169
type: string
110170
title: intersects

services/common/rs_server_common/stac_api_common.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,9 @@ def get_queryables(
228228

229229
return queryables
230230

231-
if self.prip: # pylint: disable=too-many-branches
232-
can_query = True
233-
if can_query: # pylint: disable=too-many-branches
234-
for queryable_name, queryable_data in get_prip_queryables().items():
235-
queryables.update({queryable_name: QueryableField(**queryable_data)})
236-
231+
if self.prip:
232+
for queryable_name, queryable_data in get_prip_queryables().items():
233+
queryables.update({queryable_name: QueryableField(**queryable_data)})
237234
return queryables
238235

239236
# Idem for satellite or platform
@@ -1159,13 +1156,6 @@ def filter_allowed_collections(all_collections: list[dict], role: ServiceRole |
11591156
return stac_collections
11601157

11611158

1162-
@lru_cache
1163-
def map_stac_platform() -> dict:
1164-
"""Function used to read and interpret from constellation.yaml"""
1165-
with open(Path(__file__).parent.parent / "config" / "constellation.yaml", encoding="utf-8") as cf:
1166-
return yaml.safe_load(cf)
1167-
1168-
11691159
@lru_cache
11701160
def get_cadip_queryables() -> dict:
11711161
"""Function used to read and interpret from cadip_queryables.yaml"""

services/common/rs_server_common/utils/utils.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from collections.abc import Callable, Iterable, Sequence
2121
from concurrent.futures import ThreadPoolExecutor
2222
from datetime import datetime
23+
from functools import lru_cache
2324
from pathlib import Path
2425
from threading import Thread
2526
from typing import Any
@@ -152,6 +153,73 @@ def to_dt(dates: list[str]) -> list[datetime | None]:
152153
return fixed_date_dt, start_date_dt, stop_date_dt
153154

154155

156+
@lru_cache
157+
def map_stac_platform() -> dict:
158+
"""Function used to read and interpret from constellation.yaml"""
159+
with open(Path(__file__).parent.parent.parent / "config" / "constellation.yaml", encoding="utf-8") as cf:
160+
return yaml.safe_load(cf)
161+
162+
163+
def map_auxip_prip_mission(platform: str, constellation: str) -> tuple[str | None, str | None]:
164+
"""
165+
Custom function for ADGS/PRIP, to read constellation mapper and return propper
166+
values for platform and serial.
167+
Eodag maps this values to platformShortName, platformSerialIdentifier
168+
169+
Input: platform = sentinel-1a Output: sentinel-1, A
170+
Input: platform = sentinel-5P Output: sentinel-5p, None
171+
Input: constellation = sentinel-1 Output: sentinel-1, None
172+
"""
173+
data = map_stac_platform()
174+
platform_short_name: str | None = None
175+
platform_serial_identifier: str | None = None
176+
try:
177+
if platform:
178+
config = next(satellite[platform] for satellite in data["satellites"] if platform in satellite)
179+
platform_short_name = config.get("constellation", None)
180+
platform_serial_identifier = config.get("serialid", None)
181+
if constellation:
182+
if platform_short_name and platform_short_name != constellation:
183+
# Inconsistent combination of platform / constellation case
184+
raise HTTPException(
185+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
186+
detail="Invalid combination of platform-constellation",
187+
)
188+
if any(
189+
satellite[list(satellite.keys())[0]]["constellation"] == constellation
190+
for satellite in data["satellites"]
191+
):
192+
platform_short_name = constellation
193+
platform_serial_identifier = None
194+
else:
195+
raise KeyError
196+
except (KeyError, IndexError, StopIteration) as exc:
197+
raise HTTPException(
198+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
199+
detail="Cannot map platform/constellation",
200+
) from exc
201+
return platform_short_name, platform_serial_identifier
202+
203+
204+
def reverse_adgs_prip_map_mission(
205+
platform: str | None,
206+
constellation: str | None,
207+
) -> tuple[str | None, str | None]:
208+
"""Function used to re-map platform and constellation based on satellite value."""
209+
if not (constellation or platform):
210+
return None, None
211+
212+
if constellation:
213+
constellation = constellation.lower() # type: ignore
214+
215+
for satellite in map_stac_platform()["satellites"]:
216+
for key, info in satellite.items():
217+
# Check for matching serialid and constellation
218+
if info.get("serialid") == platform and info.get("constellation").lower() == constellation:
219+
return key, info.get("constellation")
220+
return None, None
221+
222+
155223
def odata_to_stac(
156224
feature_template: dict,
157225
odata_dict: dict,

services/prip/config/prip_search_config.template.yaml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 CS Group
1+
# Copyright 2025 CS Group
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@ template:
3333
title: "Legal notice on the use of Copernicus Sentinel Data and Service Information"
3434
type: "application/pdf"
3535
- rel: describedby
36-
href: "https://sentiwiki.copernicus.eu/web/copernicus-operations#CopernicusOperations-AuxiliaryDataGathering"
37-
title: "Auxiliary Data"
36+
href: "https://sentiwiki.copernicus.eu/web/copernicus-operations#CopernicusOperations-SystematicProduction"
37+
title: "Production Service"
3838
type: "text/html"
3939
providers:
4040
- name: "European Union/ESA/Copernicus"
@@ -51,21 +51,42 @@ collections:
5151

5252
# All stations deployed in the CS cluster, without queries
5353

54-
- id: adgs
55-
station: adgs
56-
title: "All from 'adgs' station"
57-
description: "All from 'adgs' station"
54+
- id: s1a
55+
station: s1a
56+
title: "All from 's1a' station"
57+
description: "All from 's1a' station"
5858

59-
- id: adgs2
60-
station: adgs2
61-
title: "All from 'adgs2' station"
62-
description: "All from 'adgs2' station"
59+
- id: s2b
60+
station: s2b
61+
title: "All from 's2b' station"
62+
description: "All from 's2b' station"
6363

6464
# Idem with one collection per product type
6565

66-
- id: adgs_aux_pp2
67-
station: adgs
66+
- id: S1A_L0_IW_RAW
67+
station: s1a
6868
query:
69-
productType: AUX_PP2
70-
title: "AUX_PP2 'adgs' station"
71-
description: "AUX_PP2 'adgs' station"
69+
productType: IW_RAW__0N
70+
title: "s1a 'prip' station"
71+
description: "s1a 'prip' station"
72+
73+
- id: S2B_L0_DS
74+
station: s2b
75+
query:
76+
productType: OPER_MSI
77+
title: "s2b 'prip' station"
78+
description: "s2b 'prip' station"
79+
80+
- id: S2B_L0_GR
81+
station: s2b
82+
query:
83+
productType: OPER_MSI_L0
84+
title: "S2B_L0_GR 'prip' station"
85+
description: "S2B_L0_GR 'prip' station"
86+
87+
- id: S2B_L2A_TL
88+
station: s2b
89+
query:
90+
productType: OPER_MSI_L2A
91+
title: "S2B_L2A_TL 'prip' station"
92+
description: "S2B_L2A_TL 'prip' station"

services/prip/config/prip_search_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 CS Group
1+
# Copyright 2025 CS Group
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)