From b2ec1641fc97be1683b80b8398571577e8eac28b Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Wed, 27 Nov 2024 16:13:13 +0100 Subject: [PATCH 01/11] fix decimal representation --- .../pricing_plans.py | 7 ++----- .../api_schemas_webserver/resource_usage.py | 7 ++----- .../models_library/api_schemas_webserver/wallets.py | 13 +++---------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/packages/models-library/src/models_library/api_schemas_resource_usage_tracker/pricing_plans.py b/packages/models-library/src/models_library/api_schemas_resource_usage_tracker/pricing_plans.py index 294ea360e58..bbb5d52f906 100644 --- a/packages/models-library/src/models_library/api_schemas_resource_usage_tracker/pricing_plans.py +++ b/packages/models-library/src/models_library/api_schemas_resource_usage_tracker/pricing_plans.py @@ -1,8 +1,7 @@ from datetime import datetime from decimal import Decimal -from typing import Annotated -from pydantic import BaseModel, ConfigDict, PlainSerializer +from pydantic import BaseModel, ConfigDict from ..resource_tracker import ( HardwareInfo, @@ -19,9 +18,7 @@ class PricingUnitGet(BaseModel): pricing_unit_id: PricingUnitId unit_name: str unit_extra_info: UnitExtraInfo - current_cost_per_unit: Annotated[ - Decimal, PlainSerializer(float, return_type=float, when_used="json") - ] + current_cost_per_unit: Decimal current_cost_per_unit_id: PricingUnitCostId default: bool specific_info: HardwareInfo diff --git a/packages/models-library/src/models_library/api_schemas_webserver/resource_usage.py b/packages/models-library/src/models_library/api_schemas_webserver/resource_usage.py index bdf0992910e..3eea55c6d67 100644 --- a/packages/models-library/src/models_library/api_schemas_webserver/resource_usage.py +++ b/packages/models-library/src/models_library/api_schemas_webserver/resource_usage.py @@ -1,8 +1,7 @@ from datetime import datetime from decimal import Decimal -from typing import Annotated -from pydantic import BaseModel, ConfigDict, Field, PlainSerializer +from pydantic import BaseModel, ConfigDict, Field from ..projects import ProjectID from ..projects_nodes_io import NodeID @@ -50,9 +49,7 @@ class PricingUnitGet(OutputSchema): pricing_unit_id: PricingUnitId unit_name: str unit_extra_info: UnitExtraInfo - current_cost_per_unit: Annotated[ - Decimal, PlainSerializer(float, return_type=float, when_used="json") - ] + current_cost_per_unit: Decimal default: bool diff --git a/packages/models-library/src/models_library/api_schemas_webserver/wallets.py b/packages/models-library/src/models_library/api_schemas_webserver/wallets.py index 21fe990b88b..3112a8301a6 100644 --- a/packages/models-library/src/models_library/api_schemas_webserver/wallets.py +++ b/packages/models-library/src/models_library/api_schemas_webserver/wallets.py @@ -1,15 +1,8 @@ from datetime import datetime from decimal import Decimal -from typing import Annotated, Literal, TypeAlias +from typing import Literal, TypeAlias -from pydantic import ( - ConfigDict, - Field, - HttpUrl, - PlainSerializer, - ValidationInfo, - field_validator, -) +from pydantic import ConfigDict, Field, HttpUrl, ValidationInfo, field_validator from ..basic_types import AmountDecimal, IDStr, NonNegativeDecimal from ..users import GroupID @@ -31,7 +24,7 @@ class WalletGet(OutputSchema): class WalletGetWithAvailableCredits(WalletGet): - available_credits: Annotated[Decimal, PlainSerializer(float)] + available_credits: Decimal class WalletGetPermissions(WalletGet): From 4a344ef87aea3f958050c29d30ab94e5dbba51bc Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Thu, 28 Nov 2024 09:22:49 +0100 Subject: [PATCH 02/11] =?UTF-8?q?services/webserver=20api=20version:=200.4?= =?UTF-8?q?6.0=20=E2=86=92=200.47.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/web/server/VERSION | 2 +- services/web/server/setup.cfg | 2 +- .../server/src/simcore_service_webserver/api/v0/openapi.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/web/server/VERSION b/services/web/server/VERSION index 301092317fe..421ab545d9a 100644 --- a/services/web/server/VERSION +++ b/services/web/server/VERSION @@ -1 +1 @@ -0.46.0 +0.47.0 diff --git a/services/web/server/setup.cfg b/services/web/server/setup.cfg index 0c5bbbcb6b3..628685e0ad5 100644 --- a/services/web/server/setup.cfg +++ b/services/web/server/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.46.0 +current_version = 0.47.0 commit = True message = services/webserver api version: {current_version} → {new_version} tag = False diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index 688d2187cb3..e8cb4359df4 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -2,7 +2,7 @@ openapi: 3.1.0 info: title: simcore-service-webserver description: Main service with an interface (http-API & websockets) to the web front-end - version: 0.46.0 + version: 0.47.0 servers: - url: '' description: webserver From c70c59e367a7c033852e3cafde0a15719942b7e9 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Thu, 28 Nov 2024 09:25:08 +0100 Subject: [PATCH 03/11] =?UTF-8?q?services/webserver=20api=20version:=200.4?= =?UTF-8?q?7.0=20=E2=86=92=200.48.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/web/server/VERSION | 2 +- services/web/server/setup.cfg | 2 +- .../server/src/simcore_service_webserver/api/v0/openapi.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/web/server/VERSION b/services/web/server/VERSION index 421ab545d9a..a758a09aae5 100644 --- a/services/web/server/VERSION +++ b/services/web/server/VERSION @@ -1 +1 @@ -0.47.0 +0.48.0 diff --git a/services/web/server/setup.cfg b/services/web/server/setup.cfg index 628685e0ad5..0b6157ef959 100644 --- a/services/web/server/setup.cfg +++ b/services/web/server/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.47.0 +current_version = 0.48.0 commit = True message = services/webserver api version: {current_version} → {new_version} tag = False diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index e8cb4359df4..55603a9e16c 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -2,7 +2,7 @@ openapi: 3.1.0 info: title: simcore-service-webserver description: Main service with an interface (http-API & websockets) to the web front-end - version: 0.47.0 + version: 0.48.0 servers: - url: '' description: webserver From ebbb2c15419be9a3c95334bb52aae439111b0768 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Thu, 28 Nov 2024 09:25:59 +0100 Subject: [PATCH 04/11] make openapi-spec --- .../src/simcore_service_webserver/api/v0/openapi.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index 55603a9e16c..af1a39206a8 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -4396,7 +4396,7 @@ paths: '403': description: ProjectInvalidRightsError '404': - description: ProjectNotFoundError, UserDefaultWalletNotFoundError + description: UserDefaultWalletNotFoundError, ProjectNotFoundError '409': description: ProjectTooManyProjectOpenedError '422': @@ -11285,7 +11285,7 @@ components: unitExtraInfo: $ref: '#/components/schemas/UnitExtraInfo-Output' currentCostPerUnit: - type: number + type: string title: Currentcostperunit default: type: boolean @@ -11329,7 +11329,7 @@ components: unitExtraInfo: $ref: '#/components/schemas/UnitExtraInfo-Output' currentCostPerUnit: - type: number + type: string title: Currentcostperunit default: type: boolean @@ -14140,7 +14140,7 @@ components: format: date-time title: Modified availableCredits: - type: number + type: string title: Availablecredits type: object required: From 83471a5338c215cfc0bdb41d7e8d80319c9a64a4 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Thu, 28 Nov 2024 09:28:08 +0100 Subject: [PATCH 05/11] revert to 0.46 --- services/web/server/setup.cfg | 6 +++--- .../src/simcore_service_webserver/api/v0/openapi.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/web/server/setup.cfg b/services/web/server/setup.cfg index 0b6157ef959..982e0cab3f5 100644 --- a/services/web/server/setup.cfg +++ b/services/web/server/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.48.0 +current_version = 0.46.0 commit = True message = services/webserver api version: {current_version} → {new_version} tag = False @@ -12,13 +12,13 @@ commit_args = --no-verify [tool:pytest] addopts = --strict-markers asyncio_mode = auto -markers = +markers = slow: marks tests as slow (deselect with '-m "not slow"') acceptance_test: "marks tests as 'acceptance tests' i.e. does the system do what the user expects? Typically those are workflows." testit: "marks test to run during development" heavy_load: "mark tests that require large amount of data" [mypy] -plugins = +plugins = pydantic.mypy sqlalchemy.ext.mypy.plugin diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index af1a39206a8..accca45fbfb 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -2,7 +2,7 @@ openapi: 3.1.0 info: title: simcore-service-webserver description: Main service with an interface (http-API & websockets) to the web front-end - version: 0.48.0 + version: 0.46.0 servers: - url: '' description: webserver From 91a871953a83fff3b4ab174359e9f9aa473509f3 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Thu, 28 Nov 2024 09:28:43 +0100 Subject: [PATCH 06/11] revert to 0.46.0 --- services/web/server/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/server/VERSION b/services/web/server/VERSION index a758a09aae5..301092317fe 100644 --- a/services/web/server/VERSION +++ b/services/web/server/VERSION @@ -1 +1 @@ -0.48.0 +0.46.0 From 2d117172ca55116b1dfeab852345790dd0a42893 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Thu, 28 Nov 2024 09:28:46 +0100 Subject: [PATCH 07/11] =?UTF-8?q?services/webserver=20api=20version:=200.4?= =?UTF-8?q?6.0=20=E2=86=92=200.47.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/web/server/VERSION | 2 +- services/web/server/setup.cfg | 6 +++--- .../src/simcore_service_webserver/api/v0/openapi.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/web/server/VERSION b/services/web/server/VERSION index 301092317fe..421ab545d9a 100644 --- a/services/web/server/VERSION +++ b/services/web/server/VERSION @@ -1 +1 @@ -0.46.0 +0.47.0 diff --git a/services/web/server/setup.cfg b/services/web/server/setup.cfg index 982e0cab3f5..628685e0ad5 100644 --- a/services/web/server/setup.cfg +++ b/services/web/server/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.46.0 +current_version = 0.47.0 commit = True message = services/webserver api version: {current_version} → {new_version} tag = False @@ -12,13 +12,13 @@ commit_args = --no-verify [tool:pytest] addopts = --strict-markers asyncio_mode = auto -markers = +markers = slow: marks tests as slow (deselect with '-m "not slow"') acceptance_test: "marks tests as 'acceptance tests' i.e. does the system do what the user expects? Typically those are workflows." testit: "marks test to run during development" heavy_load: "mark tests that require large amount of data" [mypy] -plugins = +plugins = pydantic.mypy sqlalchemy.ext.mypy.plugin diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index accca45fbfb..7d4c6b55063 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -2,7 +2,7 @@ openapi: 3.1.0 info: title: simcore-service-webserver description: Main service with an interface (http-API & websockets) to the web front-end - version: 0.46.0 + version: 0.47.0 servers: - url: '' description: webserver From 14d4cda76894550520b8270152b86ebe196fb795 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Mon, 2 Dec 2024 09:25:21 +0100 Subject: [PATCH 08/11] run make openapi.json --- services/api-server/openapi.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/api-server/openapi.json b/services/api-server/openapi.json index 5b23b44603d..a52ec40b0ab 100644 --- a/services/api-server/openapi.json +++ b/services/api-server/openapi.json @@ -6490,7 +6490,7 @@ "$ref": "#/components/schemas/UnitExtraInfo" }, "currentCostPerUnit": { - "type": "number", + "type": "string", "title": "Currentcostperunit" }, "default": { @@ -6891,7 +6891,7 @@ "type": "integer", "x_unit": "second" }, - "key": "input_2", + "key": "f763658f-a89a-4a90-ace4-c44631290f12", "kind": "input" } }, @@ -7091,7 +7091,7 @@ "title": "Modified" }, "availableCredits": { - "type": "number", + "type": "string", "title": "Availablecredits" } }, @@ -7099,7 +7099,9 @@ "required": [ "walletId", "name", + "description", "owner", + "thumbnail", "status", "created", "modified", From c2660a8c60961ef8f41c00add27ee7d32ea84124 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Tue, 3 Dec 2024 09:20:33 +0100 Subject: [PATCH 09/11] make fields optional in Pydantic v2 --- .../src/models_library/api_schemas_webserver/wallets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/models-library/src/models_library/api_schemas_webserver/wallets.py b/packages/models-library/src/models_library/api_schemas_webserver/wallets.py index 3112a8301a6..c9460ab74c1 100644 --- a/packages/models-library/src/models_library/api_schemas_webserver/wallets.py +++ b/packages/models-library/src/models_library/api_schemas_webserver/wallets.py @@ -13,9 +13,9 @@ class WalletGet(OutputSchema): wallet_id: WalletID name: IDStr - description: str | None + description: str | None = None owner: GroupID - thumbnail: str | None + thumbnail: str | None = None status: WalletStatus created: datetime modified: datetime From b6036e2401db3cc1422505d6699f47f966ab53c4 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Tue, 3 Dec 2024 09:21:31 +0100 Subject: [PATCH 10/11] update openapi.json --- services/api-server/openapi.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/api-server/openapi.json b/services/api-server/openapi.json index a52ec40b0ab..1dbb1c70605 100644 --- a/services/api-server/openapi.json +++ b/services/api-server/openapi.json @@ -7099,9 +7099,7 @@ "required": [ "walletId", "name", - "description", "owner", - "thumbnail", "status", "created", "modified", From b8ed53b2a91d43bdbd68583866e242405f6ded81 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Wed, 4 Dec 2024 12:24:44 +0100 Subject: [PATCH 11/11] remove oas spec test --- .../tests/unit/api_rest/test__oas_spec.py | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 services/resource-usage-tracker/tests/unit/api_rest/test__oas_spec.py diff --git a/services/resource-usage-tracker/tests/unit/api_rest/test__oas_spec.py b/services/resource-usage-tracker/tests/unit/api_rest/test__oas_spec.py deleted file mode 100644 index 3952db4c4cc..00000000000 --- a/services/resource-usage-tracker/tests/unit/api_rest/test__oas_spec.py +++ /dev/null @@ -1,29 +0,0 @@ -# pylint: disable=redefined-outer-name -# pylint: disable=unused-argument -# pylint: disable=unused-variable - -import json -from pathlib import Path -from unittest import mock - -from fastapi.testclient import TestClient - - -def test_openapi_json_is_in_sync_with_app_oas( - disabled_database: None, - disabled_prometheus: None, - disabled_rabbitmq: None, - mocked_redis_server: None, - mocked_setup_rabbitmq: mock.MagicMock, - client: TestClient, - project_slug_dir: Path, -): - """ - If this test fails, just 'make openapi.json' - """ - spec_from_app = client.app.openapi() - open_api_json_file = project_slug_dir / "openapi.json" - stored_openapi_json_file = json.loads(open_api_json_file.read_text()) - assert ( - spec_from_app == stored_openapi_json_file - ), "rerun `make openapi.json` and check differences"