-
Notifications
You must be signed in to change notification settings - Fork 32
♻️ Redirecting labels request via catalog in director-v2 #7016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GitHK
merged 22 commits into
ITISFoundation:master
from
GitHK:pr-osparc-move-service-labels-to-catalog-client
Jan 10, 2025
Merged
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
02a1a8c
catalog exposes service labels
77a2143
reroute getting labels
0119221
Merge remote-tracking branch 'upstream/master' into pr-osparc-move-se…
60346ff
updated specs
29f2298
pylint
e94c139
fixed issue
7b2512e
fixed warning
a612804
Merge remote-tracking branch 'upstream/master' into pr-osparc-move-se…
da1ef55
fixed failing tests
d3701d2
Merge remote-tracking branch 'upstream/master' into pr-osparc-move-se…
8233029
pylint
731baa0
remove envelope
0b94380
update specs
86aa7d7
fixed unused
3dc7bc6
fixed test
bdd4560
refactor
1922224
refactor
40963ef
rename
5b4fb17
Merge remote-tracking branch 'upstream/master' into pr-osparc-move-se…
751efdf
services/catalog version: 0.6.0 → 0.7.0
d798336
update specs
6fc086b
refactor
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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) | ||
GitHK marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.