Skip to content

Commit

Permalink
✨♻️ New fields for service metadata (ITISFoundation#5902)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov authored May 31, 2024
1 parent 1c5cf7b commit e50f972
Show file tree
Hide file tree
Showing 39 changed files with 317 additions and 324 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from pydantic import Extra

from ..emails import LowerCaseEmailStr
from ..services import ServiceDockerData, ServiceMetaData
from ..services import BaseServiceMetaData, ServiceDockerData
from ..services_access import ServiceAccessRights
from ..services_resources import ServiceResourcesDict


class ServiceUpdate(ServiceMetaData, ServiceAccessRights):
class ServiceUpdate(BaseServiceMetaData, ServiceAccessRights):
class Config:
schema_extra: ClassVar[dict[str, Any]] = {
"example": {
Expand Down Expand Up @@ -61,7 +61,7 @@ class Config:


class ServiceGet(
ServiceDockerData, ServiceAccessRights, ServiceMetaData
ServiceDockerData, ServiceAccessRights, BaseServiceMetaData
): # pylint: disable=too-many-ancestors
owner: LowerCaseEmailStr | None

Expand Down
203 changes: 104 additions & 99 deletions packages/models-library/src/models_library/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
validator,
)

from .basic_regex import VERSION_RE
from .basic_regex import SEMANTIC_VERSION_RE_W_CAPTURE_GROUPS, VERSION_RE
from .boot_options import BootOption, BootOptions
from .emails import LowerCaseEmailStr
from .services_constants import FILENAME_RE, PROPERTY_TYPE_RE
Expand Down Expand Up @@ -480,25 +480,104 @@ def validate_thumbnail(cls, value): # pylint: disable=no-self-argument,no-self-
ServiceOutputsDict: TypeAlias = dict[ServicePortKey, ServiceOutput]


_EXAMPLE = {
"name": "oSparc Python Runner",
"key": "simcore/services/comp/osparc-python-runner",
"type": "computational",
"integration-version": "1.0.0",
"progress_regexp": "^(?:\\[?PROGRESS\\]?:?)?\\s*(?P<value>[0-1]?\\.\\d+|\\d+\\s*(?P<percent_sign>%))",
"version": "1.7.0",
"description": "oSparc Python Runner",
"contact": "[email protected]",
"authors": [
{
"name": "John Smith",
"email": "[email protected]",
"affiliation": "Company",
},
{
"name": "Richard Brown",
"email": "[email protected]",
"affiliation": "University",
},
],
"inputs": {
"input_1": {
"displayOrder": 1,
"label": "Input data",
"description": "Any code, requirements or data file",
"type": "data:*/*",
}
},
"outputs": {
"output_1": {
"displayOrder": 1,
"label": "Output data",
"description": "All data produced by the script is zipped as output_data.zip",
"type": "data:*/*",
"fileToKeyMap": {"output_data.zip": "output_1"},
}
},
}

_EXAMPLE_W_BOOT_OPTIONS_AND_NO_DISPLAY_ORDER = {
**_EXAMPLE,
"description": "oSparc Python Runner with boot options",
"inputs": {
"input_1": {
"label": "Input data",
"description": "Any code, requirements or data file",
"type": "data:*/*",
}
},
"outputs": {
"output_1": {
"label": "Output data",
"description": "All data produced by the script is zipped as output_data.zip",
"type": "data:*/*",
"fileToKeyMap": {"output_data.zip": "output_1"},
}
},
"boot-options": {
"example_service_defined_boot_mode": BootOption.Config.schema_extra["examples"][
0
],
"example_service_defined_theme_selection": BootOption.Config.schema_extra[
"examples"
][1],
},
"min-visible-inputs": 2,
}


class ServiceDockerData(ServiceKeyVersion, _BaseServiceCommonDataModel):
"""
Static metadata for a service injected in the image labels
This is one to one with node-meta-v0.0.1.json
NOTE: This model is serialized in .osparc/metadata.yml and in the labels of the docker image
"""

integration_version: str | None = Field(
version_display: str | None = Field(
None,
alias="integration-version",
description="integration version number",
regex=VERSION_RE,
examples=["1.0.0"],
description="A user-friendly or marketing name for the release."
" This can be used to reference the release in a more readable and recognizable format, such as 'Matterhorn Release,' 'Spring Update,' or 'Holiday Edition.'"
" This name is not used for version comparison but is useful for communication and documentation purposes.",
)
progress_regexp: str | None = Field(

release_date: datetime | None = Field(
None,
alias="progress_regexp",
description="regexp pattern for detecting computational service's progress",
description="A timestamp when the specific version of the service was released."
" This field helps in tracking the timeline of releases and understanding the sequence of updates."
" A timestamp string should be formatted as YYYY-MM-DD[T]HH:MM[:SS[.ffffff]][Z or [±]HH[:]MM]",
)

integration_version: str | None = Field(
None,
alias="integration-version",
description="This version is used to maintain backward compatibility when there are changes in the way a service is integrated into the framework",
regex=SEMANTIC_VERSION_RE_W_CAPTURE_GROUPS,
)

service_type: ServiceType = Field(
...,
alias="type",
Expand Down Expand Up @@ -526,6 +605,7 @@ class ServiceDockerData(ServiceKeyVersion, _BaseServiceCommonDataModel):
alias="boot-options",
description="Service defined boot options. These get injected in the service as env variables.",
)

min_visible_inputs: NonNegativeInt | None = Field(
None,
alias="min-visible-inputs",
Expand All @@ -535,108 +615,33 @@ class ServiceDockerData(ServiceKeyVersion, _BaseServiceCommonDataModel):
),
)

progress_regexp: str | None = Field(
None,
alias="progress_regexp",
description="regexp pattern for detecting computational service's progress",
)

class Config:
description = "Description of a simcore node 'class' with input and output"
extra = Extra.forbid
frozen = False # it inherits from ServiceKeyVersion.
frozen = False # overrides config from ServiceKeyVersion.
allow_population_by_field_name = True

schema_extra: ClassVar[dict[str, Any]] = {
"examples": [
{
"name": "oSparc Python Runner",
"key": "simcore/services/comp/osparc-python-runner",
"type": "computational",
"integration-version": "1.0.0",
"progress_regexp": "^(?:\\[?PROGRESS\\]?:?)?\\s*(?P<value>[0-1]?\\.\\d+|\\d+\\s*(?P<percent_sign>%))",
"version": "1.7.0",
"description": "oSparc Python Runner",
"contact": "[email protected]",
"authors": [
{
"name": "John Smith",
"email": "[email protected]",
"affiliation": "Company",
},
{
"name": "Richard Brown",
"email": "[email protected]",
"affiliation": "University",
},
],
"inputs": {
"input_1": {
"displayOrder": 1,
"label": "Input data",
"description": "Any code, requirements or data file",
"type": "data:*/*",
}
},
"outputs": {
"output_1": {
"displayOrder": 1,
"label": "Output data",
"description": "All data produced by the script is zipped as output_data.zip",
"type": "data:*/*",
"fileToKeyMap": {"output_data.zip": "output_1"},
}
},
},
_EXAMPLE,
_EXAMPLE_W_BOOT_OPTIONS_AND_NO_DISPLAY_ORDER,
# latest
{
"name": "oSparc Python Runner",
"key": "simcore/services/comp/osparc-python-runner",
"type": "computational",
"integration-version": "1.0.0",
"progress_regexp": "^(?:\\[?PROGRESS\\]?:?)?\\s*(?P<value>[0-1]?\\.\\d+|\\d+\\s*(?P<percent_sign>%))",
"version": "1.7.0",
"description": "oSparc Python Runner with boot options",
"contact": "[email protected]",
"authors": [
{
"name": "John Smith",
"email": "[email protected]",
"affiliation": "Company",
},
{
"name": "Richard Brown",
"email": "[email protected]",
"affiliation": "University",
},
],
"inputs": {
"input_1": {
"label": "Input data",
"description": "Any code, requirements or data file",
"type": "data:*/*",
}
},
"outputs": {
"output_1": {
"label": "Output data",
"description": "All data produced by the script is zipped as output_data.zip",
"type": "data:*/*",
"fileToKeyMap": {"output_data.zip": "output_1"},
}
},
"boot-options": {
"example_service_defined_boot_mode": BootOption.Config.schema_extra[
"examples"
][
0
],
"example_service_defined_theme_selection": BootOption.Config.schema_extra[
"examples"
][
1
],
},
"min-visible-inputs": 2,
**_EXAMPLE_W_BOOT_OPTIONS_AND_NO_DISPLAY_ORDER,
"version_display": "Matterhorn Release",
"release_date": "2024-05-31T13:45:30",
},
]
}


class ServiceMetaData(_BaseServiceCommonDataModel):
class BaseServiceMetaData(_BaseServiceCommonDataModel):
# Overrides all fields of _BaseServiceCommonDataModel:
# - for a partial update all members must be Optional
# FIXME: if API entry needs a schema to allow partial updates (e.g. patch/put),
Expand Down
4 changes: 2 additions & 2 deletions packages/models-library/src/models_library/services_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pydantic import Field
from pydantic.types import PositiveInt

from .services import ServiceKeyVersion, ServiceMetaData
from .services import BaseServiceMetaData, ServiceKeyVersion
from .services_access import ServiceGroupAccessRights

# -------------------------------------------------------------------
Expand All @@ -18,7 +18,7 @@
# - table services_access_rights


class ServiceMetaDataAtDB(ServiceKeyVersion, ServiceMetaData):
class ServiceMetaDataAtDB(ServiceKeyVersion, BaseServiceMetaData):
# for a partial update all members must be Optional
classifiers: list[str] | None = Field([])
owner: PositiveInt | None
Expand Down
2 changes: 1 addition & 1 deletion packages/service-integration/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3
1.0.4
2 changes: 1 addition & 1 deletion packages/service-integration/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.3
current_version = 1.0.4
commit = True
message = service-integration version: {current_version} → {new_version}
tag = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class Config:
) = None
oom_kill_disable: bool | None = None
oom_score_adj: conint(ge=-1000, le=1000) | None = None
pid: str | None | None = None
pid: str | None = None
pids_limit: float | str | None = None
platform: str | None = None
ports: list[PortInt | str | Port] | None = None
Expand Down
4 changes: 2 additions & 2 deletions packages/service-integration/src/service_integration/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def _version_callback(value: bool):
if value:
rich.print(__version__)
raise typer.Exit()
raise typer.Exit


@app.callback()
Expand All @@ -38,7 +38,7 @@ def main(
),
):
"""o2s2parc service integration library"""
assert version or not version # nosec
assert isinstance(version, bool | None) # nosec

overrides = {}
if registry_name:
Expand Down
Loading

0 comments on commit e50f972

Please sign in to comment.