Skip to content

Commit b82fe24

Browse files
Dropdowns for env and stage; [skip ci]
Introduced dropdowns for env and stage cli args in the frontend of the ml_service, similar to the one for logging_level. This ensures that users can only select valid options for these arguments, improving the user experience and reducing the likelihood of errors when executing pipelines.
1 parent fb624dd commit b82fe24

4 files changed

Lines changed: 33 additions & 17 deletions

File tree

ml_service/backend/pipelines/models/pipelines_cli_args.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from pydantic import BaseModel
55

66
LOGGING_LEVEL = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
7+
ENV = Literal["dev", "test", "prod", "default"]
8+
STAGE = Literal["staging", "production"]
79

810
class RegisterRawSnapshotInput(BaseModel):
911
"""Model for the input of the register_raw_snapshot pipeline."""
@@ -44,7 +46,7 @@ class SearchInput(BaseModel):
4446
version: str
4547
experiment_id: str | None = None
4648
snapshot_binding_key: str | None = None
47-
env: str | None = None
49+
env: ENV = "default"
4850
strict: bool | None = True
4951
logging_level: LOGGING_LEVEL = "INFO"
5052
owner: str | None = "Sebastijan"
@@ -58,7 +60,7 @@ class TrainInput(BaseModel):
5860
version: str
5961
snapshot_binding_key: str | None = None
6062
train_run_id: str | None = None
61-
env: str | None = None
63+
env: ENV = "default"
6264
strict: bool | None = True
6365
experiment_id: str | None = None
6466
logging_level: LOGGING_LEVEL = "INFO"
@@ -70,7 +72,7 @@ class EvaluateInput(BaseModel):
7072
problem: str
7173
segment: str
7274
version: str
73-
env: str | None = None
75+
env: ENV = "default"
7476
strict: bool | None = True
7577
experiment_id: str | None = None
7678
train_id: str | None = None
@@ -81,7 +83,7 @@ class ExplainInput(BaseModel):
8183
problem: str
8284
segment: str
8385
version: str
84-
env: str | None = None
86+
env: ENV = "default"
8587
strict: bool | None = True
8688
experiment_id: str | None = None
8789
train_id: str | None = None
@@ -97,7 +99,7 @@ class PromoteInput(BaseModel):
9799
train_run_id: str
98100
eval_run_id: str
99101
explain_run_id: str
100-
stage: str
102+
stage: STAGE = "production"
101103
logging_level: LOGGING_LEVEL = "INFO"
102104

103105
class ExecuteAllDataPreprocessingInput(BaseModel):
@@ -115,7 +117,7 @@ class ExecuteExperimentWithLatestInput(BaseModel):
115117
problem: str
116118
segment: str
117119
version: str
118-
env: str | None = "dev"
120+
env: ENV = "dev"
119121
strict: bool | None = True
120122
logging_level: LOGGING_LEVEL = "INFO"
121123
owner: str | None = "Sebastijan"
@@ -126,7 +128,7 @@ class ExecuteExperimentWithLatestInput(BaseModel):
126128

127129
class ExecuteAllExperimentsWithLatestInput(BaseModel):
128130
"""Model for the input of the execute_all_experiments_with_latest_input pipeline."""
129-
env: str | None = "dev"
131+
env: ENV = "dev"
130132
strict: bool | None = True
131133
logging_level: LOGGING_LEVEL = "INFO"
132134
owner: str | None = "Sebastijan"
@@ -137,7 +139,7 @@ class ExecuteAllExperimentsWithLatestInput(BaseModel):
137139

138140
class RunAllWorkflowsInput(BaseModel):
139141
"""Model for the input of the run_all_workflows pipeline."""
140-
env: str | None = "dev"
142+
env: ENV = "dev"
141143
logging_level: LOGGING_LEVEL = "INFO"
142144
owner: str | None = "Sebastijan"
143145
skip_if_existing: bool | None = True

ml_service/backend/routers/pipelines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def explain(payload: Annotated[ExplainInput, Body(...)], request: Request): # ty
105105
)
106106

107107
@router.post("/promote", status_code=200)
108-
@limiter.limit("1/minute")
108+
@limiter.limit("3/minute")
109109
def promote(payload: Annotated[PromoteInput, Body(...)], request: Request): # type: ignore
110110
"""Executes the promotion pipeline."""
111111
return execute_pipeline(

ml_service/frontend/pipelines/pipelines_metadata.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@ def is_number_field(model_field):
5454
"bold": True,
5555
"optional": is_optional
5656
})
57+
elif field_name == "env":
58+
fields.append({
59+
"name": field_name,
60+
"type": "dropdown",
61+
"options": ["dev", "test", "prod", "default"],
62+
"value": model_field.default if model_field.default is not None else "default",
63+
"bold": True,
64+
"optional": is_optional,
65+
"label": "env (default ~ none)"
66+
})
67+
elif field_name == "stage":
68+
fields.append({
69+
"name": field_name,
70+
"type": "dropdown",
71+
"options": ["staging", "production"],
72+
"value": model_field.default if model_field.default is not None else "production",
73+
"bold": True,
74+
"optional": is_optional,
75+
"label": "stage"
76+
})
5777
elif is_boolean_field(model_field):
5878
fields.append({
5979
"name": field_name,

ml_service/frontend/pipelines/pipelines_registry.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
"optional": True
158158
},
159159
"env": {
160-
"placeholder": "Environment to run the script in (dev/test/prod) (default = default ~ none)",
161160
"optional": True,
162161
"value": "default"
163162
},
@@ -213,7 +212,6 @@
213212
"optional": True
214213
},
215214
"env": {
216-
"placeholder": "Environment to run the script in (dev/test/prod) (default = default ~ none)",
217215
"optional": True,
218216
"value": "default"
219217
},
@@ -260,7 +258,6 @@
260258
"optional": False
261259
},
262260
"env": {
263-
"placeholder": "Environment to run the script in (dev/test/prod) (default = default ~ none)",
264261
"optional": True,
265262
"value": "default"
266263
},
@@ -301,7 +298,6 @@
301298
"optional": False
302299
},
303300
"env": {
304-
"placeholder": "Environment to run the script in (dev/test/prod) (default = default ~ none)",
305301
"optional": True,
306302
"value": "default"
307303
},
@@ -362,8 +358,8 @@
362358
"optional": False
363359
},
364360
"stage": {
365-
"placeholder": "Stage of the promotion (staging or production)",
366-
"optional": False
361+
"optional": False,
362+
"value": "production"
367363
},
368364
"logging_level": {
369365
"optional": True,
@@ -466,7 +462,6 @@
466462
"args_schema": ExecuteAllExperimentsWithLatestInput,
467463
"field_metadata": {
468464
"env": {
469-
"placeholder": "Environment to run the script in (dev/test/prod) (default = dev)",
470465
"optional": True,
471466
"value": "dev"
472467
},
@@ -511,7 +506,6 @@
511506
"args_schema": RunAllWorkflowsInput,
512507
"field_metadata": {
513508
"env": {
514-
"placeholder": "Environment to run the script in (dev/test/prod) (default = dev)",
515509
"optional": True,
516510
"value": "dev"
517511
},

0 commit comments

Comments
 (0)