mlrun 1.8.0rc5__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.

Files changed (60) hide show
  1. mlrun/artifacts/__init__.py +1 -1
  2. mlrun/artifacts/base.py +12 -1
  3. mlrun/artifacts/document.py +59 -38
  4. mlrun/common/model_monitoring/__init__.py +0 -2
  5. mlrun/common/model_monitoring/helpers.py +0 -28
  6. mlrun/common/schemas/__init__.py +1 -4
  7. mlrun/common/schemas/client_spec.py +0 -1
  8. mlrun/common/schemas/model_monitoring/__init__.py +0 -6
  9. mlrun/common/schemas/model_monitoring/constants.py +11 -9
  10. mlrun/common/schemas/model_monitoring/model_endpoints.py +77 -149
  11. mlrun/common/schemas/notification.py +6 -0
  12. mlrun/config.py +0 -2
  13. mlrun/datastore/datastore_profile.py +57 -17
  14. mlrun/datastore/vectorstore.py +67 -59
  15. mlrun/db/base.py +22 -18
  16. mlrun/db/httpdb.py +116 -148
  17. mlrun/db/nopdb.py +33 -17
  18. mlrun/execution.py +11 -4
  19. mlrun/model.py +3 -0
  20. mlrun/model_monitoring/__init__.py +3 -2
  21. mlrun/model_monitoring/api.py +40 -43
  22. mlrun/model_monitoring/applications/_application_steps.py +3 -1
  23. mlrun/model_monitoring/applications/context.py +15 -17
  24. mlrun/model_monitoring/controller.py +43 -37
  25. mlrun/model_monitoring/db/__init__.py +0 -2
  26. mlrun/model_monitoring/db/tsdb/base.py +2 -1
  27. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +2 -1
  28. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +43 -0
  29. mlrun/model_monitoring/helpers.py +12 -66
  30. mlrun/model_monitoring/stream_processing.py +83 -270
  31. mlrun/model_monitoring/writer.py +1 -10
  32. mlrun/projects/project.py +63 -55
  33. mlrun/runtimes/nuclio/function.py +7 -6
  34. mlrun/runtimes/nuclio/serving.py +7 -1
  35. mlrun/serving/routers.py +158 -145
  36. mlrun/serving/server.py +6 -0
  37. mlrun/serving/states.py +2 -0
  38. mlrun/serving/v2_serving.py +69 -60
  39. mlrun/utils/helpers.py +14 -30
  40. mlrun/utils/notifications/notification/mail.py +17 -6
  41. mlrun/utils/version/version.json +2 -2
  42. {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc6.dist-info}/METADATA +1 -1
  43. {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc6.dist-info}/RECORD +47 -60
  44. mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +0 -149
  45. mlrun/model_monitoring/db/stores/__init__.py +0 -136
  46. mlrun/model_monitoring/db/stores/base/__init__.py +0 -15
  47. mlrun/model_monitoring/db/stores/base/store.py +0 -154
  48. mlrun/model_monitoring/db/stores/sqldb/__init__.py +0 -13
  49. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -46
  50. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -93
  51. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -47
  52. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -25
  53. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -408
  54. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +0 -13
  55. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -464
  56. mlrun/model_monitoring/model_endpoint.py +0 -120
  57. {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc6.dist-info}/LICENSE +0 -0
  58. {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc6.dist-info}/WHEEL +0 -0
  59. {mlrun-1.8.0rc5.dist-info → mlrun-1.8.0rc6.dist-info}/entry_points.txt +0 -0
  60. {mlrun-1.8.0rc5.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
- project: str,
667
- endpoint_id: str,
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
- model: Optional[str] = None,
685
- function: Optional[str] = None,
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: str = "now-1h",
688
- end: str = "now",
689
- metrics: Optional[list[str]] = None,
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
- ) -> list[mlrun.model_monitoring.model_endpoint.ModelEndpoint]:
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
- endpoint_id: str,
700
- start: Optional[str] = None,
701
- end: Optional[str] = None,
702
- metrics: Optional[list[str]] = None,
703
- features: bool = False,
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/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 = {"kind": kind, "name": name, "include_last_run": include_last_run}
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
- project: str,
3508
- endpoint_id: str,
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
- if isinstance(
3522
- model_endpoint, mlrun.model_monitoring.model_endpoint.ModelEndpoint
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/{endpoint_id}"
3527
- self.api_call(
3528
- method="POST",
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=dict_to_json(model_endpoint),
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/{endpoint_id}"
3546
+ path = f"projects/{project}/model-endpoints/{name}"
3546
3547
  self.api_call(
3547
- method="DELETE",
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
- model: Optional[str] = None,
3555
- function: Optional[str] = None,
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: str = "now-1h",
3558
- end: str = "now",
3559
- metrics: Optional[list[str]] = None,
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
- ) -> list[mlrun.model_monitoring.model_endpoint.ModelEndpoint]:
3563
- """
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.
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="GET",
3590
+ method=mlrun.common.types.HTTPMethod.GET,
3605
3591
  path=path,
3606
3592
  params={
3607
- "model": model,
3608
- "function": function,
3593
+ "name": name,
3594
+ "model_name": model_name,
3595
+ "function_name": function_name,
3609
3596
  "label": labels,
3610
- "start": start,
3611
- "end": end,
3612
- "metric": metrics or [],
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
- # Generate a list of a model endpoint dictionaries
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
- endpoint_id: str,
3631
- start: Optional[str] = None,
3632
- end: Optional[str] = None,
3633
- metrics: Optional[list[str]] = None,
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.model_monitoring.model_endpoint.ModelEndpoint:
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 endpoint_id: The unique id of the model endpoint.
3641
- :param start: The start time of the metrics. Can be represented by a string containing an
3642
- RFC 3339 time, a Unix timestamp in milliseconds, a relative time
3643
- (`'now'` or `'now-[0-9]+[mhd]'`, where `m` = minutes, `h` = hours,
3644
- `'d'` = days, and `'s'` = seconds), or 0 for the earliest time.
3645
- :param end: The end time of the metrics. Can be represented by a string containing an
3646
- RFC 3339 time, a Unix timestamp in milliseconds, a relative time
3647
- (`'now'` or `'now-[0-9]+[mhd]'`, where `m` = minutes, `h` = hours,
3648
- `'d'` = days, and `'s'` = seconds), or 0 for the earliest time.
3649
- :param metrics: A list of metrics to return for the model endpoint. There are pre-defined
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="GET",
3634
+ method=mlrun.common.types.HTTPMethod.GET,
3663
3635
  path=path,
3664
3636
  params={
3665
- "start": start,
3666
- "end": end,
3667
- "metric": metrics or [],
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.model_monitoring.model_endpoint.ModelEndpoint.from_dict(
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
- ):
3651
+ function_name: Optional[str] = None,
3652
+ endpoint_id: Optional[str] = None,
3653
+ ) -> mlrun.common.schemas.ModelEndpoint:
3682
3654
  """
3683
- Updates model endpoint with provided attributes.
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`.
3655
+ Updates a model endpoint with the given attributes.
3691
3656
 
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
-
3708
- """
3709
-
3710
- attributes = {"attributes": _as_json(attributes)}
3711
- path = f"projects/{project}/model-endpoints/{endpoint_id}"
3712
- self.api_call(
3713
- method="PATCH",
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=attributes,
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,
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(self, project: str, endpoint_id: str):
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
- model: Optional[str] = None,
589
- function: Optional[str] = None,
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: str = "now-1h",
592
- end: str = "now",
593
- metrics: Optional[list[str]] = None,
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
- endpoint_id: str,
601
- start: Optional[str] = None,
602
- end: Optional[str] = None,
603
- metrics: Optional[list[str]] = None,
604
- features: bool = False,
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(self, project: str, endpoint_id: str, attributes: dict):
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(
mlrun/execution.py CHANGED
@@ -877,28 +877,35 @@ class MLClientCtx:
877
877
  def log_document(
878
878
  self,
879
879
  key: str,
880
+ tag: str = "",
881
+ local_path: str = "",
880
882
  artifact_path: Optional[str] = None,
881
883
  document_loader: DocumentLoaderSpec = DocumentLoaderSpec(),
882
- tag: str = "",
883
884
  upload: Optional[bool] = False,
884
885
  labels: Optional[dict[str, str]] = None,
886
+ target_path: Optional[str] = None,
885
887
  **kwargs,
886
888
  ) -> DocumentArtifact:
887
889
  """
888
890
  Log a document as an artifact.
889
891
 
890
892
  :param key: Artifact key
891
- :param target_path: Path to the local file
892
- :param artifact_path: Target path for artifact storage
893
- :param document_loader: Spec to use to load the artifact as langchain document
894
893
  :param tag: Version tag
894
+ :param local_path: path to the local file we upload, will also be use
895
+ as the destination subpath (under "artifact_path")
896
+ :param artifact_path: Target artifact path (when not using the default)
897
+ to define a subpath under the default location use:
898
+ `artifact_path=context.artifact_subpath('data')`
899
+ :param document_loader: Spec to use to load the artifact as langchain document
895
900
  :param upload: Whether to upload the artifact
896
901
  :param labels: Key-value labels
902
+ :param target_path: Path to the local file
897
903
  :param kwargs: Additional keyword arguments
898
904
  :return: DocumentArtifact object
899
905
  """
900
906
  doc_artifact = DocumentArtifact(
901
907
  key=key,
908
+ original_source=local_path or target_path,
902
909
  document_loader=document_loader,
903
910
  **kwargs,
904
911
  )
mlrun/model.py CHANGED
@@ -445,6 +445,7 @@ class Credentials(ModelObj):
445
445
  class BaseMetadata(ModelObj):
446
446
  _default_fields_to_strip = ModelObj._default_fields_to_strip + [
447
447
  "hash",
448
+ "uid",
448
449
  # Below are environment specific fields, no need to keep when stripping
449
450
  "namespace",
450
451
  "project",
@@ -467,10 +468,12 @@ class BaseMetadata(ModelObj):
467
468
  categories=None,
468
469
  updated=None,
469
470
  credentials=None,
471
+ uid=None,
470
472
  ):
471
473
  self.name = name
472
474
  self.tag = tag
473
475
  self.hash = hash
476
+ self.uid = uid
474
477
  self.namespace = namespace
475
478
  self.project = project or ""
476
479
  self.labels = labels or {}
@@ -14,7 +14,8 @@
14
14
 
15
15
  # for backwards compatibility
16
16
 
17
- from .db import get_store_object, get_tsdb_connector
17
+ from mlrun.common.schemas import ModelEndpoint, ModelEndpointList
18
+
19
+ from .db import get_tsdb_connector
18
20
  from .helpers import get_stream_path
19
- from .model_endpoint import ModelEndpoint
20
21
  from .tracking_policy import TrackingPolicy