Skip to content

Commit 2fc2d1e

Browse files
author
Andrei Neagu
committed
extend format
1 parent 9c4bb3b commit 2fc2d1e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/models-library/src/models_library/service_settings_labels.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ def ensure_backwards_compatible_setting_type(cls, v):
167167
SimcoreServiceSettingsLabel = ListModel[SimcoreServiceSettingLabelEntry]
168168

169169

170+
class LegacyState(BaseModel):
171+
s3_archive: str
172+
new_state_path: Path
173+
174+
170175
class PathMappingsLabel(BaseModel):
171176
"""Content of "simcore.service.paths-mapping" label"""
172177

@@ -195,6 +200,29 @@ class PathMappingsLabel(BaseModel):
195200
),
196201
)
197202

203+
legacy_state: LegacyState | None = Field(
204+
None,
205+
description=(
206+
"if present, the service needs to first try todownload the legacy state "
207+
"from the s3_ardhive and copy it over to the new_state_path."
208+
),
209+
)
210+
211+
@field_validator("legacy_state")
212+
@classmethod
213+
def validate_legacy_state(
214+
cls, v: LegacyState | None, info: ValidationInfo
215+
) -> LegacyState | None:
216+
if v is None:
217+
return v
218+
219+
state_paths: list[Path] = info.data.get("state_paths", [])
220+
if v.new_state_path not in state_paths:
221+
msg = f"legacy_state={v} not found in state_paths={state_paths}"
222+
raise ValueError(msg)
223+
224+
return v
225+
198226
@field_validator("volume_size_limits")
199227
@classmethod
200228
def validate_volume_limits(cls, v, info: ValidationInfo) -> str | None:
@@ -252,6 +280,16 @@ def validate_volume_limits(cls, v, info: ValidationInfo) -> str | None:
252280
"/t_inp": "1EIB",
253281
},
254282
},
283+
{
284+
"outputs_path": "/tmp/outputs", # noqa: S108 nosec
285+
"inputs_path": "/tmp/inputs", # noqa: S108 nosec
286+
"state_paths": ["/tmp/save_1", "/tmp_save_2"], # noqa: S108 nosec
287+
"state_exclude": ["/tmp/strip_me/*"], # noqa: S108 nosec
288+
"legacy_state": {
289+
"s3_archive": "work.zip",
290+
"new_state_path": "/tmp/save_1", # noqa: S108 nosec
291+
},
292+
},
255293
]
256294
},
257295
)

0 commit comments

Comments
 (0)