Skip to content

Commit f8e0749

Browse files
authored
IEBH-353: Sync with the latest changes (#9)
1 parent 372c1a9 commit f8e0749

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1732
-1175
lines changed

.env.example

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# Credentials for vault and whether to use it or not
2-
CONFIG_CENTER_ENABLED= # example: true
3-
VAULT_URL= # example: http://vault.vault:8200
4-
VAULT_CRT= # example: ca.crt
5-
VAULT_TOKEN= # eample: token
6-
71
# The following contains defaults that can be overridden:
82
#APP_NAME=bff-web
93
#HOST=0.0.0.0

.github/workflows/hdc-pipeline.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: HDC ci/cd pipeline
2+
3+
permissions:
4+
contents: write
5+
issues: write
6+
pull-requests: write
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
pull_request:
13+
branches:
14+
- main
15+
16+
jobs:
17+
run_tests_hdc:
18+
uses: PilotDataPlatform/pilot-hdc-ci-tools/.github/workflows/run_tests.yml@main
19+
with:
20+
min_coverage_percent: 60
21+
docker_login: true
22+
secrets: inherit
23+
24+
build_and_publish_hdc:
25+
needs: [run_tests_hdc]
26+
uses: PilotDataPlatform/pilot-hdc-ci-tools/.github/workflows/build_and_publish.yml@main
27+
with:
28+
matrix_config: '["bff"]'
29+
service_name: 'bff-web'
30+
secrets: inherit
31+
32+
deploy_hdc:
33+
needs: [build_and_publish_hdc]
34+
uses: PilotDataPlatform/pilot-hdc-ci-tools/.github/workflows/trigger_deployment.yml@main
35+
with:
36+
hdc_service_name: 'bff'
37+
secrets: inherit

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ repos:
6767
'--max-line-length=120',
6868
]
6969

70-
# - repo: https://github.com/PyCQA/docformatter
71-
# rev: v1.7.5
72-
# hooks:
73-
# - id: docformatter
74-
# args: [
75-
# '--wrap-summaries=120',
76-
# '--wrap-descriptions=120',
77-
# '--in-place',
78-
# ]
70+
- repo: https://github.com/PyCQA/docformatter
71+
rev: v1.7.7
72+
hooks:
73+
- id: docformatter
74+
args: [
75+
'--wrap-summaries=120',
76+
'--wrap-descriptions=120',
77+
'--in-place',
78+
]
7979

8080
- repo: https://github.com/Lucas-C/pre-commit-hooks
8181
rev: v1.5.5

Jenkinsfile

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

api/api_bridge.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# Version 3.0 (the "License") available at https://www.gnu.org/licenses/agpl-3.0.en.html.
55
# You may not use this file except in compliance with the License.
66

7+
from typing import Annotated
8+
79
import httpx
810
from fastapi import APIRouter
911
from fastapi import Depends
@@ -19,6 +21,7 @@
1921
from models.bridge import AddVisits
2022
from models.bridge import AddVisitsResponse
2123
from models.bridge import GetRecentVisits
24+
from services.bridge import BridgeService
2225
from services.bridge import get_bridge_service
2326

2427
router = APIRouter(tags=['Bridge'])
@@ -30,17 +33,17 @@ class Bridge:
3033
current_identity: CurrentUser = Depends(jwt_required)
3134

3235
@router.post('/visits', summary='Compute one visit to the user from JWT', response_model=AddVisitsResponse)
33-
async def add_visit(self, data: AddVisits):
34-
bridge_service = await get_bridge_service()
36+
async def add_visit(self, bridge_service: Annotated[BridgeService, Depends(get_bridge_service)], data: AddVisits):
3537
username = self.current_identity['username']
3638
response = AddVisitsResponse(result='success', code=EAPIResponseCode.success.value)
3739

3840
await bridge_service.add_visit(data.entity, data.code, username)
3941
return JSONResponse(content=response.dict(), status_code=response.code)
4042

4143
@router.get('/visits', summary='get JWT user last visits')
42-
async def get_visit(self, params: GetRecentVisits = Depends()):
43-
bridge_service = await get_bridge_service()
44+
async def get_visit(
45+
self, bridge_service: Annotated[BridgeService, Depends(get_bridge_service)], params: GetRecentVisits = Depends()
46+
):
4447
username = self.current_identity['username']
4548
entity = params.entity
4649
last_codes = await bridge_service.get_visits(params.entity, username, params.last)

api/api_container/api_container_user.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# You may not use this file except in compliance with the License.
66

77
from typing import Any
8-
from typing import Dict
98

109
from common.project.project_client import ProjectObject
1110
from fastapi import APIRouter
@@ -204,13 +203,13 @@ async def keycloak_user_role_update(operation: str, user_email: str, role: str,
204203

205204

206205
def send_email_user(
207-
user: Dict[str, Any],
206+
user: dict[str, Any],
208207
project: ProjectObject,
209208
username: str,
210209
role: str,
211210
title: str,
212211
template: str,
213-
current_identity: Dict[str, Any],
212+
current_identity: dict[str, Any],
214213
) -> None:
215214
try:
216215
email = user['email']

api/api_dataset/api_activity_logs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ActivityLogs:
4040
)
4141
async def get(self, dataset_code: str, request: Request) -> JSONResponse:
4242
"""Fetch activity logs of a dataset."""
43+
4344
_res = APIResponse()
4445
logger.info(f'Call API for fetching logs for dataset: {dataset_code}')
4546

api/api_dataset/api_versions.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from httpx import AsyncClient
1414

1515
from app.auth import jwt_required
16+
from app.components.request.context import RequestContextDependency
1617
from app.components.user.models import CurrentUser
1718
from app.logger import logger
1819
from config import ConfigClass
@@ -85,14 +86,12 @@ class DownloadPre:
8586
summary='pre-download for dataset',
8687
dependencies=[Depends(DatasetPermission())],
8788
)
88-
async def get(self, dataset_id: str, request: Request):
89+
async def get(self, dataset_id: str, request: Request, request_context: RequestContextDependency):
8990
api_response = APIResponse()
9091
try:
91-
response = requests.get(
92+
response = await request_context.client.get(
9293
ConfigClass.DATASET_SERVICE + f'dataset/{dataset_id}/download/pre',
9394
params=request.query_params,
94-
headers=request.headers,
95-
timeout=ConfigClass.SERVICE_CLIENT_TIMEOUT,
9695
)
9796
except Exception as e:
9897
logger.info(f'Error calling dataset service: {e}')

0 commit comments

Comments
 (0)