Skip to content

Commit b8bb98f

Browse files
Generate modelserving
1 parent e731cb6 commit b8bb98f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

services/modelserving/src/stackit/modelserving/models/token.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ def state_validate_enum(cls, value):
6161
raise ValueError("must be one of enum values ('creating', 'active', 'deleting', 'inactive')")
6262
return value
6363

64+
@field_validator("valid_until", mode="before")
65+
def valid_until_change_year_zero_to_one(cls, value):
66+
"""Workaround which prevents year 0 issue"""
67+
if isinstance(value, str):
68+
# Check for year "0000" at the beginning of the string
69+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
70+
if value.startswith("0000-01-01T") and re.match(
71+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
72+
):
73+
# Workaround: Replace "0000" with "0001"
74+
return "0001" + value[4:] # Take "0001" and append the rest of the string
75+
return value
76+
6477
model_config = ConfigDict(
6578
populate_by_name=True,
6679
validate_assignment=True,

services/modelserving/src/stackit/modelserving/models/token_created.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ def state_validate_enum(cls, value):
6969
raise ValueError("must be one of enum values ('creating', 'active', 'deleting')")
7070
return value
7171

72+
@field_validator("valid_until", mode="before")
73+
def valid_until_change_year_zero_to_one(cls, value):
74+
"""Workaround which prevents year 0 issue"""
75+
if isinstance(value, str):
76+
# Check for year "0000" at the beginning of the string
77+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
78+
if value.startswith("0000-01-01T") and re.match(
79+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
80+
):
81+
# Workaround: Replace "0000" with "0001"
82+
return "0001" + value[4:] # Take "0001" and append the rest of the string
83+
return value
84+
7285
model_config = ConfigDict(
7386
populate_by_name=True,
7487
validate_assignment=True,

0 commit comments

Comments
 (0)