Skip to content

Commit d161ce3

Browse files
Added post-prom. pipelines to ml_service; [skip ci]
1 parent 5a11f6d commit d161ce3

3 files changed

Lines changed: 93 additions & 0 deletions

File tree

ml_service/backend/pipelines/models/pipelines_cli_args.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,17 @@ class RunAllWorkflowsInput(BaseModel):
143143
logging_level: LOGGING_LEVEL = "INFO"
144144
owner: str | None = "Sebastijan"
145145
skip_if_existing: bool | None = True
146+
147+
class InferInput(BaseModel):
148+
"""Model for the input of the inference pipeline."""
149+
problem: str
150+
segment: str
151+
snapshot_bindings_id: str
152+
logging_level: LOGGING_LEVEL = "INFO"
153+
154+
class MonitorInput(BaseModel):
155+
"""Model for the input of the monitoring pipeline."""
156+
problem: str
157+
segment: str
158+
inference_run_id: str | None = None
159+
logging_level: LOGGING_LEVEL = "INFO"

ml_service/backend/routers/pipelines.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
ExplainInput,
1616
FreezeAllFeatureSetsInput,
1717
FreezeFeaturesInput,
18+
InferInput,
19+
MonitorInput,
1820
PromoteInput,
1921
RegisterRawSnapshotInput,
2022
RunAllWorkflowsInput,
@@ -163,3 +165,23 @@ def run_all_workflows(payload: Annotated[RunAllWorkflowsInput, Body(...)], reque
163165
payload=payload,
164166
boolean_args=[],
165167
)
168+
169+
@router.post("/infer", status_code=200)
170+
@limiter.limit("10/minute")
171+
def infer(payload: Annotated[InferInput, Body(...)], request: Request): # type: ignore
172+
"""Executes the inference pipeline."""
173+
return execute_pipeline(
174+
module_path="pipelines.post_promotion.infer",
175+
payload=payload,
176+
boolean_args=[],
177+
)
178+
179+
@router.post("/monitor", status_code=200)
180+
@limiter.limit("10/minute")
181+
def monitor(payload: Annotated[MonitorInput, Body(...)], request: Request): # type: ignore
182+
"""Executes the monitoring pipeline."""
183+
return execute_pipeline(
184+
module_path="pipelines.post_promotion.monitor",
185+
payload=payload,
186+
boolean_args=[],
187+
)

ml_service/frontend/pipelines/pipelines_registry.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
ExplainInput,
1212
FreezeAllFeatureSetsInput,
1313
FreezeFeaturesInput,
14+
InferInput,
15+
MonitorInput,
1416
PromoteInput,
1517
RegisterRawSnapshotInput,
1618
RunAllWorkflowsInput,
@@ -367,6 +369,61 @@
367369
}
368370
}
369371
},
372+
{
373+
"name": "Infer",
374+
"endpoint": "pipelines/infer",
375+
"args_schema": InferInput,
376+
"field_metadata": {
377+
"problem": {
378+
"placeholder": "Model problem, e.g., 'no_show'",
379+
"optional": False
380+
},
381+
"segment": {
382+
"placeholder": "Model segment name, e.g., 'city_hotel_online_ta'",
383+
"optional": False
384+
},
385+
"version": {
386+
"placeholder": "Model version, e.g., 'v1'",
387+
"optional": False
388+
},
389+
"snapshot_bindings_id": {
390+
"placeholder": "A snapshot binding ID to define which snapshot to load for each dataset",
391+
"optional": False
392+
},
393+
"logging_level": {
394+
"optional": True,
395+
"value": "INFO"
396+
}
397+
}
398+
},
399+
{
400+
"name": "Monitor",
401+
"endpoint": "pipelines/monitor",
402+
"args_schema": MonitorInput,
403+
"field_metadata": {
404+
"problem": {
405+
"placeholder": "Model problem, e.g., 'no_show'",
406+
"optional": False
407+
},
408+
"segment": {
409+
"placeholder": "Model segment name, e.g., 'city_hotel_online_ta'",
410+
"optional": False
411+
},
412+
"version": {
413+
"placeholder":"Model version, e.g., 'v1'",
414+
"optional": False
415+
},
416+
"inference_run_id": {
417+
"placeholder":"Inference run id dir name under predictions/{problem}/{segment} (default = latest)",
418+
"optional": True,
419+
},
420+
"logging_level": {
421+
"optional": True,
422+
"value":"INFO"
423+
}
424+
}
425+
426+
},
370427
{
371428
"name": "Execute All Data Preprocessing",
372429
"endpoint": "pipelines/execute_all_data_preprocessing",

0 commit comments

Comments
 (0)