Skip to content

Commit

Permalink
✨ Add file probe service (#5636)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvangeit authored Apr 9, 2024
1 parent 45f6f67 commit c96582c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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)

0 comments on commit c96582c

Please sign in to comment.