Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
e4601811
Unverified
Commit
e4601811
authored
Mar 03, 2026
by
hhzhang16
Committed by
GitHub
Mar 03, 2026
Browse files
feat: use model_fields_set to distinguish ttft/itl default usage (#6814)
Signed-off-by:
Hannah Zhang
<
hannahz@nvidia.com
>
parent
8055b7dd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
components/src/dynamo/profiler/utils/dgdr_v1beta1_types.py
components/src/dynamo/profiler/utils/dgdr_v1beta1_types.py
+6
-1
deploy/operator/api/scripts/generate_pydantic_from_go.py
deploy/operator/api/scripts/generate_pydantic_from_go.py
+4
-1
deploy/operator/api/scripts/validate_pydantic_models.py
deploy/operator/api/scripts/validate_pydantic_models.py
+7
-0
No files found.
components/src/dynamo/profiler/utils/dgdr_v1beta1_types.py
View file @
e4601811
...
@@ -117,9 +117,14 @@ class SLASpec(BaseModel):
...
@@ -117,9 +117,14 @@ class SLASpec(BaseModel):
@
model_validator
(
mode
=
"after"
)
@
model_validator
(
mode
=
"after"
)
def
_validate_sla_options
(
self
)
->
"SLASpec"
:
def
_validate_sla_options
(
self
)
->
"SLASpec"
:
"""Ensure at most one SLA mode is active."""
"""Ensure at most one SLA mode is active."""
has_ttft_itl
=
self
.
ttft
is
not
None
and
self
.
itl
is
not
None
has_e2e
=
self
.
e2eLatency
is
not
None
has_e2e
=
self
.
e2eLatency
is
not
None
has_opt
=
self
.
optimizationType
is
not
None
has_opt
=
self
.
optimizationType
is
not
None
ttft_itl_touched
=
(
"ttft"
in
self
.
model_fields_set
or
"itl"
in
self
.
model_fields_set
)
has_ttft_itl
=
(
self
.
ttft
is
not
None
and
self
.
itl
is
not
None
)
and
(
ttft_itl_touched
or
(
not
has_e2e
and
not
has_opt
)
)
options_count
=
sum
([
has_ttft_itl
,
has_e2e
,
has_opt
])
options_count
=
sum
([
has_ttft_itl
,
has_e2e
,
has_opt
])
if
options_count
>
1
:
if
options_count
>
1
:
raise
ValueError
(
raise
ValueError
(
...
...
deploy/operator/api/scripts/generate_pydantic_from_go.py
View file @
e4601811
...
@@ -67,9 +67,12 @@ _STRUCT_EXTRAS: dict = {
...
@@ -67,9 +67,12 @@ _STRUCT_EXTRAS: dict = {
@model_validator(mode="after")
@model_validator(mode="after")
def _validate_sla_options(self) -> "SLASpec":
def _validate_sla_options(self) -> "SLASpec":
\"\"\"
Ensure at most one SLA mode is active.
\"\"\"
\"\"\"
Ensure at most one SLA mode is active.
\"\"\"
has_ttft_itl = self.ttft is not None and self.itl is not None
has_e2e = self.e2eLatency is not None
has_e2e = self.e2eLatency is not None
has_opt = self.optimizationType is not None
has_opt = self.optimizationType is not None
ttft_itl_touched = "ttft" in self.model_fields_set or "itl" in self.model_fields_set
has_ttft_itl = (self.ttft is not None and self.itl is not None) and (
ttft_itl_touched or (not has_e2e and not has_opt)
)
options_count = sum([has_ttft_itl, has_e2e, has_opt])
options_count = sum([has_ttft_itl, has_e2e, has_opt])
if options_count > 1:
if options_count > 1:
raise ValueError(
raise ValueError(
...
...
deploy/operator/api/scripts/validate_pydantic_models.py
View file @
e4601811
...
@@ -187,6 +187,13 @@ def test_sla_defaults_and_validation():
...
@@ -187,6 +187,13 @@ def test_sla_defaults_and_validation():
# optimizationType mode: OK (null out ttft/itl)
# optimizationType mode: OK (null out ttft/itl)
SLASpec
(
ttft
=
None
,
itl
=
None
,
optimizationType
=
OptimizationType
.
Throughput
)
SLASpec
(
ttft
=
None
,
itl
=
None
,
optimizationType
=
OptimizationType
.
Throughput
)
# optimizationType mode: OK without explicitly nulling defaults (TC-2.5 / TC-2.6)
SLASpec
(
optimizationType
=
OptimizationType
.
Throughput
)
SLASpec
(
optimizationType
=
OptimizationType
.
Latency
)
# e2eLatency mode: OK without explicitly nulling defaults
SLASpec
(
e2eLatency
=
500.0
)
# mixing modes should raise
# mixing modes should raise
try
:
try
:
SLASpec
(
ttft
=
100.0
,
itl
=
10.0
,
e2eLatency
=
500.0
)
SLASpec
(
ttft
=
100.0
,
itl
=
10.0
,
e2eLatency
=
500.0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment