Skip to content

Commit d1580c2

Browse files
authored
Merge pull request #1021 from RS-PYTHON/feat-rspy582/remove-deprecated-code
Feat rspy582/remove deprecated code
2 parents eb8bdc5 + eab0cf6 commit d1580c2

File tree

21 files changed

+10
-2662
lines changed

21 files changed

+10
-2662
lines changed

services/adgs/rs_server_adgs/adgs_download_status.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

services/adgs/rs_server_adgs/api/adgs_download.py

Lines changed: 0 additions & 139 deletions
This file was deleted.

services/adgs/rs_server_adgs/api/adgs_search.py

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@
2525
from typing import Annotated, Literal
2626

2727
import requests
28-
import sqlalchemy
2928
import stac_pydantic
3029
from fastapi import APIRouter, HTTPException
3130
from fastapi import Path as FPath
32-
from fastapi import Query, Request, status
31+
from fastapi import Request, status
3332
from fastapi.responses import RedirectResponse
3433
from rs_server_adgs import adgs_tags
35-
from rs_server_adgs.adgs_download_status import AdgsDownloadStatus
3634
from rs_server_adgs.adgs_retriever import init_adgs_provider
3735
from rs_server_adgs.adgs_utils import (
3836
auxip_map_mission,
@@ -43,7 +41,6 @@
4341
stac_to_odata,
4442
)
4543
from rs_server_common.authentication import authentication
46-
from rs_server_common.authentication.authentication import auth_validator
4744
from rs_server_common.authentication.authentication_to_external import (
4845
set_eodag_auth_token,
4946
)
@@ -61,11 +58,7 @@
6158
handle_exceptions,
6259
)
6360
from rs_server_common.utils.logging import Logging
64-
from rs_server_common.utils.utils import (
65-
validate_inputs_format,
66-
validate_sort_input,
67-
write_search_products_to_db,
68-
)
61+
from rs_server_common.utils.utils import validate_inputs_format, validate_sort_input
6962

7063
# pylint: disable=duplicate-code # with cadip_search
7164

@@ -395,91 +388,3 @@ def process_product_search( # pylint: disable=too-many-locals
395388
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
396389
detail=f"General failure: {exception}",
397390
) from exception
398-
399-
400-
######################################
401-
# DEPRECATED CODE, WILL BE REMOVED !!!
402-
######################################
403-
@router.get("/adgs/aux/search", deprecated=True)
404-
@auth_validator(station="adgs", access_type="read")
405-
async def search_products( # pylint: disable=too-many-locals
406-
request: Request, # pylint: disable=unused-argument
407-
datetime: Annotated[str, Query(description='Time interval e.g. "2024-01-01T00:00:00Z/2024-01-02T23:59:59Z"')],
408-
limit: Annotated[int, Query(description="Maximum number of products to return")] = 1000,
409-
sortby: Annotated[str, Query(description="Sort by +/-fieldName (ascending/descending)")] = "-created",
410-
) -> list[dict] | stac_pydantic.ItemCollection:
411-
"""Endpoint to handle the search for products in the AUX station within a specified time interval.
412-
413-
This function validates the input 'datetime' format, performs a search for products using the ADGS provider,
414-
writes the search results to the database, and generates a STAC Feature Collection from the products.
415-
416-
Args:
417-
request (Request): The request object (unused).
418-
datetime (str): Time interval in ISO 8601 format.
419-
limit (int, optional): Maximum number of products to return. Defaults to 1000.
420-
sortby (str, optional): Sort by +/-fieldName (ascending/descending). Defaults to "-datetime".
421-
422-
Returns:
423-
list[dict] | dict: A list of STAC Feature Collections or an error message.
424-
If no products are found in the specified time range, returns an empty list.
425-
426-
Raises:
427-
HTTPException (fastapi.exceptions): If the pagination limit is less than 1.
428-
HTTPException (fastapi.exceptions): If there is a bad station identifier (CreateProviderFailed).
429-
HTTPException (fastapi.exceptions): If there is a database connection error (sqlalchemy.exc.OperationalError).
430-
HTTPException (fastapi.exceptions): If there is a connection error to the station.
431-
HTTPException (fastapi.exceptions): If there is a general failure during the process.
432-
"""
433-
434-
if limit < 1:
435-
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail="Pagination cannot be less 0")
436-
set_eodag_auth_token("adgs", "auxip")
437-
try:
438-
products = (init_adgs_provider("adgs")).search(
439-
# Temp, will be removed.
440-
**{"PublicationDate": validate_inputs_format(datetime)},
441-
items_per_page=limit,
442-
sort_by=validate_sort_input(sortby),
443-
)
444-
write_search_products_to_db(AdgsDownloadStatus, products)
445-
feature_template_path = ADGS_CONFIG / "ODataToSTAC_template.json"
446-
stac_mapper_path = ADGS_CONFIG / "adgs_stac_mapper.json"
447-
with (
448-
open(feature_template_path, encoding="utf-8") as template,
449-
open(stac_mapper_path, encoding="utf-8") as stac_map,
450-
):
451-
feature_template = json.loads(template.read())
452-
stac_mapper = json.loads(stac_map.read())
453-
adgs_item_collection = create_stac_collection(products, feature_template, stac_mapper)
454-
logger.info("Succesfully listed and processed products from AUX station")
455-
return prepare_collection(serialize_adgs_asset(adgs_item_collection, products))
456-
457-
# pylint: disable=duplicate-code
458-
except CreateProviderFailed as exception:
459-
logger.error(f"Failed to create EODAG provider!\n{traceback.format_exc()}")
460-
raise HTTPException(
461-
status_code=status.HTTP_400_BAD_REQUEST,
462-
detail=f"Bad station identifier: {exception}",
463-
) from exception
464-
465-
# pylint: disable=duplicate-code
466-
except sqlalchemy.exc.OperationalError as exception:
467-
logger.error("Failed to connect to database!")
468-
raise HTTPException(
469-
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
470-
detail=f"Database connection error: {exception}",
471-
) from exception
472-
473-
except requests.exceptions.ConnectionError as exception:
474-
logger.error("Failed to connect to station!")
475-
raise HTTPException(
476-
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
477-
detail=f"Station ADGS connection error: {exception}",
478-
) from exception
479-
480-
except Exception as exception: # pylint: disable=broad-exception-caught
481-
logger.error(f"General failure! {exception}")
482-
raise HTTPException(
483-
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
484-
detail=f"General failure: {exception}",
485-
) from exception

services/adgs/rs_server_adgs/api/adgs_status.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

services/adgs/rs_server_adgs/fastapi/adgs_app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# that will init the database session and create the tables.
2121
# pylint: disable=unused-import, import-outside-toplevel
2222
# flake8: noqa
23-
import rs_server_adgs.adgs_download_status # DON'T REMOVE
2423
from rs_server_adgs import __version__
2524
from rs_server_adgs.api.adgs_search import MockPgstacAdgs
2625
from rs_server_adgs.fastapi.adgs_routers import adgs_routers

services/adgs/rs_server_adgs/fastapi/adgs_routers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
"""FastAPI routers definition."""
1616

17-
from rs_server_adgs.api import adgs_download, adgs_search, adgs_status
17+
from rs_server_adgs.api import adgs_search
1818

1919
adgs_routers = [
2020
adgs_search.router,
21-
adgs_download.router,
22-
adgs_status.router,
2321
]

0 commit comments

Comments
 (0)