mlrun 1.8.0rc4__py3-none-any.whl → 1.8.0rc6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mlrun might be problematic. Click here for more details.
- mlrun/__init__.py +4 -3
- mlrun/alerts/alert.py +129 -2
- mlrun/artifacts/__init__.py +1 -1
- mlrun/artifacts/base.py +12 -1
- mlrun/artifacts/document.py +59 -38
- mlrun/common/model_monitoring/__init__.py +0 -2
- mlrun/common/model_monitoring/helpers.py +0 -28
- mlrun/common/schemas/__init__.py +1 -4
- mlrun/common/schemas/alert.py +3 -0
- mlrun/common/schemas/artifact.py +4 -0
- mlrun/common/schemas/client_spec.py +0 -1
- mlrun/common/schemas/model_monitoring/__init__.py +0 -6
- mlrun/common/schemas/model_monitoring/constants.py +11 -9
- mlrun/common/schemas/model_monitoring/model_endpoints.py +77 -149
- mlrun/common/schemas/notification.py +6 -0
- mlrun/config.py +0 -2
- mlrun/datastore/datastore_profile.py +57 -17
- mlrun/datastore/vectorstore.py +67 -59
- mlrun/db/base.py +22 -18
- mlrun/db/factory.py +0 -3
- mlrun/db/httpdb.py +122 -150
- mlrun/db/nopdb.py +33 -17
- mlrun/execution.py +43 -29
- mlrun/model.py +7 -0
- mlrun/model_monitoring/__init__.py +3 -2
- mlrun/model_monitoring/api.py +40 -43
- mlrun/model_monitoring/applications/_application_steps.py +4 -2
- mlrun/model_monitoring/applications/base.py +65 -6
- mlrun/model_monitoring/applications/context.py +64 -33
- mlrun/model_monitoring/applications/evidently_base.py +0 -1
- mlrun/model_monitoring/applications/histogram_data_drift.py +2 -6
- mlrun/model_monitoring/controller.py +43 -37
- mlrun/model_monitoring/db/__init__.py +0 -2
- mlrun/model_monitoring/db/tsdb/base.py +2 -1
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +2 -1
- mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +43 -0
- mlrun/model_monitoring/helpers.py +12 -66
- mlrun/model_monitoring/stream_processing.py +83 -270
- mlrun/model_monitoring/writer.py +1 -10
- mlrun/projects/project.py +87 -74
- mlrun/runtimes/nuclio/function.py +7 -6
- mlrun/runtimes/nuclio/serving.py +7 -1
- mlrun/serving/routers.py +158 -145
- mlrun/serving/server.py +6 -0
- mlrun/serving/states.py +2 -0
- mlrun/serving/v2_serving.py +69 -60
- mlrun/utils/helpers.py +14 -30
- mlrun/utils/notifications/notification/mail.py +36 -9
- mlrun/utils/notifications/notification_pusher.py +34 -13
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.8.0rc4.dist-info → mlrun-1.8.0rc6.dist-info}/METADATA +5 -4
- {mlrun-1.8.0rc4.dist-info → mlrun-1.8.0rc6.dist-info}/RECORD +56 -69
- mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +0 -149
- mlrun/model_monitoring/db/stores/__init__.py +0 -136
- mlrun/model_monitoring/db/stores/base/__init__.py +0 -15
- mlrun/model_monitoring/db/stores/base/store.py +0 -154
- mlrun/model_monitoring/db/stores/sqldb/__init__.py +0 -13
- mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -46
- mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -93
- mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -47
- mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -25
- mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -408
- mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +0 -13
- mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -464
- mlrun/model_monitoring/model_endpoint.py +0 -120
- {mlrun-1.8.0rc4.dist-info → mlrun-1.8.0rc6.dist-info}/LICENSE +0 -0
- {mlrun-1.8.0rc4.dist-info → mlrun-1.8.0rc6.dist-info}/WHEEL +0 -0
- {mlrun-1.8.0rc4.dist-info → mlrun-1.8.0rc6.dist-info}/entry_points.txt +0 -0
- {mlrun-1.8.0rc4.dist-info → mlrun-1.8.0rc6.dist-info}/top_level.txt +0 -0
mlrun/db/base.py
CHANGED
|
@@ -663,16 +663,16 @@ class RunDBInterface(ABC):
|
|
|
663
663
|
@abstractmethod
|
|
664
664
|
def create_model_endpoint(
|
|
665
665
|
self,
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
model_endpoint: Union[mlrun.model_monitoring.ModelEndpoint, dict],
|
|
669
|
-
):
|
|
666
|
+
model_endpoint: mlrun.common.schemas.ModelEndpoint,
|
|
667
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
670
668
|
pass
|
|
671
669
|
|
|
672
670
|
@abstractmethod
|
|
673
671
|
def delete_model_endpoint(
|
|
674
672
|
self,
|
|
673
|
+
name: str,
|
|
675
674
|
project: str,
|
|
675
|
+
function_name: str,
|
|
676
676
|
endpoint_id: str,
|
|
677
677
|
):
|
|
678
678
|
pass
|
|
@@ -681,36 +681,40 @@ class RunDBInterface(ABC):
|
|
|
681
681
|
def list_model_endpoints(
|
|
682
682
|
self,
|
|
683
683
|
project: str,
|
|
684
|
-
|
|
685
|
-
|
|
684
|
+
name: Optional[str] = None,
|
|
685
|
+
function_name: Optional[str] = None,
|
|
686
|
+
model_name: Optional[str] = None,
|
|
686
687
|
labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
|
|
687
|
-
start:
|
|
688
|
-
end:
|
|
689
|
-
|
|
688
|
+
start: Optional[datetime.datetime] = None,
|
|
689
|
+
end: Optional[datetime.datetime] = None,
|
|
690
|
+
tsdb_metrics: bool = True,
|
|
690
691
|
top_level: bool = False,
|
|
691
692
|
uids: Optional[list[str]] = None,
|
|
692
|
-
|
|
693
|
+
latest_only: bool = False,
|
|
694
|
+
) -> mlrun.common.schemas.ModelEndpointList:
|
|
693
695
|
pass
|
|
694
696
|
|
|
695
697
|
@abstractmethod
|
|
696
698
|
def get_model_endpoint(
|
|
697
699
|
self,
|
|
700
|
+
name: str,
|
|
698
701
|
project: str,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
) -> mlrun.model_monitoring.ModelEndpoint:
|
|
702
|
+
function_name: Optional[str] = None,
|
|
703
|
+
endpoint_id: Optional[str] = None,
|
|
704
|
+
tsdb_metrics: bool = True,
|
|
705
|
+
feature_analysis: bool = False,
|
|
706
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
705
707
|
pass
|
|
706
708
|
|
|
707
709
|
@abstractmethod
|
|
708
710
|
def patch_model_endpoint(
|
|
709
711
|
self,
|
|
712
|
+
name: str,
|
|
710
713
|
project: str,
|
|
711
|
-
endpoint_id: str,
|
|
712
714
|
attributes: dict,
|
|
713
|
-
|
|
715
|
+
function_name: Optional[str] = None,
|
|
716
|
+
endpoint_id: Optional[str] = None,
|
|
717
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
714
718
|
pass
|
|
715
719
|
|
|
716
720
|
@abstractmethod
|
mlrun/db/factory.py
CHANGED
|
@@ -54,9 +54,6 @@ class RunDBFactory(
|
|
|
54
54
|
self._run_db = self._rundb_container.nop(url)
|
|
55
55
|
|
|
56
56
|
else:
|
|
57
|
-
# TODO: this practically makes the SQLRunDB a singleton, which mean that its session is shared, needs
|
|
58
|
-
# to be refreshed frequently and cannot be used concurrently.
|
|
59
|
-
# The SQLRunDB should always get its session from the FastAPI dependency injection.
|
|
60
57
|
self._run_db = self._rundb_container.run_db(url)
|
|
61
58
|
|
|
62
59
|
self._run_db.connect(secrets=secrets)
|
mlrun/db/httpdb.py
CHANGED
|
@@ -28,7 +28,7 @@ from urllib.parse import urlparse
|
|
|
28
28
|
import pydantic.v1
|
|
29
29
|
import requests
|
|
30
30
|
import semver
|
|
31
|
-
from pydantic import parse_obj_as
|
|
31
|
+
from pydantic.v1 import parse_obj_as
|
|
32
32
|
|
|
33
33
|
import mlrun
|
|
34
34
|
import mlrun.common.constants
|
|
@@ -37,7 +37,6 @@ import mlrun.common.runtimes
|
|
|
37
37
|
import mlrun.common.schemas
|
|
38
38
|
import mlrun.common.schemas.model_monitoring.model_endpoints as mm_endpoints
|
|
39
39
|
import mlrun.common.types
|
|
40
|
-
import mlrun.model_monitoring.model_endpoint
|
|
41
40
|
import mlrun.platforms
|
|
42
41
|
import mlrun.projects
|
|
43
42
|
import mlrun.runtimes.nuclio.api_gateway
|
|
@@ -558,10 +557,6 @@ class HTTPRunDB(RunDBInterface):
|
|
|
558
557
|
server_cfg.get("external_platform_tracking")
|
|
559
558
|
or config.external_platform_tracking
|
|
560
559
|
)
|
|
561
|
-
config.model_endpoint_monitoring.endpoint_store_connection = (
|
|
562
|
-
server_cfg.get("model_endpoint_monitoring_endpoint_store_connection")
|
|
563
|
-
or config.model_endpoint_monitoring.endpoint_store_connection
|
|
564
|
-
)
|
|
565
560
|
config.model_endpoint_monitoring.tsdb_connection = (
|
|
566
561
|
server_cfg.get("model_monitoring_tsdb_connection")
|
|
567
562
|
or config.model_endpoint_monitoring.tsdb_connection
|
|
@@ -1701,6 +1696,8 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1701
1696
|
name: Optional[str] = None,
|
|
1702
1697
|
kind: mlrun.common.schemas.ScheduleKinds = None,
|
|
1703
1698
|
include_last_run: bool = False,
|
|
1699
|
+
next_run_time_since: Optional[datetime] = None,
|
|
1700
|
+
next_run_time_until: Optional[datetime] = None,
|
|
1704
1701
|
) -> mlrun.common.schemas.SchedulesOutput:
|
|
1705
1702
|
"""Retrieve list of schedules of specific name or kind.
|
|
1706
1703
|
|
|
@@ -1709,10 +1706,18 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1709
1706
|
:param kind: Kind of schedule objects to retrieve, can be either ``job`` or ``pipeline``.
|
|
1710
1707
|
:param include_last_run: Whether to return for each schedule returned also the results of the last run of
|
|
1711
1708
|
that schedule.
|
|
1709
|
+
:param next_run_time_since: Return only schedules with next run time after this date.
|
|
1710
|
+
:param next_run_time_until: Return only schedules with next run time before this date.
|
|
1712
1711
|
"""
|
|
1713
1712
|
|
|
1714
1713
|
project = project or config.default_project
|
|
1715
|
-
params = {
|
|
1714
|
+
params = {
|
|
1715
|
+
"kind": kind,
|
|
1716
|
+
"name": name,
|
|
1717
|
+
"include_last_run": include_last_run,
|
|
1718
|
+
"next_run_time_since": datetime_to_iso(next_run_time_since),
|
|
1719
|
+
"next_run_time_until": datetime_to_iso(next_run_time_until),
|
|
1720
|
+
}
|
|
1716
1721
|
path = f"projects/{project}/schedules"
|
|
1717
1722
|
error_message = f"Failed listing schedules for {project} ? {kind} {name}"
|
|
1718
1723
|
resp = self.api_call("GET", path, error_message, params=params)
|
|
@@ -3504,217 +3509,180 @@ class HTTPRunDB(RunDBInterface):
|
|
|
3504
3509
|
|
|
3505
3510
|
def create_model_endpoint(
|
|
3506
3511
|
self,
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
model_endpoint: Union[
|
|
3510
|
-
mlrun.model_monitoring.model_endpoint.ModelEndpoint, dict
|
|
3511
|
-
],
|
|
3512
|
-
):
|
|
3512
|
+
model_endpoint: mlrun.common.schemas.ModelEndpoint,
|
|
3513
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
3513
3514
|
"""
|
|
3514
3515
|
Creates a DB record with the given model_endpoint record.
|
|
3515
3516
|
|
|
3516
|
-
:param project: The name of the project.
|
|
3517
|
-
:param endpoint_id: The id of the endpoint.
|
|
3518
3517
|
:param model_endpoint: An object representing the model endpoint.
|
|
3519
|
-
"""
|
|
3520
3518
|
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
):
|
|
3524
|
-
model_endpoint = model_endpoint.to_dict()
|
|
3519
|
+
:return: The created model endpoint object.
|
|
3520
|
+
"""
|
|
3525
3521
|
|
|
3526
|
-
path = f"projects/{project}/model-endpoints
|
|
3527
|
-
self.api_call(
|
|
3528
|
-
method=
|
|
3522
|
+
path = f"projects/{model_endpoint.metadata.project}/model-endpoints"
|
|
3523
|
+
response = self.api_call(
|
|
3524
|
+
method=mlrun.common.types.HTTPMethod.POST,
|
|
3529
3525
|
path=path,
|
|
3530
|
-
body=
|
|
3526
|
+
body=model_endpoint.json(),
|
|
3531
3527
|
)
|
|
3528
|
+
return mlrun.common.schemas.ModelEndpoint(**response.json())
|
|
3532
3529
|
|
|
3533
3530
|
def delete_model_endpoint(
|
|
3534
3531
|
self,
|
|
3532
|
+
name: str,
|
|
3535
3533
|
project: str,
|
|
3534
|
+
function_name: str,
|
|
3536
3535
|
endpoint_id: str,
|
|
3537
3536
|
):
|
|
3538
3537
|
"""
|
|
3539
3538
|
Deletes the DB record of a given model endpoint, project and endpoint_id are used for lookup
|
|
3540
3539
|
|
|
3540
|
+
:param name: The name of the model endpoint
|
|
3541
3541
|
:param project: The name of the project
|
|
3542
|
+
:param function_name: The name of the function
|
|
3542
3543
|
:param endpoint_id: The id of the endpoint
|
|
3543
3544
|
"""
|
|
3544
3545
|
|
|
3545
|
-
path = f"projects/{project}/model-endpoints/{
|
|
3546
|
+
path = f"projects/{project}/model-endpoints/{name}"
|
|
3546
3547
|
self.api_call(
|
|
3547
|
-
method=
|
|
3548
|
+
method=mlrun.common.types.HTTPMethod.DELETE,
|
|
3548
3549
|
path=path,
|
|
3550
|
+
params={
|
|
3551
|
+
"function_name": function_name,
|
|
3552
|
+
"endpoint_id": endpoint_id,
|
|
3553
|
+
},
|
|
3549
3554
|
)
|
|
3550
3555
|
|
|
3551
3556
|
def list_model_endpoints(
|
|
3552
3557
|
self,
|
|
3553
3558
|
project: str,
|
|
3554
|
-
|
|
3555
|
-
|
|
3559
|
+
name: Optional[str] = None,
|
|
3560
|
+
function_name: Optional[str] = None,
|
|
3561
|
+
model_name: Optional[str] = None,
|
|
3556
3562
|
labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
|
|
3557
|
-
start:
|
|
3558
|
-
end:
|
|
3559
|
-
|
|
3563
|
+
start: Optional[datetime] = None,
|
|
3564
|
+
end: Optional[datetime] = None,
|
|
3565
|
+
tsdb_metrics: bool = True,
|
|
3560
3566
|
top_level: bool = False,
|
|
3561
3567
|
uids: Optional[list[str]] = None,
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
model
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
:param
|
|
3578
|
-
:
|
|
3579
|
-
:param function: The name of the function to filter by
|
|
3580
|
-
:param labels: Filter model endpoints by label key-value pairs or key existence. This can be provided as:
|
|
3581
|
-
- A dictionary in the format `{"label": "value"}` to match specific label key-value pairs,
|
|
3582
|
-
or `{"label": None}` to check for key existence.
|
|
3583
|
-
- A list of strings formatted as `"label=value"` to match specific label key-value pairs,
|
|
3584
|
-
or just `"label"` for key existence.
|
|
3585
|
-
- A comma-separated string formatted as `"label1=value1,label2"` to match entities with
|
|
3586
|
-
the specified key-value pairs or key existence.
|
|
3587
|
-
:param metrics: A list of metrics to return for each endpoint, read more in 'TimeMetric'
|
|
3588
|
-
:param start: The start time of the metrics. Can be represented by a string containing an RFC 3339 time, a
|
|
3589
|
-
Unix timestamp in milliseconds, a relative time (`'now'` or `'now-[0-9]+[mhd]'`, where
|
|
3590
|
-
`m` = minutes, `h` = hours, `'d'` = days, and `'s'` = seconds), or 0 for the earliest time.
|
|
3591
|
-
:param end: The end time of the metrics. Can be represented by a string containing an RFC 3339 time, a
|
|
3592
|
-
Unix timestamp in milliseconds, a relative time (`'now'` or `'now-[0-9]+[mhd]'`, where
|
|
3593
|
-
`m` = minutes, `h` = hours, `'d'` = days, and `'s'` = seconds), or 0 for the earliest time.
|
|
3594
|
-
:param top_level: if true will return only routers and endpoint that are NOT children of any router
|
|
3595
|
-
:param uids: if passed will return a list `ModelEndpoint` object with uid in uids
|
|
3596
|
-
|
|
3597
|
-
:returns: Returns a list of `ModelEndpoint` objects.
|
|
3568
|
+
latest_only: bool = False,
|
|
3569
|
+
) -> mlrun.common.schemas.ModelEndpointList:
|
|
3570
|
+
"""
|
|
3571
|
+
List model endpoints with optional filtering by name, function name, model name, labels, and time range.
|
|
3572
|
+
|
|
3573
|
+
:param project: The name of the project
|
|
3574
|
+
:param name: The name of the model endpoint
|
|
3575
|
+
:param function_name: The name of the function
|
|
3576
|
+
:param model_name: The name of the model
|
|
3577
|
+
:param labels: A list of labels to filter by. (see mlrun.common.schemas.LabelsModel)
|
|
3578
|
+
:param start: The start time to filter by.Corresponding to the `created` field.
|
|
3579
|
+
:param end: The end time to filter by. Corresponding to the `created` field.
|
|
3580
|
+
:param tsdb_metrics: Whether to include metrics from the time series DB.
|
|
3581
|
+
:param top_level: Whether to return only top level model endpoints.
|
|
3582
|
+
:param uids: A list of unique ids to filter by.
|
|
3583
|
+
:param latest_only: Whether to return only the latest model endpoint version.
|
|
3584
|
+
:return: A list of model endpoints.
|
|
3598
3585
|
"""
|
|
3599
|
-
|
|
3600
3586
|
path = f"projects/{project}/model-endpoints"
|
|
3601
3587
|
labels = self._parse_labels(labels)
|
|
3602
3588
|
|
|
3603
3589
|
response = self.api_call(
|
|
3604
|
-
method=
|
|
3590
|
+
method=mlrun.common.types.HTTPMethod.GET,
|
|
3605
3591
|
path=path,
|
|
3606
3592
|
params={
|
|
3607
|
-
"
|
|
3608
|
-
"
|
|
3593
|
+
"name": name,
|
|
3594
|
+
"model_name": model_name,
|
|
3595
|
+
"function_name": function_name,
|
|
3609
3596
|
"label": labels,
|
|
3610
|
-
"start": start,
|
|
3611
|
-
"end": end,
|
|
3612
|
-
"
|
|
3597
|
+
"start": datetime_to_iso(start),
|
|
3598
|
+
"end": datetime_to_iso(end),
|
|
3599
|
+
"tsdb_metrics": tsdb_metrics,
|
|
3613
3600
|
"top-level": top_level,
|
|
3614
3601
|
"uid": uids,
|
|
3602
|
+
"latest_only": latest_only,
|
|
3615
3603
|
},
|
|
3616
3604
|
)
|
|
3617
3605
|
|
|
3618
|
-
|
|
3619
|
-
model_endpoints = response.json()["endpoints"]
|
|
3620
|
-
if model_endpoints:
|
|
3621
|
-
return [
|
|
3622
|
-
mlrun.model_monitoring.model_endpoint.ModelEndpoint.from_dict(obj)
|
|
3623
|
-
for obj in model_endpoints
|
|
3624
|
-
]
|
|
3625
|
-
return []
|
|
3606
|
+
return mlrun.common.schemas.ModelEndpointList(**response.json())
|
|
3626
3607
|
|
|
3627
3608
|
def get_model_endpoint(
|
|
3628
3609
|
self,
|
|
3610
|
+
name: str,
|
|
3629
3611
|
project: str,
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3612
|
+
function_name: Optional[str] = None,
|
|
3613
|
+
# TODO: function_tag
|
|
3614
|
+
endpoint_id: Optional[str] = None,
|
|
3615
|
+
tsdb_metrics: bool = True,
|
|
3634
3616
|
feature_analysis: bool = False,
|
|
3635
|
-
) -> mlrun.
|
|
3617
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
3636
3618
|
"""
|
|
3637
3619
|
Returns a single `ModelEndpoint` object with additional metrics and feature related data.
|
|
3638
3620
|
|
|
3621
|
+
:param name: The name of the model endpoint
|
|
3639
3622
|
:param project: The name of the project
|
|
3640
|
-
:param
|
|
3641
|
-
:param
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
metrics for model endpoints such as predictions_per_second and
|
|
3651
|
-
latency_avg_5m but also custom metrics defined by the user. Please note that
|
|
3652
|
-
these metrics are stored in the time series DB and the results will be
|
|
3653
|
-
appeared under model_endpoint.spec.metrics.
|
|
3654
|
-
:param feature_analysis: When True, the base feature statistics and current feature statistics will
|
|
3655
|
-
be added to the output of the resulting object.
|
|
3656
|
-
|
|
3657
|
-
:returns: A `ModelEndpoint` object.
|
|
3658
|
-
"""
|
|
3659
|
-
|
|
3660
|
-
path = f"projects/{project}/model-endpoints/{endpoint_id}"
|
|
3623
|
+
:param function_name: The name of the function
|
|
3624
|
+
:param endpoint_id: The id of the endpoint
|
|
3625
|
+
:param tsdb_metrics: Whether to include metrics from the time series DB.
|
|
3626
|
+
:param feature_analysis: Whether to include feature analysis data (feature_stats,
|
|
3627
|
+
current_stats & drift_measures).
|
|
3628
|
+
|
|
3629
|
+
:return: A `ModelEndpoint` object.
|
|
3630
|
+
"""
|
|
3631
|
+
|
|
3632
|
+
path = f"projects/{project}/model-endpoints/{name}"
|
|
3661
3633
|
response = self.api_call(
|
|
3662
|
-
method=
|
|
3634
|
+
method=mlrun.common.types.HTTPMethod.GET,
|
|
3663
3635
|
path=path,
|
|
3664
3636
|
params={
|
|
3665
|
-
"
|
|
3666
|
-
"
|
|
3667
|
-
"
|
|
3637
|
+
"function_name": function_name,
|
|
3638
|
+
"endpoint_id": endpoint_id,
|
|
3639
|
+
"tsdb_metrics": tsdb_metrics,
|
|
3668
3640
|
"feature_analysis": feature_analysis,
|
|
3669
3641
|
},
|
|
3670
3642
|
)
|
|
3671
3643
|
|
|
3672
|
-
return mlrun.
|
|
3673
|
-
response.json()
|
|
3674
|
-
)
|
|
3644
|
+
return mlrun.common.schemas.ModelEndpoint(**response.json())
|
|
3675
3645
|
|
|
3676
3646
|
def patch_model_endpoint(
|
|
3677
3647
|
self,
|
|
3648
|
+
name: str,
|
|
3678
3649
|
project: str,
|
|
3679
|
-
endpoint_id: str,
|
|
3680
3650
|
attributes: dict,
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
:param project: The name of the project.
|
|
3686
|
-
:param endpoint_id: The id of the endpoint.
|
|
3687
|
-
:param attributes: Dictionary of attributes that will be used for update the model endpoint. The keys
|
|
3688
|
-
of this dictionary should exist in the target table. Note that the values should be from type string or from
|
|
3689
|
-
a valid numerical type such as int or float. More details about the model endpoint available attributes can
|
|
3690
|
-
be found under :py:class:`~mlrun.common.schemas.ModelEndpoint`.
|
|
3691
|
-
|
|
3692
|
-
Example::
|
|
3693
|
-
|
|
3694
|
-
# Generate current stats for two features
|
|
3695
|
-
current_stats = {'tvd_sum': 2.2,
|
|
3696
|
-
'tvd_mean': 0.5,
|
|
3697
|
-
'hellinger_sum': 3.6,
|
|
3698
|
-
'hellinger_mean': 0.9,
|
|
3699
|
-
'kld_sum': 24.2,
|
|
3700
|
-
'kld_mean': 6.0,
|
|
3701
|
-
'f1': {'tvd': 0.5, 'hellinger': 1.0, 'kld': 6.4},
|
|
3702
|
-
'f2': {'tvd': 0.5, 'hellinger': 1.0, 'kld': 6.5}}
|
|
3703
|
-
|
|
3704
|
-
# Create attributes dictionary according to the required format
|
|
3705
|
-
attributes = {`current_stats`: json.dumps(current_stats),
|
|
3706
|
-
`drift_status`: "DRIFT_DETECTED"}
|
|
3707
|
-
|
|
3651
|
+
function_name: Optional[str] = None,
|
|
3652
|
+
endpoint_id: Optional[str] = None,
|
|
3653
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
3708
3654
|
"""
|
|
3655
|
+
Updates a model endpoint with the given attributes.
|
|
3709
3656
|
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3657
|
+
:param name: The name of the model endpoint
|
|
3658
|
+
:param project: The name of the project
|
|
3659
|
+
:param attributes: The attributes to update
|
|
3660
|
+
:param function_name: The name of the function
|
|
3661
|
+
:param endpoint_id: The id of the endpoint
|
|
3662
|
+
:return: The updated `ModelEndpoint` object.
|
|
3663
|
+
"""
|
|
3664
|
+
attributes_keys = list(attributes.keys())
|
|
3665
|
+
attributes["name"] = name
|
|
3666
|
+
attributes["project"] = project
|
|
3667
|
+
attributes["uid"] = endpoint_id or ""
|
|
3668
|
+
model_endpoint = mlrun.common.schemas.ModelEndpoint.from_flat_dict(attributes)
|
|
3669
|
+
path = f"projects/{project}/model-endpoints"
|
|
3670
|
+
logger.info(
|
|
3671
|
+
"Patching model endpoint",
|
|
3672
|
+
attributes_keys=attributes_keys,
|
|
3673
|
+
model_endpoint=model_endpoint,
|
|
3674
|
+
)
|
|
3675
|
+
response = self.api_call(
|
|
3676
|
+
method=mlrun.common.types.HTTPMethod.PATCH,
|
|
3714
3677
|
path=path,
|
|
3715
|
-
params=
|
|
3678
|
+
params={
|
|
3679
|
+
"attribute-key": attributes_keys,
|
|
3680
|
+
},
|
|
3681
|
+
body=model_endpoint.json(),
|
|
3716
3682
|
)
|
|
3717
3683
|
|
|
3684
|
+
return mlrun.common.schemas.ModelEndpoint(**response.json())
|
|
3685
|
+
|
|
3718
3686
|
def update_model_monitoring_controller(
|
|
3719
3687
|
self,
|
|
3720
3688
|
project: str,
|
|
@@ -5074,7 +5042,11 @@ class HTTPRunDB(RunDBInterface):
|
|
|
5074
5042
|
until: Optional[datetime] = None,
|
|
5075
5043
|
entity: Optional[str] = None,
|
|
5076
5044
|
severity: Optional[
|
|
5077
|
-
|
|
5045
|
+
Union[
|
|
5046
|
+
mlrun.common.schemas.alert.AlertSeverity,
|
|
5047
|
+
str,
|
|
5048
|
+
list[Union[mlrun.common.schemas.alert.AlertSeverity, str]],
|
|
5049
|
+
]
|
|
5078
5050
|
] = None,
|
|
5079
5051
|
entity_kind: Optional[
|
|
5080
5052
|
Union[mlrun.common.schemas.alert.EventEntityKind, str]
|
|
@@ -5091,7 +5063,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
5091
5063
|
"since": datetime_to_iso(since),
|
|
5092
5064
|
"until": datetime_to_iso(until),
|
|
5093
5065
|
"entity": entity,
|
|
5094
|
-
"severity": severity,
|
|
5066
|
+
"severity": mlrun.utils.helpers.as_list(severity) if severity else None,
|
|
5095
5067
|
"entity-kind": entity_kind,
|
|
5096
5068
|
"event-kind": event_kind,
|
|
5097
5069
|
"page": page,
|
mlrun/db/nopdb.py
CHANGED
|
@@ -22,6 +22,7 @@ import mlrun.common.runtimes.constants
|
|
|
22
22
|
import mlrun.common.schemas
|
|
23
23
|
import mlrun.errors
|
|
24
24
|
import mlrun.lists
|
|
25
|
+
import mlrun.model_monitoring
|
|
25
26
|
|
|
26
27
|
from ..config import config
|
|
27
28
|
from ..utils import logger
|
|
@@ -573,39 +574,54 @@ class NopDB(RunDBInterface):
|
|
|
573
574
|
|
|
574
575
|
def create_model_endpoint(
|
|
575
576
|
self,
|
|
576
|
-
project: str,
|
|
577
|
-
endpoint_id: str,
|
|
578
577
|
model_endpoint: mlrun.common.schemas.ModelEndpoint,
|
|
579
|
-
):
|
|
578
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
580
579
|
pass
|
|
581
580
|
|
|
582
|
-
def delete_model_endpoint(
|
|
581
|
+
def delete_model_endpoint(
|
|
582
|
+
self,
|
|
583
|
+
name: str,
|
|
584
|
+
project: str,
|
|
585
|
+
function_name: str,
|
|
586
|
+
endpoint_id: str,
|
|
587
|
+
):
|
|
583
588
|
pass
|
|
584
589
|
|
|
585
590
|
def list_model_endpoints(
|
|
586
591
|
self,
|
|
587
592
|
project: str,
|
|
588
|
-
|
|
589
|
-
|
|
593
|
+
name: Optional[str] = None,
|
|
594
|
+
function_name: Optional[str] = None,
|
|
595
|
+
model_name: Optional[str] = None,
|
|
590
596
|
labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
|
|
591
|
-
start:
|
|
592
|
-
end:
|
|
593
|
-
|
|
594
|
-
|
|
597
|
+
start: Optional[datetime.datetime] = None,
|
|
598
|
+
end: Optional[datetime.datetime] = None,
|
|
599
|
+
tsdb_metrics: bool = True,
|
|
600
|
+
top_level: bool = False,
|
|
601
|
+
uids: Optional[list[str]] = None,
|
|
602
|
+
latest_only: bool = False,
|
|
603
|
+
) -> mlrun.common.schemas.ModelEndpointList:
|
|
595
604
|
pass
|
|
596
605
|
|
|
597
606
|
def get_model_endpoint(
|
|
598
607
|
self,
|
|
608
|
+
name: str,
|
|
599
609
|
project: str,
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
):
|
|
610
|
+
function_name: Optional[str] = None,
|
|
611
|
+
endpoint_id: Optional[str] = None,
|
|
612
|
+
tsdb_metrics: bool = True,
|
|
613
|
+
feature_analysis: bool = False,
|
|
614
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
606
615
|
pass
|
|
607
616
|
|
|
608
|
-
def patch_model_endpoint(
|
|
617
|
+
def patch_model_endpoint(
|
|
618
|
+
self,
|
|
619
|
+
name: str,
|
|
620
|
+
project: str,
|
|
621
|
+
attributes: dict,
|
|
622
|
+
function_name: Optional[str] = None,
|
|
623
|
+
endpoint_id: Optional[str] = None,
|
|
624
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
609
625
|
pass
|
|
610
626
|
|
|
611
627
|
def create_hub_source(
|