diff --git a/services/api-server/src/simcore_service_api_server/api/dependencies/webserver.py b/services/api-server/src/simcore_service_api_server/api/dependencies/webserver_http.py similarity index 100% rename from services/api-server/src/simcore_service_api_server/api/dependencies/webserver.py rename to services/api-server/src/simcore_service_api_server/api/dependencies/webserver_http.py diff --git a/services/api-server/src/simcore_service_api_server/api/routes/credits.py b/services/api-server/src/simcore_service_api_server/api/routes/credits.py index 5b5258cfb01..36069b54988 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/credits.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/credits.py @@ -3,7 +3,7 @@ from fastapi import APIRouter, Depends, status from ...models.schemas.model_adapter import GetCreditPriceLegacy -from ..dependencies.webserver import AuthSession, get_webserver_session +from ..dependencies.webserver_http import AuthSession, get_webserver_session from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION router = APIRouter() diff --git a/services/api-server/src/simcore_service_api_server/api/routes/solvers.py b/services/api-server/src/simcore_service_api_server/api/routes/solvers.py index 2ef1cea93e6..f9f80b37c4c 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/solvers.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/solvers.py @@ -17,7 +17,7 @@ from ..dependencies.application import get_reverse_url_mapper from ..dependencies.authentication import get_current_user_id, get_product_name from ..dependencies.services import get_api_client -from ..dependencies.webserver import AuthSession, get_webserver_session +from ..dependencies.webserver_http import AuthSession, get_webserver_session from ._common import API_SERVER_DEV_FEATURES_ENABLED from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION diff --git a/services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs.py b/services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs.py index a7a893ca244..609bf0b56a6 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs.py @@ -37,7 +37,7 @@ from ..dependencies.application import get_reverse_url_mapper from ..dependencies.authentication import get_current_user_id, get_product_name from ..dependencies.services import get_api_client -from ..dependencies.webserver import AuthSession, get_webserver_session +from ..dependencies.webserver_http import AuthSession, get_webserver_session from ._constants import ( FMSG_CHANGELOG_ADDED_IN_VERSION, FMSG_CHANGELOG_CHANGED_IN_VERSION, diff --git a/services/api-server/src/simcore_service_api_server/api/routes/studies.py b/services/api-server/src/simcore_service_api_server/api/routes/studies.py index 77d273d8233..f6483ea6531 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/studies.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/studies.py @@ -14,7 +14,7 @@ from ...models.schemas.errors import ErrorGet from ...models.schemas.studies import Study, StudyID, StudyPort from ...services_http.webserver import AuthSession -from ..dependencies.webserver import get_webserver_session +from ..dependencies.webserver_http import get_webserver_session _logger = logging.getLogger(__name__) router = APIRouter() diff --git a/services/api-server/src/simcore_service_api_server/api/routes/studies_jobs.py b/services/api-server/src/simcore_service_api_server/api/routes/studies_jobs.py index 11755e93640..f1e5513414b 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/studies_jobs.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/studies_jobs.py @@ -18,7 +18,6 @@ from ...api.dependencies.authentication import get_current_user_id from ...api.dependencies.services import get_api_client -from ...api.dependencies.webserver import get_webserver_session from ...exceptions.backend_errors import ProjectAlreadyStartedError from ...models.pagination import Page, PaginationParams from ...models.schemas.errors import ErrorGet @@ -48,6 +47,7 @@ ) from ...services_http.webserver import AuthSession from ..dependencies.application import get_reverse_url_mapper +from ..dependencies.webserver_http import get_webserver_session from ._common import API_SERVER_DEV_FEATURES_ENABLED from ._constants import FMSG_CHANGELOG_CHANGED_IN_VERSION, FMSG_CHANGELOG_NEW_IN_VERSION from .solvers_jobs import JOBS_STATUS_CODES diff --git a/services/api-server/src/simcore_service_api_server/api/routes/users.py b/services/api-server/src/simcore_service_api_server/api/routes/users.py index 14954a45285..1aee57c4648 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/users.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/users.py @@ -7,7 +7,7 @@ from ...models.schemas.errors import ErrorGet from ...models.schemas.profiles import Profile, ProfileUpdate from ...services_http.webserver import AuthSession -from ..dependencies.webserver import get_webserver_session +from ..dependencies.webserver_http import get_webserver_session _logger = logging.getLogger(__name__) diff --git a/services/api-server/src/simcore_service_api_server/api/routes/wallets.py b/services/api-server/src/simcore_service_api_server/api/routes/wallets.py index 40e2233fce0..ca34726eae3 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/wallets.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/wallets.py @@ -6,7 +6,7 @@ from ...exceptions.service_errors_utils import DEFAULT_BACKEND_SERVICE_STATUS_CODES from ...models.schemas.errors import ErrorGet from ...models.schemas.model_adapter import WalletGetWithAvailableCreditsLegacy -from ..dependencies.webserver import AuthSession, get_webserver_session +from ..dependencies.webserver_http import AuthSession, get_webserver_session from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION _logger = logging.getLogger(__name__) diff --git a/services/api-server/src/simcore_service_api_server/core/application.py b/services/api-server/src/simcore_service_api_server/core/application.py index 4de017698a6..847570db3d6 100644 --- a/services/api-server/src/simcore_service_api_server/core/application.py +++ b/services/api-server/src/simcore_service_api_server/core/application.py @@ -7,6 +7,7 @@ from servicelib.fastapi.profiler_middleware import ProfilerMiddleware from servicelib.fastapi.tracing import setup_tracing from servicelib.logging_utils import config_all_loggers +from simcore_service_api_server.api.dependencies.rabbitmq import get_rabbitmq_rpc_client from .. import exceptions from .._meta import API_VERSION, API_VTAG, APP_NAME @@ -14,6 +15,7 @@ from ..api.routes.health import router as health_router from ..services_http import catalog, director_v2, storage, webserver from ..services_http.rabbitmq import setup_rabbitmq +from ..services_rpc import wb_api_server from ._prometheus_instrumentation import setup_prometheus_instrumentation from .events import create_start_app_handler, create_stop_app_handler from .openapi import override_openapi_method, use_route_names_as_operation_ids @@ -92,6 +94,7 @@ def init_app(settings: ApplicationSettings | None = None) -> FastAPI: settings.API_SERVER_WEBSERVER, tracing_settings=settings.API_SERVER_TRACING, ) + wb_api_server.setup(app, get_rabbitmq_rpc_client(app)) if settings.API_SERVER_CATALOG: catalog.setup( diff --git a/services/api-server/src/simcore_service_api_server/services_http/jobs.py b/services/api-server/src/simcore_service_api_server/services_http/jobs.py index 277f9625f17..ed2ef50d588 100644 --- a/services/api-server/src/simcore_service_api_server/services_http/jobs.py +++ b/services/api-server/src/simcore_service_api_server/services_http/jobs.py @@ -9,7 +9,7 @@ from ..api.dependencies.authentication import get_current_user_id from ..api.dependencies.services import get_api_client -from ..api.dependencies.webserver import get_webserver_session +from ..api.dependencies.webserver_http import get_webserver_session from ..models.schemas.jobs import ( JobID, JobMetadata, diff --git a/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py b/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py index 8988185b5ac..33bd4c65ab6 100644 --- a/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py +++ b/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py @@ -1,5 +1,6 @@ from dataclasses import dataclass +from fastapi import FastAPI from fastapi_pagination import Page, create_page from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient from servicelib.rabbitmq.rpc_interfaces.webserver.licenses.licensed_items import ( @@ -31,3 +32,9 @@ async def get_licensed_items( total=licensed_items_page.total, params=page_params, ) + + +def setup(app: FastAPI, rabbitmq_rmp_client: RabbitMQRPCClient): + app.state.wb_api_rpc_client = WbApiRpcClient( + _rabbitmq_rpc_client=rabbitmq_rmp_client + )