From 8f4c1b22c1a759c54d85f82102c5f068096eac8f Mon Sep 17 00:00:00 2001 From: Sylvain <35365065+sanderegg@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:28:19 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=EF=B8=8FComputation=20backend:=20?= =?UTF-8?q?clean=20comp=5Ftasks=20DB=20(=F0=9F=97=83=EF=B8=8F)=20(#6968)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .codecov.yml | 10 +++---- .../postgres-database/requirements/_test.in | 1 + .../postgres-database/requirements/_test.txt | 8 ++++- .../52a0e8148dd5_remove_submit_timestamp.py | 28 ++++++++++++++++++ .../models/comp_tasks.py | 4 --- .../pytest_simcore/helpers/faker_factories.py | 8 ++--- .../api/routes/computations.py | 12 +++----- .../models/comp_tasks.py | 4 +-- .../db/repositories/comp_tasks/_utils.py | 29 +++++++++---------- .../simcore_service_director_v2/utils/dags.py | 11 ------- .../director-v2/tests/mocks/fake_task.json | 1 - .../director-v2/tests/unit/test_utils_dags.py | 20 +++++-------- .../test_api_route_computations.py | 15 ++++------ .../tests/unit/with_dbs/conftest.py | 1 - 14 files changed, 78 insertions(+), 74 deletions(-) create mode 100644 packages/postgres-database/src/simcore_postgres_database/migration/versions/52a0e8148dd5_remove_submit_timestamp.py diff --git a/.codecov.yml b/.codecov.yml index eb2e6697348..f4a4f9cbcf4 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -10,10 +10,10 @@ flag_management: statuses: - type: project target: auto - threshold: 2% + threshold: 5% - type: patch target: auto - threshold: 2% + threshold: 5% component_management: @@ -22,7 +22,7 @@ component_management: statuses: - type: project target: auto - threshold: 2% + threshold: 5% branches: - "!master" individual_components: @@ -116,12 +116,12 @@ coverage: project: default: informational: true - threshold: 2% + threshold: 5% patch: default: informational: true - threshold: 2% + threshold: 5% comment: layout: "header,diff,flags,components,footer" diff --git a/packages/postgres-database/requirements/_test.in b/packages/postgres-database/requirements/_test.in index 3249c9c02b2..d0b7af019df 100644 --- a/packages/postgres-database/requirements/_test.in +++ b/packages/postgres-database/requirements/_test.in @@ -10,6 +10,7 @@ --constraint _migration.txt aiopg[sa] +arrow coverage faker pytest diff --git a/packages/postgres-database/requirements/_test.txt b/packages/postgres-database/requirements/_test.txt index 49636a365c3..6b6c490ce72 100644 --- a/packages/postgres-database/requirements/_test.txt +++ b/packages/postgres-database/requirements/_test.txt @@ -1,5 +1,7 @@ aiopg==1.4.0 # via -r requirements/_test.in +arrow==1.3.0 + # via -r requirements/_test.in async-timeout==4.0.3 # via # -c requirements/_base.txt @@ -52,7 +54,9 @@ pytest-instafail==0.5.0 pytest-runner==6.0.1 # via -r requirements/_test.in python-dateutil==2.9.0.post0 - # via faker + # via + # arrow + # faker pyyaml==6.0.2 # via # -c requirements/../../../requirements/constraints.txt @@ -72,6 +76,8 @@ types-docker==7.1.0.20240827 # via -r requirements/_test.in types-psycopg2==2.9.21.20241019 # via -r requirements/_test.in +types-python-dateutil==2.9.0.20241206 + # via arrow types-requests==2.32.0.20241016 # via types-docker typing-extensions==4.12.2 diff --git a/packages/postgres-database/src/simcore_postgres_database/migration/versions/52a0e8148dd5_remove_submit_timestamp.py b/packages/postgres-database/src/simcore_postgres_database/migration/versions/52a0e8148dd5_remove_submit_timestamp.py new file mode 100644 index 00000000000..8589578abe7 --- /dev/null +++ b/packages/postgres-database/src/simcore_postgres_database/migration/versions/52a0e8148dd5_remove_submit_timestamp.py @@ -0,0 +1,28 @@ +"""remove submit timestamp + +Revision ID: 52a0e8148dd5 +Revises: 77ac824a77ff +Create Date: 2024-12-16 14:55:15.114923+00:00 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '52a0e8148dd5' +down_revision = '77ac824a77ff' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('comp_tasks', 'submit') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('comp_tasks', sa.Column('submit', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True)) + # ### end Alembic commands ### diff --git a/packages/postgres-database/src/simcore_postgres_database/models/comp_tasks.py b/packages/postgres-database/src/simcore_postgres_database/models/comp_tasks.py index af5dc451cc3..8389495d9b6 100644 --- a/packages/postgres-database/src/simcore_postgres_database/models/comp_tasks.py +++ b/packages/postgres-database/src/simcore_postgres_database/models/comp_tasks.py @@ -77,10 +77,6 @@ class NodeClass(enum.Enum): nullable=True, doc="current progress of the task if available", ), - # utc timestamps for submission/start/end - sa.Column( - "submit", sa.DateTime(timezone=True), doc="UTC timestamp for task submission" - ), sa.Column( "start", sa.DateTime(timezone=True), doc="UTC timestamp when task started" ), diff --git a/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py b/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py index d4418a5ef81..803987b3b8a 100644 --- a/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py +++ b/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py @@ -16,10 +16,11 @@ import json import random from collections.abc import Callable -from datetime import datetime, timedelta, timezone +from datetime import UTC, datetime, timedelta from typing import Any, Final from uuid import uuid4 +import arrow import faker from faker import Faker @@ -182,7 +183,7 @@ def fake_task_factory(first_internal_id=1) -> Callable: _index_in_sequence = itertools.count(start=first_internal_id) def fake_task(**overrides) -> dict[str, Any]: - t0 = datetime.utcnow() + t0 = arrow.utcnow().datetime data = { "project_id": uuid4(), "node_id": uuid4(), @@ -193,7 +194,6 @@ def fake_task(**overrides) -> dict[str, Any]: "outputs": json.dumps({}), "image": json.dumps({}), "state": random.choice(_get_comp_pipeline_test_states()), - "submit": t0, "start": t0 + timedelta(seconds=1), "end": t0 + timedelta(minutes=5), } @@ -251,7 +251,7 @@ def random_product( def utcnow() -> datetime: - return datetime.now(tz=timezone.utc) + return datetime.now(tz=UTC) def random_payment_method( diff --git a/services/director-v2/src/simcore_service_director_v2/api/routes/computations.py b/services/director-v2/src/simcore_service_director_v2/api/routes/computations.py index f0b6e635ac7..707d7a8cc1e 100644 --- a/services/director-v2/src/simcore_service_director_v2/api/routes/computations.py +++ b/services/director-v2/src/simcore_service_director_v2/api/routes/computations.py @@ -1,4 +1,4 @@ -""" CRUD operations on a "computation" resource +"""CRUD operations on a "computation" resource A computation is a resource that represents a running pipeline of computational services in a give project Therefore, @@ -15,7 +15,6 @@ # pylint: disable=too-many-arguments # pylint: disable=too-many-statements - import contextlib import logging from typing import Annotated, Any, Final @@ -75,7 +74,6 @@ compute_pipeline_details, compute_pipeline_started_timestamp, compute_pipeline_stopped_timestamp, - compute_pipeline_submitted_timestamp, create_complete_dag, create_complete_dag_from_tasks, create_minimal_computational_graph_based_on_selection, @@ -396,9 +394,7 @@ async def create_computation( # noqa: PLR0913 # pylint: disable=too-many-positi stopped=compute_pipeline_stopped_timestamp( minimal_computational_dag, comp_tasks ), - submitted=compute_pipeline_submitted_timestamp( - minimal_computational_dag, comp_tasks - ), + submitted=last_run.created if last_run else None, ) except ProjectNotFoundError as e: @@ -498,7 +494,7 @@ async def get_computation( result=None, started=compute_pipeline_started_timestamp(pipeline_dag, all_tasks), stopped=compute_pipeline_stopped_timestamp(pipeline_dag, all_tasks), - submitted=compute_pipeline_submitted_timestamp(pipeline_dag, all_tasks), + submitted=last_run.created if last_run else None, ) @@ -572,7 +568,7 @@ async def stop_computation( result=None, started=compute_pipeline_started_timestamp(pipeline_dag, tasks), stopped=compute_pipeline_stopped_timestamp(pipeline_dag, tasks), - submitted=compute_pipeline_submitted_timestamp(pipeline_dag, tasks), + submitted=last_run.created if last_run else None, ) except ProjectNotFoundError as e: diff --git a/services/director-v2/src/simcore_service_director_v2/models/comp_tasks.py b/services/director-v2/src/simcore_service_director_v2/models/comp_tasks.py index 4bf9e1e30af..2b646cf424e 100644 --- a/services/director-v2/src/simcore_service_director_v2/models/comp_tasks.py +++ b/services/director-v2/src/simcore_service_director_v2/models/comp_tasks.py @@ -128,7 +128,6 @@ class CompTaskAtDB(BaseModel): description="the hex digest of the resolved inputs +outputs hash at the time when the last outputs were generated", ) image: Image - submit: dt.datetime start: dt.datetime | None = None end: dt.datetime | None = None state: RunningState @@ -163,7 +162,7 @@ def _convert_state_from_state_type_enum_if_needed(cls, v): return RunningState(DB_TO_RUNNING_STATE[StateType(v)]) return v - @field_validator("start", "end", "submit") + @field_validator("start", "end") @classmethod def _ensure_utc(cls, v: dt.datetime | None) -> dt.datetime | None: if v is not None and v.tzinfo is None: @@ -228,7 +227,6 @@ def to_db_model(self, **exclusion_rules) -> dict[str, Any]: } }, "image": image_example, - "submit": "2021-03-01 13:07:34.19161", "node_class": "INTERACTIVE", "state": "NOT_STARTED", "progress": 0.44, diff --git a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks/_utils.py b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks/_utils.py index 2619d9ce98f..b703691926f 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks/_utils.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks/_utils.py @@ -145,12 +145,12 @@ async def _get_node_infos( None, ) - result: tuple[ServiceMetaDataPublished, ServiceExtras, SimcoreServiceLabels] = ( - await asyncio.gather( - _get_service_details(catalog_client, user_id, product_name, node), - director_client.get_service_extras(node.key, node.version), - director_client.get_service_labels(node), - ) + result: tuple[ + ServiceMetaDataPublished, ServiceExtras, SimcoreServiceLabels + ] = await asyncio.gather( + _get_service_details(catalog_client, user_id, product_name, node), + director_client.get_service_extras(node.key, node.version), + director_client.get_service_labels(node), ) return result @@ -246,9 +246,9 @@ async def _get_pricing_and_hardware_infos( return pricing_info, hardware_info -_RAM_SAFE_MARGIN_RATIO: Final[float] = ( - 0.1 # NOTE: machines always have less available RAM than advertised -) +_RAM_SAFE_MARGIN_RATIO: Final[ + float +] = 0.1 # NOTE: machines always have less available RAM than advertised _CPUS_SAFE_MARGIN: Final[float] = 0.1 @@ -266,11 +266,11 @@ async def _update_project_node_resources_from_hardware_info( if not hardware_info.aws_ec2_instances: return try: - unordered_list_ec2_instance_types: list[EC2InstanceTypeGet] = ( - await get_instance_type_details( - rabbitmq_rpc_client, - instance_type_names=set(hardware_info.aws_ec2_instances), - ) + unordered_list_ec2_instance_types: list[ + EC2InstanceTypeGet + ] = await get_instance_type_details( + rabbitmq_rpc_client, + instance_type_names=set(hardware_info.aws_ec2_instances), ) assert unordered_list_ec2_instance_types # nosec @@ -439,7 +439,6 @@ async def generate_tasks_list_from_project( inputs=node.inputs, outputs=node.outputs, image=image, - submit=arrow.utcnow().datetime, state=task_state, internal_id=internal_id, node_class=to_node_class(node.key), diff --git a/services/director-v2/src/simcore_service_director_v2/utils/dags.py b/services/director-v2/src/simcore_service_director_v2/utils/dags.py index 07d60e82fd5..2b8593fce07 100644 --- a/services/director-v2/src/simcore_service_director_v2/utils/dags.py +++ b/services/director-v2/src/simcore_service_director_v2/utils/dags.py @@ -217,17 +217,6 @@ def compute_pipeline_stopped_timestamp( return pipeline_stopped_at -def compute_pipeline_submitted_timestamp( - pipeline_dag: nx.DiGraph, comp_tasks: list[CompTaskAtDB] -) -> datetime.datetime | None: - if not pipeline_dag.nodes: - return None - node_id_to_comp_task: dict[NodeIDStr, CompTaskAtDB] = { - NodeIDStr(f"{task.node_id}"): task for task in comp_tasks - } - return max(node_id_to_comp_task[node_id].submit for node_id in pipeline_dag.nodes) - - async def compute_pipeline_details( complete_dag: nx.DiGraph, pipeline_dag: nx.DiGraph, comp_tasks: list[CompTaskAtDB] ) -> PipelineDetails: diff --git a/services/director-v2/tests/mocks/fake_task.json b/services/director-v2/tests/mocks/fake_task.json index 00a9dfe3501..57d7a4c2837 100644 --- a/services/director-v2/tests/mocks/fake_task.json +++ b/services/director-v2/tests/mocks/fake_task.json @@ -50,7 +50,6 @@ "requires_gpu": false, "requires_mpi": true }, - "submit": "1994-11-10T19:23:02.115Z", "state": "PUBLISHED", "internal_id": 21107840, "node_class": "COMPUTATIONAL", diff --git a/services/director-v2/tests/unit/test_utils_dags.py b/services/director-v2/tests/unit/test_utils_dags.py index 11975ac9e88..0fc17030a2d 100644 --- a/services/director-v2/tests/unit/test_utils_dags.py +++ b/services/director-v2/tests/unit/test_utils_dags.py @@ -485,9 +485,8 @@ def pipeline_test_params( state=RunningState.NOT_STARTED, internal_id=3, node_class=NodeClass.COMPUTATIONAL, - submit=datetime.datetime.now(tz=datetime.timezone.utc), - created=datetime.datetime.now(tz=datetime.timezone.utc), - modified=datetime.datetime.now(tz=datetime.timezone.utc), + created=datetime.datetime.now(tz=datetime.UTC), + modified=datetime.datetime.now(tz=datetime.UTC), last_heartbeat=None, progress=1.00, ) @@ -536,9 +535,8 @@ def pipeline_test_params( state=RunningState.NOT_STARTED, internal_id=3, node_class=NodeClass.COMPUTATIONAL, - submit=datetime.datetime.now(tz=datetime.timezone.utc), - created=datetime.datetime.now(tz=datetime.timezone.utc), - modified=datetime.datetime.now(tz=datetime.timezone.utc), + created=datetime.datetime.now(tz=datetime.UTC), + modified=datetime.datetime.now(tz=datetime.UTC), last_heartbeat=None, ), CompTaskAtDB.model_construct( @@ -550,9 +548,8 @@ def pipeline_test_params( state=RunningState.NOT_STARTED, internal_id=3, node_class=NodeClass.COMPUTATIONAL, - submit=datetime.datetime.now(tz=datetime.timezone.utc), - created=datetime.datetime.now(tz=datetime.timezone.utc), - modified=datetime.datetime.now(tz=datetime.timezone.utc), + created=datetime.datetime.now(tz=datetime.UTC), + modified=datetime.datetime.now(tz=datetime.UTC), last_heartbeat=None, ), CompTaskAtDB.model_construct( @@ -564,9 +561,8 @@ def pipeline_test_params( state=RunningState.NOT_STARTED, internal_id=3, node_class=NodeClass.COMPUTATIONAL, - submit=datetime.datetime.now(tz=datetime.timezone.utc), - created=datetime.datetime.now(tz=datetime.timezone.utc), - modified=datetime.datetime.now(tz=datetime.timezone.utc), + created=datetime.datetime.now(tz=datetime.UTC), + modified=datetime.datetime.now(tz=datetime.UTC), last_heartbeat=None, progress=1.00, ), diff --git a/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_route_computations.py b/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_route_computations.py index 4c8ed5f4b78..2d076c3fdf0 100644 --- a/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_route_computations.py +++ b/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_route_computations.py @@ -258,7 +258,11 @@ def _mocked_services_details( ).isoformat() } - data = {**ServiceGet.model_config["json_schema_extra"]["examples"][0], **data_published, **deprecated} # type: ignore + data = { + **ServiceGet.model_config["json_schema_extra"]["examples"][0], + **data_published, + **deprecated, + } # type: ignore payload = ServiceGet.model_validate(data) @@ -354,7 +358,6 @@ def _mocked_get_pricing_unit(request, pricing_plan_id: int) -> httpx.Response: assert_all_called=False, assert_all_mocked=True, ) as respx_mock: - respx_mock.get( re.compile( r"services/(?Psimcore/services/(comp|dynamic|frontend)/[^/]+)/(?P[^\.]+.[^\.]+.[^/\?]+)/pricing-plan.+" @@ -915,13 +918,7 @@ async def test_get_computation_from_not_started_computation_task( stopped=None, submitted=None, ) - _CHANGED_FIELDS = {"submitted"} - assert returned_computation.model_dump( - exclude=_CHANGED_FIELDS - ) == expected_computation.model_dump(exclude=_CHANGED_FIELDS) - assert returned_computation.model_dump( - include=_CHANGED_FIELDS - ) != expected_computation.model_dump(include=_CHANGED_FIELDS) + assert returned_computation == expected_computation async def test_get_computation_from_published_computation_task( diff --git a/services/director-v2/tests/unit/with_dbs/conftest.py b/services/director-v2/tests/unit/with_dbs/conftest.py index 703686d2526..9b0d03e6eed 100644 --- a/services/director-v2/tests/unit/with_dbs/conftest.py +++ b/services/director-v2/tests/unit/with_dbs/conftest.py @@ -118,7 +118,6 @@ async def _( ), "node_class": to_node_class(node_data.key), "internal_id": internal_id + 1, - "submit": datetime.datetime.now(datetime.UTC), "job_id": generate_dask_job_id( service_key=node_data.key, service_version=node_data.version, From f7e3e86f2ee896d6ba390f1305b10dc459bda78b Mon Sep 17 00:00:00 2001 From: Mads Bisgaard <126242332+bisgaard-itis@users.noreply.github.com> Date: Wed, 18 Dec 2024 07:15:53 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Update=20webserver's=20swagg?= =?UTF-8?q?er=20ui=20(#6971)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/web/server/requirements/_base.in | 2 +- services/web/server/requirements/_base.txt | 41 +++---------------- .../simcore_service_webserver/rest/plugin.py | 12 +++--- .../tests/unit/isolated/test_diagnostics.py | 5 ++- 4 files changed, 16 insertions(+), 44 deletions(-) diff --git a/services/web/server/requirements/_base.in b/services/web/server/requirements/_base.in index 308a1604cb3..caf883fc166 100644 --- a/services/web/server/requirements/_base.in +++ b/services/web/server/requirements/_base.in @@ -27,7 +27,6 @@ aiohttp aiohttp_jinja2 aiohttp_security aiohttp_session[secure] -aiohttp-swagger[performance] aiopg[sa] # db aiosmtplib # email asyncpg # db @@ -50,5 +49,6 @@ pydantic[email] # models python-magic # excel python-socketio # web-sockets redis +swagger-ui-py tenacity twilio diff --git a/services/web/server/requirements/_base.txt b/services/web/server/requirements/_base.txt index ada75776f9e..810e6e29fad 100644 --- a/services/web/server/requirements/_base.txt +++ b/services/web/server/requirements/_base.txt @@ -61,15 +61,12 @@ aiohttp==3.8.5 # aiohttp-jinja2 # aiohttp-security # aiohttp-session - # aiohttp-swagger aiohttp-jinja2==1.5 # via -r requirements/_base.in aiohttp-security==0.4.0 # via -r requirements/_base.in aiohttp-session==2.11.0 # via -r requirements/_base.in -aiohttp-swagger==1.0.16 - # via -r requirements/_base.in aiopg==1.4.0 # via # -r requirements/../../../../packages/service-library/requirements/_aiohttp.in @@ -269,7 +266,7 @@ jinja2==3.1.2 # -c requirements/../../../../packages/simcore-sdk/requirements/../../../requirements/constraints.txt # -c requirements/../../../../requirements/constraints.txt # aiohttp-jinja2 - # aiohttp-swagger + # swagger-ui-py json2html==1.3.0 # via -r requirements/_base.in jsondiff==2.0.0 @@ -473,6 +470,7 @@ packaging==24.1 # -r requirements/../../../../packages/simcore-sdk/requirements/_base.in # -r requirements/_base.in # gunicorn + # swagger-ui-py pamqp==3.2.1 # via aiormq passlib==1.7.4 @@ -651,7 +649,7 @@ pyyaml==6.0.1 # -c requirements/../../../../requirements/constraints.txt # -r requirements/../../../../packages/service-library/requirements/_base.in # -r requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/_base.in - # aiohttp-swagger + # swagger-ui-py redis==5.0.4 # via # -c requirements/../../../../packages/common-library/requirements/../../../requirements/constraints.txt @@ -748,6 +746,8 @@ sqlalchemy==1.4.47 # -r requirements/../../../../packages/simcore-sdk/requirements/../../../packages/postgres-database/requirements/_base.in # aiopg # alembic +swagger-ui-py==23.9.23 + # via -r requirements/_base.in tenacity==8.5.0 # via # -r requirements/../../../../packages/service-library/requirements/_base.in @@ -783,37 +783,6 @@ typing-extensions==4.12.2 # pydantic # pydantic-core # typer -ujson==5.5.0 - # via - # -c requirements/../../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/postgres-database/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/postgres-database/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/postgres-database/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/postgres-database/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../requirements/constraints.txt - # aiohttp-swagger urllib3==2.2.3 # via # -c requirements/../../../../packages/common-library/requirements/../../../requirements/constraints.txt diff --git a/services/web/server/src/simcore_service_webserver/rest/plugin.py b/services/web/server/src/simcore_service_webserver/rest/plugin.py index 833023d6df9..9d23181a814 100644 --- a/services/web/server/src/simcore_service_webserver/rest/plugin.py +++ b/services/web/server/src/simcore_service_webserver/rest/plugin.py @@ -9,12 +9,12 @@ import logging from aiohttp import web -from aiohttp_swagger import setup_swagger # type: ignore[import-untyped] from servicelib.aiohttp.application_setup import ModuleCategory, app_module_setup from servicelib.aiohttp.rest_middlewares import ( envelope_middleware_factory, error_middleware_factory, ) +from swagger_ui import api_doc # type: ignore from .._meta import API_VTAG from ..security.plugin import setup_security @@ -60,11 +60,11 @@ def setup_rest(app: web.Application): # _logger.debug("OAS loaded from %s ", spec_path) if settings.REST_SWAGGER_API_DOC_ENABLED: - setup_swagger( - app, - swagger_url="/dev/doc", - swagger_from_file=str(spec_path), - ui_version=3, + api_doc( + app=app, + url_prefix="/dev/doc", + config_path=str(spec_path), + title="Web-API doc", ) diff --git a/services/web/server/tests/unit/isolated/test_diagnostics.py b/services/web/server/tests/unit/isolated/test_diagnostics.py index 3f18e81fd09..fdd08db062d 100644 --- a/services/web/server/tests/unit/isolated/test_diagnostics.py +++ b/services/web/server/tests/unit/isolated/test_diagnostics.py @@ -6,6 +6,7 @@ from unittest.mock import Mock import pytest +from pytest_mock import MockerFixture from servicelib.aiohttp.application_setup import APP_SETUP_COMPLETED_KEY from simcore_service_webserver.application_settings import setup_settings from simcore_service_webserver.diagnostics.plugin import setup_diagnostics @@ -35,12 +36,14 @@ def add_routes(self, *args, **kwargs): @pytest.fixture -def app_mock(): +def app_mock(mocker: MockerFixture): app = MockApp() # emulates security is initialized app[APP_SETUP_COMPLETED_KEY] = ["simcore_service_webserver.security"] + mocker.patch("simcore_service_webserver.rest.plugin.api_doc") + return app