Skip to content

Commit 39d21e1

Browse files
committed
merge zarr features into sebastien
2 parents 39d75d2 + 0c1742d commit 39d21e1

File tree

21 files changed

+99
-249
lines changed

21 files changed

+99
-249
lines changed

.github/workflows/build_on_release.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
push: true
4040
build-args: |
4141
REGISTRY=${{ vars.GEOKUBE_REGISTRY }}
42-
TAG=v0.2a6
4342
cache-from: type=gha
4443
cache-to: type=gha,mode=max
4544
tags: |

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ _catalogs/
113113
_old/
114114

115115
.DS_Store
116-
db_init
117116
*.zarr
118-
*.nc
117+
*.nc
118+
db_init
119+
catalog
120+
docker-compose.yaml
121+
nginx.conf

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10598417.svg)](https://doi.org/10.5281/zenodo.10598417)
2-
31
# geolake
42

53
## Description
@@ -12,13 +10,14 @@ The system has been designed using a cloud-native architecture, based on contain
1210

1311
It uses [geokube](https://github.com/CMCC-Foundation/geokube) as an Analytics Engine to perform geospatial operations.
1412

15-
## Authors
13+
## Developer Team
14+
15+
- [Valentina Scardigno](https://github.com/vale95-eng)
16+
- [Gabriele Tramonte](https://github.com/gtramonte)
1617

17-
**Project Lead**:
18-
[Marco Mancini](https://github.com/km4rcus)
18+
### Former Developers
1919

20-
**Main Developers**
20+
- [Marco Mancini](https://github.com/km4rcus)
2121
- [Jakub Walczak](https://github.com/jamesWalczak)
2222
- [Mirko Stojiljkovic](https://github.com/MMStojiljkovic)
23-
- [Valentina Scardigno](https://github.com/vale95-eng)
2423

api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt update && apt install -y cron curl
66

77
WORKDIR /app
88
COPY requirements.txt /code/requirements.txt
9-
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
9+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt --break-system-packages
1010
COPY app /app
1111
EXPOSE 80
1212

api/app/endpoint_handlers/file.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
"""Module with functions to handle file related endpoints"""
2+
import io
23
import os
4+
import zipfile
5+
from pathlib import Path
6+
from zipfile import ZipFile
37

48
from fastapi.responses import FileResponse
9+
10+
511
from dbmanager.dbmanager import DBManager, RequestStatus
12+
from starlette.requests import Request
13+
from starlette.responses import HTMLResponse, RedirectResponse, StreamingResponse
14+
from starlette.staticfiles import StaticFiles
615

716
from utils.api_logging import get_dds_logger
817
from utils.metrics import log_execution_time
918
import exceptions as exc
1019

1120
log = get_dds_logger(__name__)
1221

13-
1422
@log_execution_time(log)
15-
def download_request_result(request_id: int):
23+
def download_request_result(request_id: int, filename: str = None):
1624
"""Realize the logic for the endpoint:
1725
1826
`GET /download/{request_id}`
@@ -60,7 +68,15 @@ def download_request_result(request_id: int):
6068
download_details.location_path,
6169
)
6270
raise FileNotFoundError
63-
return FileResponse(
64-
path=download_details.location_path,
65-
filename=download_details.location_path.split(os.sep)[-1],
66-
)
71+
72+
if download_details.location_path.endswith(".zarr"):
73+
log.info("Zarr detected")
74+
return FileResponse(
75+
path=f'{download_details.location_path}/{filename}',
76+
filename=filename,
77+
)
78+
else:
79+
return FileResponse(
80+
path=download_details.location_path,
81+
filename=download_details.location_path.split(os.sep)[-1],
82+
)

api/app/main.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,4 +679,52 @@ async def dcatapit(request: Request):
679679
# response = dcatapit_graph.serialize(format='pretty-xml')
680680
response = serialize_and_concatenate_graphs(catalog_graph, datasets_graph, distributions_graph, vcard_graph)
681681

682-
return Response(content=response, media_type="application/rdf+xml")
682+
return Response(content=response, media_type="application/rdf+xml")
683+
@app.get("/download/{request_id}/{filename}", tags=[tags.REQUEST])
684+
@timer(
685+
app.state.api_request_duration_seconds,
686+
labels={"route": "GET /download/{request_id}/{filename}"},
687+
)
688+
# @requires([scopes.AUTHENTICATED]) # TODO: mange download auth in the web component
689+
async def download_request_result(
690+
request: Request,
691+
request_id: int,
692+
filename: str,
693+
):
694+
"""Download result of the request"""
695+
app.state.api_http_requests_total.inc(
696+
{"route": "GET /download/{request_id}/{filename}"}
697+
)
698+
try:
699+
return file_handler.download_request_result(request_id=request_id, filename=filename)
700+
except exc.BaseDDSException as err:
701+
raise err.wrap_around_http_exception() from err
702+
except FileNotFoundError as err:
703+
raise HTTPException(
704+
status_code=status.HTTP_404_NOT_FOUND, detail="File was not found!"
705+
) from err
706+
707+
@app.get("/download/{request_id}/{filename}/{subfile}", tags=[tags.REQUEST])
708+
@timer(
709+
app.state.api_request_duration_seconds,
710+
labels={"route": "GET /download/{request_id}/{filename}/{subfile}"},
711+
)
712+
# @requires([scopes.AUTHENTICATED])
713+
async def download_request_result(
714+
request: Request,
715+
request_id: int,
716+
filename: str,
717+
subfile: str,
718+
):
719+
"""Download result of the request"""
720+
app.state.api_http_requests_total.inc(
721+
{"route": "GET /download/{request_id}/{filename}/{subfile}"}
722+
)
723+
try:
724+
return file_handler.download_request_result(request_id=request_id, filename=f'{filename}/{subfile}')
725+
except exc.BaseDDSException as err:
726+
raise err.wrap_around_http_exception() from err
727+
except FileNotFoundError as err:
728+
raise HTTPException(
729+
status_code=status.HTTP_404_NOT_FOUND, detail="File was not found!"
730+
) from err

catalog/README.md

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

catalog/RS_indices.yaml

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

catalog/cache.py

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

catalog/catalog.yaml

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

0 commit comments

Comments
 (0)