Skip to content

Commit e29f65a

Browse files
committed
fixes sil
1 parent 7ead8ec commit e29f65a

File tree

2 files changed

+92
-59
lines changed

2 files changed

+92
-59
lines changed

packages/service-integration/src/service_integration/oci_image_spec.py

Lines changed: 82 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import os
99
from datetime import datetime
10-
from typing import Any
10+
from typing import Annotated, Any
1111

1212
from models_library.basic_types import SHA1Str, VersionStr
1313
from models_library.utils.labels_annotations import from_labels, to_labels
@@ -43,62 +43,89 @@ def _underscore_as_dot(field_name: str):
4343
class OciImageSpecAnnotations(BaseModel):
4444
# TODO: review and polish constraints
4545

46-
created: datetime = Field(
47-
None,
48-
description="date and time on which the image was built (string, date-time as defined by RFC 3339)",
49-
)
50-
51-
authors: str = Field(
52-
None,
53-
description="contact details of the people or organization responsible for the image (freeform string)",
54-
)
55-
56-
url: AnyUrl = Field(
57-
None, description="URL to find more information on the image (string)"
58-
)
59-
60-
documentation: AnyUrl = Field(
61-
None, description="URL to get documentation on the image (string)"
62-
)
63-
64-
source: AnyUrl = Field(
65-
None, description="URL to get source code for building the image (string)"
66-
)
67-
68-
version: VersionStr = Field(
69-
None,
70-
description="version of the packaged software"
71-
"The version MAY match a label or tag in the source code repository"
72-
"version MAY be Semantic versioning-compatible",
73-
)
74-
revision: str = Field(
75-
None,
76-
description="Source control revision identifier for the packaged software.",
77-
)
78-
79-
vendor: str = Field(
80-
None, description="Name of the distributing entity, organization or individual."
81-
)
46+
created: Annotated[
47+
datetime | None,
48+
Field(
49+
description="date and time on which the image was built (string, date-time as defined by RFC 3339)",
50+
),
51+
] = None
52+
53+
authors: Annotated[
54+
str | None,
55+
Field(
56+
description="contact details of the people or organization responsible for the image (freeform string)",
57+
),
58+
] = None
59+
60+
url: Annotated[
61+
AnyUrl | None,
62+
Field(None, description="URL to find more information on the image (string)"),
63+
] = None
64+
65+
documentation: Annotated[
66+
AnyUrl | None,
67+
Field(None, description="URL to get documentation on the image (string)"),
68+
] = None
69+
70+
source: Annotated[
71+
AnyUrl | None,
72+
Field(
73+
None, description="URL to get source code for building the image (string)"
74+
),
75+
] = None
76+
77+
version: Annotated[
78+
VersionStr | None,
79+
Field(
80+
description="version of the packaged software"
81+
"The version MAY match a label or tag in the source code repository"
82+
"version MAY be Semantic versioning-compatible",
83+
),
84+
] = None
85+
revision: Annotated[
86+
str | None,
87+
Field(
88+
description="Source control revision identifier for the packaged software.",
89+
),
90+
] = None
91+
vendor: Annotated[
92+
str | None,
93+
Field(
94+
description="Name of the distributing entity, organization or individual."
95+
),
96+
] = None
8297

8398
# SEE https://spdx.dev/spdx-specification-21-web-version/#h.jxpfx0ykyb60
84-
licenses: str = Field(
85-
"MIT",
86-
description="License(s) under which contained software is distributed as an SPDX License Expression.",
87-
)
88-
ref_name: str = Field(
89-
None,
90-
description="Name of the reference for a target (string).",
91-
)
99+
licenses: Annotated[
100+
str,
101+
Field(
102+
description="License(s) under which contained software is distributed as an SPDX License Expression.",
103+
),
104+
] = "MIT"
105+
106+
ref_name: Annotated[
107+
str | None,
108+
Field(
109+
description="Name of the reference for a target (string).",
110+
),
111+
] = None
112+
113+
title: Annotated[
114+
str | None, Field(description="Human-readable title of the image (string)")
115+
] = None
116+
description: Annotated[
117+
str | None,
118+
Field(
119+
description="Human-readable description of the software packaged in the image (string)",
120+
),
121+
] = None
122+
base_digest: Annotated[
123+
SHA1Str | None,
124+
Field(
125+
description="Digest of the image this image is based on (string)",
126+
),
127+
] = None
92128

93-
title: str = Field(None, description="Human-readable title of the image (string)")
94-
description: str = Field(
95-
None,
96-
description="Human-readable description of the software packaged in the image (string)",
97-
)
98-
base_digest: SHA1Str = Field(
99-
None,
100-
description="Digest of the image this image is based on (string)",
101-
)
102129
model_config = ConfigDict(
103130
alias_generator=_underscore_as_dot, populate_by_name=True, extra="forbid"
104131
)
@@ -123,7 +150,7 @@ class LabelSchemaAnnotations(BaseModel):
123150
NOTE: DEPRECATED IN FAVOUR OF OCI IMAGE SPEC
124151
"""
125152

126-
schema_version: VersionStr = Field("1.0.0", alias="schema-version")
153+
schema_version: Annotated[VersionStr, Field(alias="schema-version")] = "1.0.0"
127154

128155
build_date: datetime
129156
vcs_ref: str

packages/service-integration/src/service_integration/osparc_config.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
import logging
1616
from pathlib import Path
17-
from typing import Any, Final, Literal
17+
from typing import Annotated, Any, Final, Literal
1818

19+
from models_library._compat import Undefined
1920
from models_library.basic_types import SHA256Str
2021
from models_library.callbacks_mapping import CallbacksMapping
2122
from models_library.service_settings_labels import (
@@ -64,6 +65,8 @@
6465
ServiceType.DYNAMIC: DYNAMIC_SERVICE_KEY_FORMAT,
6566
}
6667

68+
_Unset: Any = Undefined
69+
6770

6871
class DockerComposeOverwriteConfig(ComposeSpecification):
6972
"""Content of docker-compose.overwrite.yml configuration file"""
@@ -215,7 +218,10 @@ class RuntimeConfig(BaseModel):
215218

216219
restart_policy: RestartPolicy = RestartPolicy.NO_RESTART
217220

218-
callbacks_mapping: CallbacksMapping | None = Field(default_factory=dict)
221+
callbacks_mapping: Annotated[
222+
CallbacksMapping | None, Field(default_factory=dict)
223+
] = _Unset
224+
219225
paths_mapping: PathMappingsLabel | None = None
220226

221227
user_preferences_path: Path | None = None
@@ -226,11 +232,11 @@ class RuntimeConfig(BaseModel):
226232

227233
containers_allowed_outgoing_internet: set[str] | None = None
228234

229-
settings: list[SettingsItem] = Field(default_factory=list)
235+
settings: Annotated[list[SettingsItem], Field(default_factory=list)] = _Unset
230236

231237
@model_validator(mode="before")
232238
@classmethod
233-
def ensure_compatibility(cls, v):
239+
def _ensure_compatibility(cls, v):
234240
# NOTE: if changes are applied to `DynamicSidecarServiceLabels`
235241
# these are also validated when ooil runs.
236242
try:

0 commit comments

Comments
 (0)