mlrun 1.8.0rc5__py3-none-any.whl → 1.8.0rc9__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 +1 -0
- mlrun/artifacts/__init__.py +1 -1
- mlrun/artifacts/base.py +21 -1
- mlrun/artifacts/document.py +62 -39
- mlrun/artifacts/manager.py +12 -5
- mlrun/common/constants.py +1 -0
- mlrun/common/model_monitoring/__init__.py +0 -2
- mlrun/common/model_monitoring/helpers.py +0 -28
- mlrun/common/schemas/__init__.py +2 -4
- mlrun/common/schemas/alert.py +77 -1
- 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/common/schemas/project.py +3 -0
- mlrun/config.py +2 -3
- mlrun/datastore/datastore_profile.py +57 -17
- mlrun/datastore/sources.py +1 -2
- mlrun/datastore/store_resources.py +7 -2
- mlrun/datastore/vectorstore.py +99 -62
- mlrun/db/base.py +34 -20
- mlrun/db/httpdb.py +249 -163
- mlrun/db/nopdb.py +40 -17
- mlrun/execution.py +14 -7
- mlrun/feature_store/api.py +1 -0
- mlrun/model.py +3 -0
- mlrun/model_monitoring/__init__.py +3 -2
- mlrun/model_monitoring/api.py +64 -53
- mlrun/model_monitoring/applications/_application_steps.py +3 -1
- mlrun/model_monitoring/applications/base.py +115 -15
- mlrun/model_monitoring/applications/context.py +42 -24
- mlrun/model_monitoring/applications/histogram_data_drift.py +1 -1
- 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 +78 -66
- mlrun/model_monitoring/stream_processing.py +83 -270
- mlrun/model_monitoring/writer.py +1 -10
- mlrun/projects/pipelines.py +37 -1
- mlrun/projects/project.py +173 -70
- mlrun/run.py +40 -0
- mlrun/runtimes/nuclio/function.py +7 -6
- mlrun/runtimes/nuclio/serving.py +9 -4
- mlrun/serving/routers.py +158 -145
- mlrun/serving/server.py +6 -0
- mlrun/serving/states.py +21 -7
- mlrun/serving/v2_serving.py +94 -68
- mlrun/utils/helpers.py +23 -33
- mlrun/utils/notifications/notification/mail.py +17 -6
- mlrun/utils/notifications/notification_pusher.py +9 -5
- mlrun/utils/regex.py +8 -1
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc9.dist-info}/METADATA +2 -2
- {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc9.dist-info}/RECORD +61 -74
- 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.0rc5.dist-info → mlrun-1.8.0rc9.dist-info}/LICENSE +0 -0
- {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc9.dist-info}/WHEEL +0 -0
- {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc9.dist-info}/entry_points.txt +0 -0
- {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc9.dist-info}/top_level.txt +0 -0
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
|
|
@@ -49,6 +48,7 @@ from mlrun.errors import MLRunInvalidArgumentError, err_to_str
|
|
|
49
48
|
from mlrun_pipelines.utils import compile_pipeline
|
|
50
49
|
|
|
51
50
|
from ..artifacts import Artifact
|
|
51
|
+
from ..common.schemas import AlertActivations
|
|
52
52
|
from ..config import config
|
|
53
53
|
from ..datastore.datastore_profile import DatastoreProfile2Json
|
|
54
54
|
from ..feature_store import FeatureSet, FeatureVector
|
|
@@ -558,10 +558,6 @@ class HTTPRunDB(RunDBInterface):
|
|
|
558
558
|
server_cfg.get("external_platform_tracking")
|
|
559
559
|
or config.external_platform_tracking
|
|
560
560
|
)
|
|
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
561
|
config.model_endpoint_monitoring.tsdb_connection = (
|
|
566
562
|
server_cfg.get("model_monitoring_tsdb_connection")
|
|
567
563
|
or config.model_endpoint_monitoring.tsdb_connection
|
|
@@ -1000,7 +996,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1000
996
|
tag=None,
|
|
1001
997
|
project="",
|
|
1002
998
|
tree=None,
|
|
1003
|
-
):
|
|
999
|
+
) -> dict[str, str]:
|
|
1004
1000
|
"""Store an artifact in the DB.
|
|
1005
1001
|
|
|
1006
1002
|
:param key: Identifying key of the artifact.
|
|
@@ -1012,6 +1008,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1012
1008
|
:param tag: Tag of the artifact.
|
|
1013
1009
|
:param project: Project that the artifact belongs to.
|
|
1014
1010
|
:param tree: The tree (producer id) which generated this artifact.
|
|
1011
|
+
:returns: The stored artifact dictionary.
|
|
1015
1012
|
"""
|
|
1016
1013
|
if uid:
|
|
1017
1014
|
warnings.warn(
|
|
@@ -1036,9 +1033,10 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1036
1033
|
params["tree"] = tree
|
|
1037
1034
|
|
|
1038
1035
|
body = _as_json(artifact)
|
|
1039
|
-
self.api_call(
|
|
1036
|
+
response = self.api_call(
|
|
1040
1037
|
"PUT", endpoint_path, error, body=body, params=params, version="v2"
|
|
1041
1038
|
)
|
|
1039
|
+
return response.json()
|
|
1042
1040
|
|
|
1043
1041
|
def read_artifact(
|
|
1044
1042
|
self,
|
|
@@ -1701,6 +1699,8 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1701
1699
|
name: Optional[str] = None,
|
|
1702
1700
|
kind: mlrun.common.schemas.ScheduleKinds = None,
|
|
1703
1701
|
include_last_run: bool = False,
|
|
1702
|
+
next_run_time_since: Optional[datetime] = None,
|
|
1703
|
+
next_run_time_until: Optional[datetime] = None,
|
|
1704
1704
|
) -> mlrun.common.schemas.SchedulesOutput:
|
|
1705
1705
|
"""Retrieve list of schedules of specific name or kind.
|
|
1706
1706
|
|
|
@@ -1709,10 +1709,18 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1709
1709
|
:param kind: Kind of schedule objects to retrieve, can be either ``job`` or ``pipeline``.
|
|
1710
1710
|
:param include_last_run: Whether to return for each schedule returned also the results of the last run of
|
|
1711
1711
|
that schedule.
|
|
1712
|
+
:param next_run_time_since: Return only schedules with next run time after this date.
|
|
1713
|
+
:param next_run_time_until: Return only schedules with next run time before this date.
|
|
1712
1714
|
"""
|
|
1713
1715
|
|
|
1714
1716
|
project = project or config.default_project
|
|
1715
|
-
params = {
|
|
1717
|
+
params = {
|
|
1718
|
+
"kind": kind,
|
|
1719
|
+
"name": name,
|
|
1720
|
+
"include_last_run": include_last_run,
|
|
1721
|
+
"next_run_time_since": datetime_to_iso(next_run_time_since),
|
|
1722
|
+
"next_run_time_until": datetime_to_iso(next_run_time_until),
|
|
1723
|
+
}
|
|
1716
1724
|
path = f"projects/{project}/schedules"
|
|
1717
1725
|
error_message = f"Failed listing schedules for {project} ? {kind} {name}"
|
|
1718
1726
|
resp = self.api_call("GET", path, error_message, params=params)
|
|
@@ -2260,6 +2268,75 @@ class HTTPRunDB(RunDBInterface):
|
|
|
2260
2268
|
|
|
2261
2269
|
return resp.json()
|
|
2262
2270
|
|
|
2271
|
+
def retry_pipeline(
|
|
2272
|
+
self,
|
|
2273
|
+
run_id: str,
|
|
2274
|
+
namespace: Optional[str] = None,
|
|
2275
|
+
timeout: int = 30,
|
|
2276
|
+
project: Optional[str] = None,
|
|
2277
|
+
):
|
|
2278
|
+
"""
|
|
2279
|
+
Retry a specific pipeline run using its run ID. This function sends an API request
|
|
2280
|
+
to retry a pipeline run. If a project is specified, the run must belong to that
|
|
2281
|
+
project; otherwise, all projects are queried.
|
|
2282
|
+
|
|
2283
|
+
:param run_id: The unique ID of the pipeline run to retry.
|
|
2284
|
+
:param namespace: Kubernetes namespace where the pipeline is running. Optional.
|
|
2285
|
+
:param timeout: Timeout (in seconds) for the API call. Defaults to 30 seconds.
|
|
2286
|
+
:param project: Name of the MLRun project associated with the pipeline. Can be
|
|
2287
|
+
``*`` to query across all projects. Optional.
|
|
2288
|
+
|
|
2289
|
+
:raises ValueError: Raised if the API response is not successful or contains an
|
|
2290
|
+
error.
|
|
2291
|
+
|
|
2292
|
+
:return: JSON response containing details of the retried pipeline run.
|
|
2293
|
+
"""
|
|
2294
|
+
|
|
2295
|
+
params = {}
|
|
2296
|
+
if namespace:
|
|
2297
|
+
params["namespace"] = namespace
|
|
2298
|
+
project_path = project if project else "*"
|
|
2299
|
+
|
|
2300
|
+
resp_text = ""
|
|
2301
|
+
resp_code = None
|
|
2302
|
+
try:
|
|
2303
|
+
resp = self.api_call(
|
|
2304
|
+
"POST",
|
|
2305
|
+
f"projects/{project_path}/pipelines/{run_id}/retry",
|
|
2306
|
+
params=params,
|
|
2307
|
+
timeout=timeout,
|
|
2308
|
+
)
|
|
2309
|
+
resp_code = resp.status_code
|
|
2310
|
+
resp_text = resp.text
|
|
2311
|
+
if not resp.ok:
|
|
2312
|
+
raise mlrun.errors.MLRunHTTPError(
|
|
2313
|
+
f"Failed to retry pipeline run '{run_id}'. "
|
|
2314
|
+
f"HTTP {resp_code}: {resp_text}"
|
|
2315
|
+
)
|
|
2316
|
+
except Exception as exc:
|
|
2317
|
+
logger.error(
|
|
2318
|
+
"Retry pipeline API call encountered an error.",
|
|
2319
|
+
run_id=run_id,
|
|
2320
|
+
project=project_path,
|
|
2321
|
+
namespace=namespace,
|
|
2322
|
+
response_code=resp_code,
|
|
2323
|
+
response_text=resp_text,
|
|
2324
|
+
error=str(exc),
|
|
2325
|
+
)
|
|
2326
|
+
if isinstance(exc, mlrun.errors.MLRunHTTPError):
|
|
2327
|
+
raise exc # Re-raise known HTTP errors
|
|
2328
|
+
raise mlrun.errors.MLRunRuntimeError(
|
|
2329
|
+
f"Unexpected error while retrying pipeline run '{run_id}'."
|
|
2330
|
+
) from exc
|
|
2331
|
+
|
|
2332
|
+
logger.info(
|
|
2333
|
+
"Successfully retried pipeline run",
|
|
2334
|
+
run_id=run_id,
|
|
2335
|
+
project=project_path,
|
|
2336
|
+
namespace=namespace,
|
|
2337
|
+
)
|
|
2338
|
+
return resp.json()
|
|
2339
|
+
|
|
2263
2340
|
@staticmethod
|
|
2264
2341
|
def _resolve_reference(tag, uid):
|
|
2265
2342
|
if uid and tag:
|
|
@@ -3048,7 +3125,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
3048
3125
|
for project_dict in response.json()["projects"]
|
|
3049
3126
|
]
|
|
3050
3127
|
|
|
3051
|
-
def get_project(self, name: str) -> mlrun.
|
|
3128
|
+
def get_project(self, name: str) -> "mlrun.MlrunProject":
|
|
3052
3129
|
"""Get details for a specific project."""
|
|
3053
3130
|
|
|
3054
3131
|
if not name:
|
|
@@ -3057,7 +3134,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
3057
3134
|
path = f"projects/{name}"
|
|
3058
3135
|
error_message = f"Failed retrieving project {name}"
|
|
3059
3136
|
response = self.api_call("GET", path, error_message)
|
|
3060
|
-
return mlrun.
|
|
3137
|
+
return mlrun.MlrunProject.from_dict(response.json())
|
|
3061
3138
|
|
|
3062
3139
|
def delete_project(
|
|
3063
3140
|
self,
|
|
@@ -3504,217 +3581,205 @@ class HTTPRunDB(RunDBInterface):
|
|
|
3504
3581
|
|
|
3505
3582
|
def create_model_endpoint(
|
|
3506
3583
|
self,
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
model_endpoint: Union[
|
|
3510
|
-
mlrun.model_monitoring.model_endpoint.ModelEndpoint, dict
|
|
3511
|
-
],
|
|
3512
|
-
):
|
|
3584
|
+
model_endpoint: mlrun.common.schemas.ModelEndpoint,
|
|
3585
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
3513
3586
|
"""
|
|
3514
3587
|
Creates a DB record with the given model_endpoint record.
|
|
3515
3588
|
|
|
3516
|
-
:param project: The name of the project.
|
|
3517
|
-
:param endpoint_id: The id of the endpoint.
|
|
3518
3589
|
:param model_endpoint: An object representing the model endpoint.
|
|
3519
|
-
"""
|
|
3520
3590
|
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
):
|
|
3524
|
-
model_endpoint = model_endpoint.to_dict()
|
|
3591
|
+
:return: The created model endpoint object.
|
|
3592
|
+
"""
|
|
3525
3593
|
|
|
3526
|
-
path = f"projects/{project}/model-endpoints
|
|
3527
|
-
self.api_call(
|
|
3528
|
-
method=
|
|
3594
|
+
path = f"projects/{model_endpoint.metadata.project}/model-endpoints"
|
|
3595
|
+
response = self.api_call(
|
|
3596
|
+
method=mlrun.common.types.HTTPMethod.POST,
|
|
3529
3597
|
path=path,
|
|
3530
|
-
body=
|
|
3598
|
+
body=model_endpoint.json(),
|
|
3531
3599
|
)
|
|
3600
|
+
return mlrun.common.schemas.ModelEndpoint(**response.json())
|
|
3532
3601
|
|
|
3533
3602
|
def delete_model_endpoint(
|
|
3534
3603
|
self,
|
|
3604
|
+
name: str,
|
|
3535
3605
|
project: str,
|
|
3536
|
-
|
|
3606
|
+
function_name: Optional[str] = None,
|
|
3607
|
+
function_tag: Optional[str] = None,
|
|
3608
|
+
endpoint_id: Optional[str] = None,
|
|
3537
3609
|
):
|
|
3538
3610
|
"""
|
|
3539
3611
|
Deletes the DB record of a given model endpoint, project and endpoint_id are used for lookup
|
|
3540
3612
|
|
|
3613
|
+
:param name: The name of the model endpoint
|
|
3541
3614
|
:param project: The name of the project
|
|
3615
|
+
:param function_name: The name of the function
|
|
3616
|
+
:param function_tag: The tag of the function
|
|
3542
3617
|
:param endpoint_id: The id of the endpoint
|
|
3543
3618
|
"""
|
|
3544
|
-
|
|
3545
|
-
|
|
3619
|
+
self._check_model_endpoint_representation(
|
|
3620
|
+
function_name, function_tag, endpoint_id
|
|
3621
|
+
)
|
|
3622
|
+
path = f"projects/{project}/model-endpoints/{name}"
|
|
3546
3623
|
self.api_call(
|
|
3547
|
-
method=
|
|
3624
|
+
method=mlrun.common.types.HTTPMethod.DELETE,
|
|
3548
3625
|
path=path,
|
|
3626
|
+
params={
|
|
3627
|
+
"function_name": function_name,
|
|
3628
|
+
"function_tag": function_tag,
|
|
3629
|
+
"endpoint_id": endpoint_id,
|
|
3630
|
+
},
|
|
3549
3631
|
)
|
|
3550
3632
|
|
|
3551
3633
|
def list_model_endpoints(
|
|
3552
3634
|
self,
|
|
3553
3635
|
project: str,
|
|
3554
|
-
|
|
3555
|
-
|
|
3636
|
+
name: Optional[str] = None,
|
|
3637
|
+
function_name: Optional[str] = None,
|
|
3638
|
+
function_tag: Optional[str] = None,
|
|
3639
|
+
model_name: Optional[str] = None,
|
|
3556
3640
|
labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
|
|
3557
|
-
start:
|
|
3558
|
-
end:
|
|
3559
|
-
|
|
3641
|
+
start: Optional[datetime] = None,
|
|
3642
|
+
end: Optional[datetime] = None,
|
|
3643
|
+
tsdb_metrics: bool = True,
|
|
3560
3644
|
top_level: bool = False,
|
|
3561
3645
|
uids: Optional[list[str]] = None,
|
|
3562
|
-
|
|
3646
|
+
latest_only: bool = False,
|
|
3647
|
+
) -> mlrun.common.schemas.ModelEndpointList:
|
|
3648
|
+
"""
|
|
3649
|
+
List model endpoints with optional filtering by name, function name, model name, labels, and time range.
|
|
3650
|
+
|
|
3651
|
+
:param project: The name of the project
|
|
3652
|
+
:param name: The name of the model endpoint
|
|
3653
|
+
:param function_name: The name of the function
|
|
3654
|
+
:param function_tag: The tag of the function
|
|
3655
|
+
:param model_name: The name of the model
|
|
3656
|
+
:param labels: A list of labels to filter by. (see mlrun.common.schemas.LabelsModel)
|
|
3657
|
+
:param start: The start time to filter by.Corresponding to the `created` field.
|
|
3658
|
+
:param end: The end time to filter by. Corresponding to the `created` field.
|
|
3659
|
+
:param tsdb_metrics: Whether to include metrics from the time series DB.
|
|
3660
|
+
:param top_level: Whether to return only top level model endpoints.
|
|
3661
|
+
:param uids: A list of unique ids to filter by.
|
|
3662
|
+
:param latest_only: Whether to return only the latest model endpoint version.
|
|
3663
|
+
:return: A list of model endpoints.
|
|
3563
3664
|
"""
|
|
3564
|
-
Returns a list of `ModelEndpoint` objects. Each `ModelEndpoint` object represents the current state of a
|
|
3565
|
-
model endpoint. This functions supports filtering by the following parameters:
|
|
3566
|
-
1) model
|
|
3567
|
-
2) function
|
|
3568
|
-
3) labels
|
|
3569
|
-
4) top level
|
|
3570
|
-
5) uids
|
|
3571
|
-
By default, when no filters are applied, all available endpoints for the given project will be listed.
|
|
3572
|
-
|
|
3573
|
-
In addition, this functions provides a facade for listing endpoint related metrics. This facade is time-based
|
|
3574
|
-
and depends on the 'start' and 'end' parameters. By default, when the metrics parameter is None, no metrics are
|
|
3575
|
-
added to the output of this function.
|
|
3576
|
-
|
|
3577
|
-
:param project: The name of the project
|
|
3578
|
-
:param model: The name of the model to filter by
|
|
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.
|
|
3598
|
-
"""
|
|
3599
|
-
|
|
3600
3665
|
path = f"projects/{project}/model-endpoints"
|
|
3601
3666
|
labels = self._parse_labels(labels)
|
|
3602
3667
|
|
|
3603
3668
|
response = self.api_call(
|
|
3604
|
-
method=
|
|
3669
|
+
method=mlrun.common.types.HTTPMethod.GET,
|
|
3605
3670
|
path=path,
|
|
3606
3671
|
params={
|
|
3607
|
-
"
|
|
3608
|
-
"
|
|
3672
|
+
"name": name,
|
|
3673
|
+
"model_name": model_name,
|
|
3674
|
+
"function_name": function_name,
|
|
3675
|
+
"function_tag": function_tag,
|
|
3609
3676
|
"label": labels,
|
|
3610
|
-
"start": start,
|
|
3611
|
-
"end": end,
|
|
3612
|
-
"
|
|
3677
|
+
"start": datetime_to_iso(start),
|
|
3678
|
+
"end": datetime_to_iso(end),
|
|
3679
|
+
"tsdb_metrics": tsdb_metrics,
|
|
3613
3680
|
"top-level": top_level,
|
|
3614
3681
|
"uid": uids,
|
|
3682
|
+
"latest_only": latest_only,
|
|
3615
3683
|
},
|
|
3616
3684
|
)
|
|
3617
3685
|
|
|
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 []
|
|
3686
|
+
return mlrun.common.schemas.ModelEndpointList(**response.json())
|
|
3626
3687
|
|
|
3627
3688
|
def get_model_endpoint(
|
|
3628
3689
|
self,
|
|
3690
|
+
name: str,
|
|
3629
3691
|
project: str,
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3692
|
+
function_name: Optional[str] = None,
|
|
3693
|
+
function_tag: Optional[str] = None,
|
|
3694
|
+
endpoint_id: Optional[str] = None,
|
|
3695
|
+
tsdb_metrics: bool = True,
|
|
3634
3696
|
feature_analysis: bool = False,
|
|
3635
|
-
) -> mlrun.
|
|
3697
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
3636
3698
|
"""
|
|
3637
3699
|
Returns a single `ModelEndpoint` object with additional metrics and feature related data.
|
|
3638
3700
|
|
|
3701
|
+
:param name: The name of the model endpoint
|
|
3639
3702
|
:param project: The name of the project
|
|
3640
|
-
:param
|
|
3641
|
-
:param
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
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}"
|
|
3703
|
+
:param function_name: The name of the function
|
|
3704
|
+
:param function_tag: The tag of the function
|
|
3705
|
+
:param endpoint_id: The id of the endpoint
|
|
3706
|
+
:param tsdb_metrics: Whether to include metrics from the time series DB.
|
|
3707
|
+
:param feature_analysis: Whether to include feature analysis data (feature_stats,
|
|
3708
|
+
current_stats & drift_measures).
|
|
3709
|
+
|
|
3710
|
+
:return: A `ModelEndpoint` object.
|
|
3711
|
+
"""
|
|
3712
|
+
self._check_model_endpoint_representation(
|
|
3713
|
+
function_name, function_tag, endpoint_id
|
|
3714
|
+
)
|
|
3715
|
+
path = f"projects/{project}/model-endpoints/{name}"
|
|
3661
3716
|
response = self.api_call(
|
|
3662
|
-
method=
|
|
3717
|
+
method=mlrun.common.types.HTTPMethod.GET,
|
|
3663
3718
|
path=path,
|
|
3664
3719
|
params={
|
|
3665
|
-
"
|
|
3666
|
-
"
|
|
3667
|
-
"
|
|
3720
|
+
"function_name": function_name,
|
|
3721
|
+
"function_tag": function_tag,
|
|
3722
|
+
"endpoint_id": endpoint_id,
|
|
3723
|
+
"tsdb_metrics": tsdb_metrics,
|
|
3668
3724
|
"feature_analysis": feature_analysis,
|
|
3669
3725
|
},
|
|
3670
3726
|
)
|
|
3671
3727
|
|
|
3672
|
-
return mlrun.
|
|
3673
|
-
response.json()
|
|
3674
|
-
)
|
|
3728
|
+
return mlrun.common.schemas.ModelEndpoint(**response.json())
|
|
3675
3729
|
|
|
3676
3730
|
def patch_model_endpoint(
|
|
3677
3731
|
self,
|
|
3732
|
+
name: str,
|
|
3678
3733
|
project: str,
|
|
3679
|
-
endpoint_id: str,
|
|
3680
3734
|
attributes: dict,
|
|
3681
|
-
|
|
3735
|
+
function_name: Optional[str] = None,
|
|
3736
|
+
function_tag: Optional[str] = None,
|
|
3737
|
+
endpoint_id: Optional[str] = None,
|
|
3738
|
+
) -> mlrun.common.schemas.ModelEndpoint:
|
|
3682
3739
|
"""
|
|
3683
|
-
Updates model endpoint with
|
|
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"}
|
|
3740
|
+
Updates a model endpoint with the given attributes.
|
|
3707
3741
|
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3742
|
+
:param name: The name of the model endpoint
|
|
3743
|
+
:param project: The name of the project
|
|
3744
|
+
:param attributes: The attributes to update
|
|
3745
|
+
:param function_name: The name of the function
|
|
3746
|
+
:param function_tag: The tag of the function
|
|
3747
|
+
:param endpoint_id: The id of the endpoint
|
|
3748
|
+
:return: The updated `ModelEndpoint` object.
|
|
3749
|
+
"""
|
|
3750
|
+
attributes_keys = list(attributes.keys())
|
|
3751
|
+
attributes["name"] = name
|
|
3752
|
+
attributes["project"] = project
|
|
3753
|
+
attributes["function_name"] = function_name or None
|
|
3754
|
+
attributes["function_tag"] = function_tag or None
|
|
3755
|
+
attributes["uid"] = endpoint_id or None
|
|
3756
|
+
model_endpoint = mlrun.common.schemas.ModelEndpoint.from_flat_dict(attributes)
|
|
3757
|
+
path = f"projects/{project}/model-endpoints"
|
|
3758
|
+
logger.info(
|
|
3759
|
+
"Patching model endpoint",
|
|
3760
|
+
attributes_keys=attributes_keys,
|
|
3761
|
+
model_endpoint=model_endpoint,
|
|
3762
|
+
)
|
|
3763
|
+
response = self.api_call(
|
|
3764
|
+
method=mlrun.common.types.HTTPMethod.PATCH,
|
|
3714
3765
|
path=path,
|
|
3715
|
-
params=
|
|
3766
|
+
params={
|
|
3767
|
+
"attribute-key": attributes_keys,
|
|
3768
|
+
},
|
|
3769
|
+
body=model_endpoint.json(),
|
|
3716
3770
|
)
|
|
3717
3771
|
|
|
3772
|
+
return mlrun.common.schemas.ModelEndpoint(**response.json())
|
|
3773
|
+
|
|
3774
|
+
@staticmethod
|
|
3775
|
+
def _check_model_endpoint_representation(
|
|
3776
|
+
function_name: str, function_tag: str, uid: str
|
|
3777
|
+
):
|
|
3778
|
+
if not uid and not (function_name and function_tag):
|
|
3779
|
+
raise MLRunInvalidArgumentError(
|
|
3780
|
+
"Either endpoint_uid or function_name and function_tag must be provided"
|
|
3781
|
+
)
|
|
3782
|
+
|
|
3718
3783
|
def update_model_monitoring_controller(
|
|
3719
3784
|
self,
|
|
3720
3785
|
project: str,
|
|
@@ -4707,7 +4772,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
4707
4772
|
Union[mlrun.common.schemas.alert.EventEntityKind, str]
|
|
4708
4773
|
] = None,
|
|
4709
4774
|
event_kind: Optional[Union[mlrun.common.schemas.alert.EventKind, str]] = None,
|
|
4710
|
-
) ->
|
|
4775
|
+
) -> mlrun.common.schemas.AlertActivations:
|
|
4711
4776
|
"""
|
|
4712
4777
|
Retrieve a list of all alert activations.
|
|
4713
4778
|
|
|
@@ -4743,7 +4808,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
4743
4808
|
page_size: Optional[int] = None,
|
|
4744
4809
|
page_token: Optional[str] = None,
|
|
4745
4810
|
**kwargs,
|
|
4746
|
-
) -> tuple[
|
|
4811
|
+
) -> tuple[AlertActivations, Optional[str]]:
|
|
4747
4812
|
"""List alerts activations with support for pagination and various filtering options.
|
|
4748
4813
|
|
|
4749
4814
|
This method retrieves a paginated list of alert activations based on the specified filter parameters.
|
|
@@ -4799,6 +4864,22 @@ class HTTPRunDB(RunDBInterface):
|
|
|
4799
4864
|
**kwargs,
|
|
4800
4865
|
)
|
|
4801
4866
|
|
|
4867
|
+
def get_project_summary(
|
|
4868
|
+
self, project: Optional[str] = None
|
|
4869
|
+
) -> mlrun.common.schemas.ProjectSummary:
|
|
4870
|
+
"""
|
|
4871
|
+
Retrieve the summary of a project.
|
|
4872
|
+
|
|
4873
|
+
:param project: Project name for which the summary belongs.
|
|
4874
|
+
:returns: A summary of the project.
|
|
4875
|
+
"""
|
|
4876
|
+
project = project or config.default_project
|
|
4877
|
+
|
|
4878
|
+
endpoint_path = f"project-summaries/{project}"
|
|
4879
|
+
error_message = f"Failed retrieving project summary for {project}"
|
|
4880
|
+
response = self.api_call("GET", endpoint_path, error_message)
|
|
4881
|
+
return mlrun.common.schemas.ProjectSummary(**response.json())
|
|
4882
|
+
|
|
4802
4883
|
@staticmethod
|
|
4803
4884
|
def _parse_labels(
|
|
4804
4885
|
labels: Optional[Union[str, dict[str, Optional[str]], list[str]]],
|
|
@@ -5031,9 +5112,11 @@ class HTTPRunDB(RunDBInterface):
|
|
|
5031
5112
|
"name": name,
|
|
5032
5113
|
"uid": uid,
|
|
5033
5114
|
"label": labels,
|
|
5034
|
-
"state":
|
|
5035
|
-
|
|
5036
|
-
|
|
5115
|
+
"state": (
|
|
5116
|
+
mlrun.utils.helpers.as_list(state)
|
|
5117
|
+
if state is not None
|
|
5118
|
+
else states or None
|
|
5119
|
+
),
|
|
5037
5120
|
"sort": bool2str(sort),
|
|
5038
5121
|
"iter": bool2str(iter),
|
|
5039
5122
|
"start_time_from": datetime_to_iso(start_time_from),
|
|
@@ -5088,7 +5171,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
5088
5171
|
page_size: Optional[int] = None,
|
|
5089
5172
|
page_token: Optional[str] = None,
|
|
5090
5173
|
return_all: bool = False,
|
|
5091
|
-
) -> tuple[
|
|
5174
|
+
) -> tuple[mlrun.common.schemas.AlertActivations, Optional[str]]:
|
|
5092
5175
|
project = project or config.default_project
|
|
5093
5176
|
params = {
|
|
5094
5177
|
"name": name,
|
|
@@ -5112,9 +5195,12 @@ class HTTPRunDB(RunDBInterface):
|
|
|
5112
5195
|
paginated_responses, token = self.process_paginated_responses(
|
|
5113
5196
|
responses, "activations"
|
|
5114
5197
|
)
|
|
5115
|
-
paginated_results =
|
|
5116
|
-
|
|
5117
|
-
|
|
5198
|
+
paginated_results = mlrun.common.schemas.AlertActivations(
|
|
5199
|
+
activations=[
|
|
5200
|
+
mlrun.common.schemas.AlertActivation(**item)
|
|
5201
|
+
for item in paginated_responses
|
|
5202
|
+
]
|
|
5203
|
+
)
|
|
5118
5204
|
|
|
5119
5205
|
return paginated_results, token
|
|
5120
5206
|
|