forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Redirecting labels request via catalog in director-v2 (ITISFoundat…
…ion#7016) Co-authored-by: Andrei Neagu <[email protected]>
- Loading branch information
Showing
27 changed files
with
303 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.6.0 | ||
0.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
services/catalog/src/simcore_service_catalog/api/rest/_services_labels.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Annotated, Any | ||
|
||
from fastapi import APIRouter, Depends | ||
from models_library.services import ServiceKey, ServiceVersion | ||
|
||
from ...services.director import DirectorApi | ||
from ..dependencies.director import get_director_api | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/{service_key:path}/{service_version}/labels") | ||
async def get_service_labels( | ||
service_key: ServiceKey, | ||
service_version: ServiceVersion, | ||
director_client: Annotated[DirectorApi, Depends(get_director_api)], | ||
) -> dict[str, Any]: | ||
return await director_client.get_service_labels(service_key, service_version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,11 +393,41 @@ def mocked_director_service_api_base( | |
yield respx_mock | ||
|
||
|
||
@pytest.fixture | ||
def get_mocked_service_labels() -> Callable[[str, str], dict]: | ||
def _(service_key: str, service_version: str) -> dict: | ||
return { | ||
"io.simcore.authors": '{"authors": [{"name": "John Smith", "email": "[email protected]", "affiliation": "ACME\'IS Foundation"}]}', | ||
"io.simcore.contact": '{"contact": "[email protected]"}', | ||
"io.simcore.description": '{"description": "Autonomous Nervous System Network model"}', | ||
"io.simcore.inputs": '{"inputs": {"input_1": {"displayOrder": 1.0, "label": "Simulation time", "description": "Duration of the simulation", "type": "ref_contentSchema", "contentSchema": {"type": "number", "x_unit": "milli-second"}, "defaultValue": 2.0}}}', | ||
"io.simcore.integration-version": '{"integration-version": "1.0.0"}', | ||
"io.simcore.key": '{"key": "xxxxx"}'.replace("xxxxx", service_key), | ||
"io.simcore.name": '{"name": "Autonomous Nervous System Network model"}', | ||
"io.simcore.outputs": '{"outputs": {"output_1": {"displayOrder": 1.0, "label": "ANS output", "description": "Output of simulation of Autonomous Nervous System Network model", "type": "data:*/*", "fileToKeyMap": {"ANS_output.txt": "output_1"}}, "output_2": {"displayOrder": 2.0, "label": "Stimulation parameters", "description": "stim_param.txt file containing the input provided in the inputs port", "type": "data:*/*", "fileToKeyMap": {"ANS_stim_param.txt": "output_2"}}}}', | ||
"io.simcore.thumbnail": '{"thumbnail": "https://www.statnews.com/wp-content/uploads/2020/05/3D-rat-heart.-iScience--768x432.png"}', | ||
"io.simcore.type": '{"type": "computational"}', | ||
"io.simcore.version": '{"version": "xxxxx"}'.replace( | ||
"xxxxx", service_version | ||
), | ||
"maintainer": "johnsmith", | ||
"org.label-schema.build-date": "2023-04-17T08:04:15Z", | ||
"org.label-schema.schema-version": "1.0", | ||
"org.label-schema.vcs-ref": "", | ||
"org.label-schema.vcs-url": "", | ||
"simcore.service.restart-policy": "no-restart", | ||
"simcore.service.settings": '[{"name": "Resources", "type": "Resources", "value": {"Limits": {"NanoCPUs": 4000000000, "MemoryBytes": 2147483648}, "Reservations": {"NanoCPUs": 4000000000, "MemoryBytes": 2147483648}}}]', | ||
} | ||
|
||
return _ | ||
|
||
|
||
@pytest.fixture | ||
def mocked_director_service_api( | ||
mocked_director_service_api_base: respx.MockRouter, | ||
director_service_openapi_specs: dict[str, Any], | ||
expected_director_list_services: list[dict[str, Any]], | ||
get_mocked_service_labels: Callable[[str, str], dict], | ||
) -> respx.MockRouter: | ||
""" | ||
STANDARD fixture to mock director service API | ||
|
@@ -461,30 +491,7 @@ def _get_service_labels(request, service_key, service_version): | |
return httpx.Response( | ||
status_code=status.HTTP_200_OK, | ||
json={ | ||
"data": { | ||
"io.simcore.authors": '{"authors": [{"name": "John Smith", "email": "[email protected]", "affiliation": "ACME\'IS Foundation"}]}', | ||
"io.simcore.contact": '{"contact": "[email protected]"}', | ||
"io.simcore.description": '{"description": "Autonomous Nervous System Network model"}', | ||
"io.simcore.inputs": '{"inputs": {"input_1": {"displayOrder": 1.0, "label": "Simulation time", "description": "Duration of the simulation", "type": "ref_contentSchema", "contentSchema": {"type": "number", "x_unit": "milli-second"}, "defaultValue": 2.0}}}', | ||
"io.simcore.integration-version": '{"integration-version": "1.0.0"}', | ||
"io.simcore.key": '{"key": "xxxxx"}'.replace( | ||
"xxxxx", found["key"] | ||
), | ||
"io.simcore.name": '{"name": "Autonomous Nervous System Network model"}', | ||
"io.simcore.outputs": '{"outputs": {"output_1": {"displayOrder": 1.0, "label": "ANS output", "description": "Output of simulation of Autonomous Nervous System Network model", "type": "data:*/*", "fileToKeyMap": {"ANS_output.txt": "output_1"}}, "output_2": {"displayOrder": 2.0, "label": "Stimulation parameters", "description": "stim_param.txt file containing the input provided in the inputs port", "type": "data:*/*", "fileToKeyMap": {"ANS_stim_param.txt": "output_2"}}}}', | ||
"io.simcore.thumbnail": '{"thumbnail": "https://www.statnews.com/wp-content/uploads/2020/05/3D-rat-heart.-iScience--768x432.png"}', | ||
"io.simcore.type": '{"type": "computational"}', | ||
"io.simcore.version": '{"version": "xxxxx"}'.replace( | ||
"xxxxx", found["version"] | ||
), | ||
"maintainer": "iavarone", | ||
"org.label-schema.build-date": "2023-04-17T08:04:15Z", | ||
"org.label-schema.schema-version": "1.0", | ||
"org.label-schema.vcs-ref": "", | ||
"org.label-schema.vcs-url": "", | ||
"simcore.service.restart-policy": "no-restart", | ||
"simcore.service.settings": '[{"name": "Resources", "type": "Resources", "value": {"Limits": {"NanoCPUs": 4000000000, "MemoryBytes": 2147483648}, "Reservations": {"NanoCPUs": 4000000000, "MemoryBytes": 2147483648}}}]', | ||
} | ||
"data": get_mocked_service_labels(found["key"], found["version"]) | ||
}, | ||
) | ||
return httpx.Response( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# pylint: disable=redefined-outer-name | ||
# pylint: disable=unused-argument | ||
|
||
from collections.abc import Callable | ||
from unittest.mock import AsyncMock | ||
|
||
import pytest | ||
from fastapi import FastAPI | ||
from httpx import AsyncClient | ||
from respx import MockRouter | ||
|
||
|
||
@pytest.fixture | ||
def mock_engine(app: FastAPI) -> None: | ||
app.state.engine = AsyncMock() | ||
|
||
|
||
async def test_get_service_labels( | ||
postgres_setup_disabled: None, | ||
mocked_director_service_api: MockRouter, | ||
rabbitmq_and_rpc_setup_disabled: None, | ||
background_tasks_setup_disabled: None, | ||
mock_engine: None, | ||
get_mocked_service_labels: Callable[[str, str], dict], | ||
aclient: AsyncClient, | ||
): | ||
service_key = "simcore/services/comp/ans-model" | ||
service_version = "3.0.0" | ||
result = await aclient.get(f"/v0/services/{service_key}/{service_version}/labels") | ||
assert result.status_code == 200, result.text | ||
assert result.json() == get_mocked_service_labels(service_key, service_version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.