From 9f328e573c502bca1187c2731b4daacfdc528290 Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Sun, 7 May 2023 20:12:33 +0200 Subject: [PATCH 1/5] mypy webserver - storage plugin --- .../webserver/scripts/openapi_storage.py | 5 +- .../simcore_service_webserver/application.py | 2 +- .../application_settings.py | 2 +- .../diagnostics/_handlers.py | 3 +- .../login/storage.py | 3 +- .../projects/_create_utils.py | 2 +- .../projects/_delete_utils.py | 2 +- .../projects/projects_api.py | 3 +- .../storage/__init__.py | 0 .../_handlers.py} | 14 +++--- .../{storage_routes.py => storage/_routes.py} | 26 +++++----- .../{storage_api.py => storage/api.py} | 6 +-- .../{storage.py => storage/plugin.py} | 4 +- .../schemas.py} | 50 +++++++++---------- .../settings.py} | 2 +- .../unit/isolated/test_storage_schemas.py | 4 +- 16 files changed, 66 insertions(+), 62 deletions(-) create mode 100644 services/web/server/src/simcore_service_webserver/storage/__init__.py rename services/web/server/src/simcore_service_webserver/{storage_handlers.py => storage/_handlers.py} (95%) rename services/web/server/src/simcore_service_webserver/{storage_routes.py => storage/_routes.py} (83%) rename services/web/server/src/simcore_service_webserver/{storage_api.py => storage/api.py} (97%) rename services/web/server/src/simcore_service_webserver/{storage.py => storage/plugin.py} (88%) rename services/web/server/src/simcore_service_webserver/{storage_schemas.py => storage/schemas.py} (74%) rename services/web/server/src/simcore_service_webserver/{storage_settings.py => storage/settings.py} (95%) diff --git a/api/specs/webserver/scripts/openapi_storage.py b/api/specs/webserver/scripts/openapi_storage.py index b7359da087d..216ddc339c6 100644 --- a/api/specs/webserver/scripts/openapi_storage.py +++ b/api/specs/webserver/scripts/openapi_storage.py @@ -8,12 +8,11 @@ from enum import Enum -from typing import Union from fastapi import FastAPI, status from models_library.generics import Envelope from pydantic import NonNegativeInt -from simcore_service_webserver.storage_schemas import ( +from simcore_service_webserver.storage.schemas import ( CompleteUpload, DatasetMetaData, FileLocation, @@ -27,7 +26,7 @@ app = FastAPI(redoc_url=None) -TAGS: list[Union[str, Enum]] = [ +TAGS: list[str | Enum] = [ "storage", ] diff --git a/services/web/server/src/simcore_service_webserver/application.py b/services/web/server/src/simcore_service_webserver/application.py index fa4d5803299..c32b5cdeff8 100644 --- a/services/web/server/src/simcore_service_webserver/application.py +++ b/services/web/server/src/simcore_service_webserver/application.py @@ -39,7 +39,7 @@ from .session import setup_session from .socketio.plugin import setup_socketio from .statics.plugin import setup_statics -from .storage import setup_storage +from .storage.plugin import setup_storage from .studies_dispatcher.plugin import setup_studies_dispatcher from .tags import setup_tags from .tracing import setup_app_tracing diff --git a/services/web/server/src/simcore_service_webserver/application_settings.py b/services/web/server/src/simcore_service_webserver/application_settings.py index 034813903ff..242d88dba94 100644 --- a/services/web/server/src/simcore_service_webserver/application_settings.py +++ b/services/web/server/src/simcore_service_webserver/application_settings.py @@ -41,7 +41,7 @@ from .scicrunch.settings import SciCrunchSettings from .session_settings import SessionSettings from .statics.settings import FrontEndAppSettings, StaticWebserverModuleSettings -from .storage_settings import StorageSettings +from .storage.settings import StorageSettings from .studies_dispatcher.settings import StudiesDispatcherSettings log = logging.getLogger(__name__) diff --git a/services/web/server/src/simcore_service_webserver/diagnostics/_handlers.py b/services/web/server/src/simcore_service_webserver/diagnostics/_handlers.py index d309e138793..6b1ce520ae3 100644 --- a/services/web/server/src/simcore_service_webserver/diagnostics/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/diagnostics/_handlers.py @@ -11,10 +11,11 @@ from servicelib.aiohttp.client_session import get_client_session from servicelib.utils import logged_gather -from .. import catalog_client, db, director_v2_api, storage_api +from .. import catalog_client, db, director_v2_api from .._meta import API_VERSION, APP_NAME, api_version_prefix from ..login.decorators import login_required from ..security.decorators import permission_required +from ..storage import api as storage_api from ..utils import get_task_info, get_tracemalloc_info from ..utils_aiohttp import envelope_json_response diff --git a/services/web/server/src/simcore_service_webserver/login/storage.py b/services/web/server/src/simcore_service_webserver/login/storage.py index 05ffd4b38e0..076addd5fc6 100644 --- a/services/web/server/src/simcore_service_webserver/login/storage.py +++ b/services/web/server/src/simcore_service_webserver/login/storage.py @@ -98,7 +98,8 @@ async def get_confirmation(self, filter_dict) -> ConfirmationTokenDict | None: filter_dict["user_id"] = filter_dict.pop("user")["id"] async with self.pool.acquire() as conn: confirmation = await _sql.find_one(conn, self.confirm_tbl, filter_dict) - return ConfirmationTokenDict(**confirmation) if confirmation else None + confirmation_token: ConfirmationTokenDict | None = ConfirmationTokenDict(**confirmation) if confirmation else None # type: ignore[misc] + return confirmation_token async def delete_confirmation(self, confirmation: ConfirmationTokenDict): async with self.pool.acquire() as conn: diff --git a/services/web/server/src/simcore_service_webserver/projects/_create_utils.py b/services/web/server/src/simcore_service_webserver/projects/_create_utils.py index 18488414a91..afcd62697c9 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_create_utils.py +++ b/services/web/server/src/simcore_service_webserver/projects/_create_utils.py @@ -17,7 +17,7 @@ from .. import director_v2_api from ..application_settings import get_settings -from ..storage_api import ( +from ..storage.api import ( copy_data_folders_from_project, get_project_total_size_simcore_s3, ) diff --git a/services/web/server/src/simcore_service_webserver/projects/_delete_utils.py b/services/web/server/src/simcore_service_webserver/projects/_delete_utils.py index 8ca150383a4..bfc23d91237 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_delete_utils.py +++ b/services/web/server/src/simcore_service_webserver/projects/_delete_utils.py @@ -14,7 +14,7 @@ from models_library.users import UserID from .. import director_v2_api -from ..storage_api import delete_data_folders_of_project +from ..storage.api import delete_data_folders_of_project from ..users_api import UserNameDict from ..users_exceptions import UserNotFoundError from .projects_db import ProjectDBAPI diff --git a/services/web/server/src/simcore_service_webserver/projects/projects_api.py b/services/web/server/src/simcore_service_webserver/projects/projects_api.py index 8199928f06b..c7a03d434b5 100644 --- a/services/web/server/src/simcore_service_webserver/projects/projects_api.py +++ b/services/web/server/src/simcore_service_webserver/projects/projects_api.py @@ -46,7 +46,7 @@ from servicelib.utils import fire_and_forget_task, logged_gather from simcore_postgres_database.webserver_models import ProjectType -from .. import catalog_client, director_v2_api, storage_api +from .. import catalog_client, director_v2_api from ..products.plugin import get_product_name from ..redis import get_redis_lock_manager_client_sdk from ..resource_manager.websocket_manager import ( @@ -61,6 +61,7 @@ send_group_messages, send_messages, ) +from ..storage import api as storage_api from ..users_api import UserRole, get_user_name, get_user_role from ..users_exceptions import UserNotFoundError from . import _delete_utils, _nodes_utils diff --git a/services/web/server/src/simcore_service_webserver/storage/__init__.py b/services/web/server/src/simcore_service_webserver/storage/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/services/web/server/src/simcore_service_webserver/storage_handlers.py b/services/web/server/src/simcore_service_webserver/storage/_handlers.py similarity index 95% rename from services/web/server/src/simcore_service_webserver/storage_handlers.py rename to services/web/server/src/simcore_service_webserver/storage/_handlers.py index 13e2866d588..97e0fdef078 100644 --- a/services/web/server/src/simcore_service_webserver/storage_handlers.py +++ b/services/web/server/src/simcore_service_webserver/storage/_handlers.py @@ -19,9 +19,9 @@ from servicelib.request_keys import RQT_USERID_KEY from yarl import URL -from .login.decorators import login_required -from .security.decorators import permission_required -from .storage_settings import StorageSettings, get_plugin_settings +from ..login.decorators import login_required +from ..security.decorators import permission_required +from .settings import StorageSettings, get_plugin_settings log = logging.getLogger(__name__) @@ -35,7 +35,8 @@ def _get_base_storage_url(app: web.Application) -> URL: def _get_storage_vtag(app: web.Application) -> str: settings: StorageSettings = get_plugin_settings(app) - return settings.STORAGE_VTAG + storage_vtag: str = settings.STORAGE_VTAG + return storage_vtag def _resolve_storage_url(request: web.Request) -> URL: @@ -88,7 +89,8 @@ def _unresolve_storage_url(request: web.Request, storage_url: AnyUrl) -> AnyUrl: converted_url = request.url.with_path( f"/v0/storage{storage_url.path.removeprefix(prefix)}" ).with_scheme(request.headers.get(X_FORWARDED_PROTO, request.url.scheme)) - return parse_obj_as(AnyUrl, f"{converted_url}") + converted_url_: AnyUrl = parse_obj_as(AnyUrl, f"{converted_url}") + return converted_url_ async def safe_unwrap( @@ -109,7 +111,7 @@ def extract_link(data: dict | None) -> str: if data is None or "link" not in data: raise web.HTTPException(reason=f"No url found in response: '{data}'") - return data["link"] + return parse_obj_as(str, data["link"]) # --------------------------------------------------------------------- diff --git a/services/web/server/src/simcore_service_webserver/storage_routes.py b/services/web/server/src/simcore_service_webserver/storage/_routes.py similarity index 83% rename from services/web/server/src/simcore_service_webserver/storage_routes.py rename to services/web/server/src/simcore_service_webserver/storage/_routes.py index d94dcbead87..f68652747d4 100644 --- a/services/web/server/src/simcore_service_webserver/storage_routes.py +++ b/services/web/server/src/simcore_service_webserver/storage/_routes.py @@ -8,7 +8,7 @@ from aiohttp import web from servicelib.aiohttp import openapi -from . import storage_handlers +from . import _handlers log = logging.getLogger(__name__) @@ -24,41 +24,41 @@ def create(specs: openapi.Spec) -> list[web.RouteDef]: # TODO: routing will be done automatically using operation_id/tags, etc... # storage -- - path, handler = "/storage/locations", storage_handlers.get_storage_locations + path, handler = "/storage/locations", _handlers.get_storage_locations operation_id = specs.paths[path].operations["get"].operation_id routes.append(web.get(BASEPATH + path, handler, name=operation_id)) path, handler = ( "/storage/locations/{location_id}:sync", - storage_handlers.synchronise_meta_data_table, + _handlers.synchronise_meta_data_table, ) operation_id = specs.paths[path].operations["post"].operation_id routes.append(web.post(BASEPATH + path, handler, name=operation_id)) path, handler = ( "/storage/locations/{location_id}/datasets", - storage_handlers.get_datasets_metadata, + _handlers.get_datasets_metadata, ) operation_id = specs.paths[path].operations["get"].operation_id routes.append(web.get(BASEPATH + path, handler, name=operation_id)) path, handle = ( "/storage/locations/{location_id}/files/metadata", - storage_handlers.get_files_metadata, + _handlers.get_files_metadata, ) operation_id = specs.paths[path].operations["get"].operation_id routes.append(web.get(BASEPATH + path, handle, name=operation_id)) path, handle = ( "/storage/locations/{location_id}/datasets/{dataset_id}/metadata", - storage_handlers.get_files_metadata_dataset, + _handlers.get_files_metadata_dataset, ) operation_id = specs.paths[path].operations["get"].operation_id routes.append(web.get(BASEPATH + path, handle, name=operation_id)) path, handle = ( "/storage/locations/{location_id}/files/{file_id}/metadata", - storage_handlers.get_file_metadata, + _handlers.get_file_metadata, ) operation_id = specs.paths[path].operations["get"].operation_id routes.append(web.get(BASEPATH + path, handle, name=operation_id)) @@ -66,42 +66,42 @@ def create(specs: openapi.Spec) -> list[web.RouteDef]: _FILE_PATH = "/storage/locations/{location_id}/files/{file_id}" path, handle = ( _FILE_PATH, - storage_handlers.download_file, + _handlers.download_file, ) operation_id = specs.paths[path].operations["get"].operation_id routes.append(web.get(BASEPATH + path, handle, name=operation_id)) path, handle = ( _FILE_PATH, - storage_handlers.delete_file, + _handlers.delete_file, ) operation_id = specs.paths[path].operations["delete"].operation_id routes.append(web.delete(BASEPATH + path, handle, name=operation_id)) path, handle = ( _FILE_PATH, - storage_handlers.upload_file, + _handlers.upload_file, ) operation_id = specs.paths[path].operations["put"].operation_id routes.append(web.put(BASEPATH + path, handle, name=operation_id)) path, handle = ( f"{_FILE_PATH}:complete", - storage_handlers.complete_upload_file, + _handlers.complete_upload_file, ) operation_id = specs.paths[path].operations["post"].operation_id routes.append(web.post(BASEPATH + path, handle, name=operation_id)) path, handle = ( f"{_FILE_PATH}:abort", - storage_handlers.abort_upload_file, + _handlers.abort_upload_file, ) operation_id = specs.paths[path].operations["post"].operation_id routes.append(web.post(BASEPATH + path, handle, name=operation_id)) path, handle = ( f"{_FILE_PATH}:complete/futures/{{future_id}}", - storage_handlers.is_completed_upload_file, + _handlers.is_completed_upload_file, ) operation_id = specs.paths[path].operations["post"].operation_id routes.append(web.post(BASEPATH + path, handle, name=operation_id)) diff --git a/services/web/server/src/simcore_service_webserver/storage_api.py b/services/web/server/src/simcore_service_webserver/storage/api.py similarity index 97% rename from services/web/server/src/simcore_service_webserver/storage_api.py rename to services/web/server/src/simcore_service_webserver/storage/api.py index b44d35cfd5e..365371d1428 100644 --- a/services/web/server/src/simcore_service_webserver/storage_api.py +++ b/services/web/server/src/simcore_service_webserver/storage/api.py @@ -25,9 +25,9 @@ from servicelib.logging_utils import get_log_record_extra, log_context from yarl import URL -from .projects.project_models import ProjectDict -from .projects.projects_utils import NodesMap -from .storage_settings import StorageSettings, get_plugin_settings +from ..projects.project_models import ProjectDict +from ..projects.projects_utils import NodesMap +from .settings import StorageSettings, get_plugin_settings log = logging.getLogger(__name__) diff --git a/services/web/server/src/simcore_service_webserver/storage.py b/services/web/server/src/simcore_service_webserver/storage/plugin.py similarity index 88% rename from services/web/server/src/simcore_service_webserver/storage.py rename to services/web/server/src/simcore_service_webserver/storage/plugin.py index 1ea2ece64c2..137f0822063 100644 --- a/services/web/server/src/simcore_service_webserver/storage.py +++ b/services/web/server/src/simcore_service_webserver/storage/plugin.py @@ -8,7 +8,7 @@ from servicelib.aiohttp.application_keys import APP_OPENAPI_SPECS_KEY from servicelib.aiohttp.application_setup import ModuleCategory, app_module_setup -from . import storage_routes +from . import _routes log = logging.getLogger(__name__) @@ -20,5 +20,5 @@ def setup_storage(app: web.Application): specs = app[APP_OPENAPI_SPECS_KEY] # validated openapi specs - routes = storage_routes.create(specs) + routes = _routes.create(specs) app.router.add_routes(routes) diff --git a/services/web/server/src/simcore_service_webserver/storage_schemas.py b/services/web/server/src/simcore_service_webserver/storage/schemas.py similarity index 74% rename from services/web/server/src/simcore_service_webserver/storage_schemas.py rename to services/web/server/src/simcore_service_webserver/storage/schemas.py index 102fe30d167..5b67981d0d3 100644 --- a/services/web/server/src/simcore_service_webserver/storage_schemas.py +++ b/services/web/server/src/simcore_service_webserver/storage/schemas.py @@ -1,12 +1,12 @@ from enum import Enum -from typing import Any, Optional +from typing import Any -from pydantic import BaseModel, Field, conint +from pydantic import BaseModel, Field class FileLocation(BaseModel): - name: Optional[str] = None - id: Optional[float] = None + name: str | None = None + id: float | None = None class Config: schema_extra = { @@ -22,8 +22,8 @@ class FileLocationArray(BaseModel): class TableSynchronisation(BaseModel): - dry_run: Optional[bool] = None - fire_and_forget: Optional[bool] = None + dry_run: bool | None = None + fire_and_forget: bool | None = None removed: list[str] @@ -33,7 +33,7 @@ class Links(BaseModel): class FileUploadSchema(BaseModel): - chunk_size: conint(ge=0) + chunk_size: int = Field(..., ge=0) urls: list[str] links: Links @@ -53,12 +53,12 @@ class State(str, Enum): class FileUploadCompleteFuture(BaseModel): state: State - e_tag: Optional[str] = None + e_tag: str | None = None class DatasetMetaData(BaseModel): - dataset_id: Optional[str] = None - display_name: Optional[str] = None + dataset_id: str | None = None + display_name: str | None = None class Config: schema_extra = { @@ -75,7 +75,7 @@ class DatasetMetaDataArray(BaseModel): class FileLocationEnveloped(BaseModel): data: FileLocation - error: Optional[Any] = None + error: Any | None = None class TableSynchronisationEnveloped(BaseModel): @@ -100,7 +100,7 @@ class FileUploadCompleteFutureEnveloped(BaseModel): class DatasetMetaEnvelope(BaseModel): data: DatasetMetaData - error: Optional[Any] = None + error: Any | None = None class CompleteUpload(BaseModel): @@ -109,16 +109,16 @@ class CompleteUpload(BaseModel): class FileMetaData(BaseModel): - file_uuid: Optional[str] = None - location_id: Optional[str] = None - project_name: Optional[str] = None - node_name: Optional[str] = None - file_name: Optional[str] = None - file_id: Optional[str] = None - created_at: Optional[str] = None - last_modified: Optional[str] = None - file_size: Optional[int] = None - entity_tag: Optional[str] = None + file_uuid: str | None = None + location_id: str | None = None + project_name: str | None = None + node_name: str | None = None + file_name: str | None = None + file_id: str | None = None + created_at: str | None = None + last_modified: str | None = None + file_size: int | None = None + entity_tag: str | None = None class Config: schema_extra = { @@ -143,11 +143,11 @@ class FileMetaDataArray(BaseModel): class FileMetaEnvelope(BaseModel): data: FileMetaData - error: Optional[Any] = None + error: Any | None = None class PresignedLink(BaseModel): - link: Optional[str] = None + link: str | None = None class Config: schema_extra = {"example": {"link": "example_link"}} @@ -155,4 +155,4 @@ class Config: class PresignedLinkEnveloped(BaseModel): data: PresignedLink - error: Optional[Any] = None + error: Any | None = None diff --git a/services/web/server/src/simcore_service_webserver/storage_settings.py b/services/web/server/src/simcore_service_webserver/storage/settings.py similarity index 95% rename from services/web/server/src/simcore_service_webserver/storage_settings.py rename to services/web/server/src/simcore_service_webserver/storage/settings.py index c123269773c..04ac00f61c3 100644 --- a/services/web/server/src/simcore_service_webserver/storage_settings.py +++ b/services/web/server/src/simcore_service_webserver/storage/settings.py @@ -6,7 +6,7 @@ from settings_library.utils_service import DEFAULT_AIOHTTP_PORT, MixinServiceSettings from yarl import URL -from ._constants import APP_SETTINGS_KEY +from .._constants import APP_SETTINGS_KEY class StorageSettings(BaseCustomSettings, MixinServiceSettings): diff --git a/services/web/server/tests/unit/isolated/test_storage_schemas.py b/services/web/server/tests/unit/isolated/test_storage_schemas.py index 64bc4cc1d1f..c11ce1f1345 100644 --- a/services/web/server/tests/unit/isolated/test_storage_schemas.py +++ b/services/web/server/tests/unit/isolated/test_storage_schemas.py @@ -7,14 +7,14 @@ from typing import Any import pytest -import simcore_service_webserver.storage_schemas +import simcore_service_webserver.storage.schemas from pydantic import BaseModel from pytest_simcore.pydantic_models import iter_model_examples_in_module @pytest.mark.parametrize( "model_cls, example_name, example_data", - iter_model_examples_in_module(simcore_service_webserver.storage_schemas), + iter_model_examples_in_module(simcore_service_webserver.storage.schemas), ) def test_model_examples( model_cls: type[BaseModel], example_name: int, example_data: Any From bd0b93203afdeaa948768aab3030002b290a65bf Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Sun, 7 May 2023 20:33:17 +0200 Subject: [PATCH 2/5] fix --- .../studies_dispatcher/_studies_access.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/server/src/simcore_service_webserver/studies_dispatcher/_studies_access.py b/services/web/server/src/simcore_service_webserver/studies_dispatcher/_studies_access.py index e1b4f2a88fa..0f8d033c720 100644 --- a/services/web/server/src/simcore_service_webserver/studies_dispatcher/_studies_access.py +++ b/services/web/server/src/simcore_service_webserver/studies_dispatcher/_studies_access.py @@ -40,7 +40,7 @@ ) from ..redis import get_redis_lock_manager_client from ..security.api import is_anonymous, remember -from ..storage_api import copy_data_folders_from_project +from ..storage.api import copy_data_folders_from_project from ..utils import compose_support_error_msg from ..utils_aiohttp import create_redirect_response from ._constants import ( From b611c3d43e209855eb36a417af784962a9d365fa Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Mon, 8 May 2023 08:00:01 +0200 Subject: [PATCH 3/5] code smells --- .../src/simcore_service_webserver/storage/_handlers.py | 2 -- .../server/src/simcore_service_webserver/storage/_routes.py | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/services/web/server/src/simcore_service_webserver/storage/_handlers.py b/services/web/server/src/simcore_service_webserver/storage/_handlers.py index 97e0fdef078..300381f0cb4 100644 --- a/services/web/server/src/simcore_service_webserver/storage/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/storage/_handlers.py @@ -52,7 +52,6 @@ def _resolve_storage_url(request: web.Request) -> URL: # ('asdf', '') suffix = "/".join(request.url.raw_parts[BASEPATH_INDEX:]) - # TODO: check request.query to storage! unsafe!? url = (endpoint / suffix).with_query(request.query).update_query(user_id=userid) return url @@ -69,7 +68,6 @@ async def _request_storage( await extract_and_validate(request) url = _resolve_storage_url(request) - # _token_data, _token_secret = _get_token_key_and_secret(request) body = None if request.can_read_body: diff --git a/services/web/server/src/simcore_service_webserver/storage/_routes.py b/services/web/server/src/simcore_service_webserver/storage/_routes.py index f68652747d4..e7ba61e1134 100644 --- a/services/web/server/src/simcore_service_webserver/storage/_routes.py +++ b/services/web/server/src/simcore_service_webserver/storage/_routes.py @@ -14,14 +14,14 @@ def create(specs: openapi.Spec) -> list[web.RouteDef]: - # TODO: consider the case in which server creates routes for both v0 and v1!!! - # TODO: should this be taken from servers instead? + # NOTE: consider the case in which server creates routes for both v0 and v1!!! + # NOTE: should this be taken from servers instead? BASEPATH = "/v" + specs.info.version.split(".")[0] log.debug("creating %s ", __name__) routes = [] - # TODO: routing will be done automatically using operation_id/tags, etc... + # NOTE: routing will be done automatically using operation_id/tags, etc... # storage -- path, handler = "/storage/locations", _handlers.get_storage_locations From c0de7d884c2b409014eb9a416ed33b4fb4c62b7c Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Tue, 9 May 2023 10:07:10 +0200 Subject: [PATCH 4/5] str change --- .../server/src/simcore_service_webserver/storage/_handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/server/src/simcore_service_webserver/storage/_handlers.py b/services/web/server/src/simcore_service_webserver/storage/_handlers.py index 300381f0cb4..eb81c18bf81 100644 --- a/services/web/server/src/simcore_service_webserver/storage/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/storage/_handlers.py @@ -109,7 +109,7 @@ def extract_link(data: dict | None) -> str: if data is None or "link" not in data: raise web.HTTPException(reason=f"No url found in response: '{data}'") - return parse_obj_as(str, data["link"]) + return f"{data['link']}" # --------------------------------------------------------------------- From 56825f6e5704d04d29241edcc782d276a6f7f47b Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Tue, 9 May 2023 10:10:17 +0200 Subject: [PATCH 5/5] formating --- .../web/server/src/simcore_service_webserver/login/storage.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/web/server/src/simcore_service_webserver/login/storage.py b/services/web/server/src/simcore_service_webserver/login/storage.py index 076addd5fc6..6c61761a0b1 100644 --- a/services/web/server/src/simcore_service_webserver/login/storage.py +++ b/services/web/server/src/simcore_service_webserver/login/storage.py @@ -98,7 +98,9 @@ async def get_confirmation(self, filter_dict) -> ConfirmationTokenDict | None: filter_dict["user_id"] = filter_dict.pop("user")["id"] async with self.pool.acquire() as conn: confirmation = await _sql.find_one(conn, self.confirm_tbl, filter_dict) - confirmation_token: ConfirmationTokenDict | None = ConfirmationTokenDict(**confirmation) if confirmation else None # type: ignore[misc] + confirmation_token: ConfirmationTokenDict | None = ( + ConfirmationTokenDict(**confirmation) if confirmation else None # type: ignore[misc] + ) return confirmation_token async def delete_confirmation(self, confirmation: ConfirmationTokenDict):