From c96582cbbda77cc4006f33138fd2fc1615f54f4d Mon Sep 17 00:00:00 2001 From: Werner Van Geit Date: Tue, 9 Apr 2024 17:07:59 +0200 Subject: [PATCH] =?UTF-8?q?=20=E2=9C=A8=20Add=20file=20probe=20service=20(?= =?UTF-8?q?#5636)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function_services_catalog/_utils.py | 9 +++++-- .../services/probes.py | 27 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/models-library/src/models_library/function_services_catalog/_utils.py b/packages/models-library/src/models_library/function_services_catalog/_utils.py index 0535c3096e7..a89bdf170b7 100644 --- a/packages/models-library/src/models_library/function_services_catalog/_utils.py +++ b/packages/models-library/src/models_library/function_services_catalog/_utils.py @@ -17,6 +17,7 @@ EN = Author.parse_obj(AUTHORS.get("EN", _DEFAULT)) OM = Author.parse_obj(AUTHORS.get("OM", _DEFAULT)) PC = Author.parse_obj(AUTHORS.get("PC", _DEFAULT)) +WVG = Author.parse_obj(AUTHORS.get("WVG", _DEFAULT)) def create_fake_thumbnail_url(label: str) -> str: @@ -79,7 +80,9 @@ def _skip_dev(self): skip = not self.settings.is_dev_feature_enabled() return skip - def _items(self) -> Iterator[tuple[tuple[ServiceKey, ServiceVersion], _Record]]: + def _items( + self, + ) -> Iterator[tuple[tuple[ServiceKey, ServiceVersion], _Record]]: skip_dev = self._skip_dev() for key, value in self._functions.items(): if value.is_under_development and skip_dev: @@ -91,7 +94,9 @@ def iter_metadata(self) -> Iterator[ServiceDockerData]: for _, f in self._items(): yield f.meta - def iter_services_key_version(self) -> Iterator[tuple[ServiceKey, ServiceVersion]]: + def iter_services_key_version( + self, + ) -> Iterator[tuple[ServiceKey, ServiceVersion]]: """WARNING: this function might skip services makred as 'under development'""" for kv, f in self._items(): assert kv == (f.meta.key, f.meta.version) # nosec diff --git a/packages/models-library/src/models_library/function_services_catalog/services/probes.py b/packages/models-library/src/models_library/function_services_catalog/services/probes.py index 8b5d5d03623..c0fef9ad513 100644 --- a/packages/models-library/src/models_library/function_services_catalog/services/probes.py +++ b/packages/models-library/src/models_library/function_services_catalog/services/probes.py @@ -1,6 +1,6 @@ from ...services import LATEST_INTEGRATION_VERSION, ServiceDockerData, ServiceType from .._key_labels import FUNCTION_SERVICE_KEY_PREFIX -from .._utils import OM, FunctionServices, create_fake_thumbnail_url +from .._utils import OM, WVG, FunctionServices, create_fake_thumbnail_url def create_metadata(type_name: str, prefix: str | None = None) -> ServiceDockerData: @@ -66,7 +66,30 @@ def create_metadata(type_name: str, prefix: str | None = None) -> ServiceDockerD } ) +META_FILE = ServiceDockerData.parse_obj( + { + "integration-version": LATEST_INTEGRATION_VERSION, + "key": f"{FUNCTION_SERVICE_KEY_PREFIX}/iterator-consumer/probe/file", + "version": "1.0.0", + "type": ServiceType.FRONTEND, + "name": "File probe", + "description": "Probes its input for files", + "thumbnail": create_fake_thumbnail_url("file"), + "authors": [ + WVG, + ], + "contact": WVG.email, + "inputs": { + "in_1": { + "label": "file", + "description": "file", + "type": "data:*/*", + } + }, + "outputs": {}, + } +) services = FunctionServices() -for m in (META_NUMBER, META_BOOL, META_INT, META_STR, META_ARRAY): +for m in (META_NUMBER, META_BOOL, META_INT, META_STR, META_ARRAY, META_FILE): services.add(meta=m)