mlrun 1.8.0rc57__py3-none-any.whl → 1.8.0rc59__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 (39) hide show
  1. mlrun/artifacts/base.py +7 -7
  2. mlrun/artifacts/dataset.py +2 -2
  3. mlrun/artifacts/model.py +2 -2
  4. mlrun/artifacts/plots.py +4 -4
  5. mlrun/common/runtimes/constants.py +1 -1
  6. mlrun/common/schemas/artifact.py +1 -1
  7. mlrun/common/schemas/pipeline.py +1 -1
  8. mlrun/common/schemas/project.py +1 -1
  9. mlrun/common/schemas/runs.py +1 -1
  10. mlrun/datastore/datastore_profile.py +2 -2
  11. mlrun/datastore/sources.py +3 -3
  12. mlrun/datastore/targets.py +4 -4
  13. mlrun/datastore/utils.py +2 -2
  14. mlrun/db/base.py +7 -7
  15. mlrun/db/httpdb.py +14 -12
  16. mlrun/db/nopdb.py +1 -1
  17. mlrun/execution.py +1 -1
  18. mlrun/frameworks/_common/model_handler.py +2 -2
  19. mlrun/model_monitoring/api.py +4 -4
  20. mlrun/model_monitoring/applications/evidently/base.py +59 -71
  21. mlrun/model_monitoring/controller.py +24 -13
  22. mlrun/model_monitoring/tracking_policy.py +1 -1
  23. mlrun/model_monitoring/writer.py +1 -1
  24. mlrun/projects/operations.py +3 -3
  25. mlrun/projects/project.py +20 -20
  26. mlrun/render.py +5 -9
  27. mlrun/run.py +1 -1
  28. mlrun/runtimes/base.py +4 -4
  29. mlrun/runtimes/kubejob.py +2 -2
  30. mlrun/runtimes/nuclio/function.py +2 -2
  31. mlrun/runtimes/nuclio/serving.py +4 -4
  32. mlrun/runtimes/utils.py +1 -1
  33. mlrun/utils/version/version.json +2 -2
  34. {mlrun-1.8.0rc57.dist-info → mlrun-1.8.0rc59.dist-info}/METADATA +6 -6
  35. {mlrun-1.8.0rc57.dist-info → mlrun-1.8.0rc59.dist-info}/RECORD +39 -39
  36. {mlrun-1.8.0rc57.dist-info → mlrun-1.8.0rc59.dist-info}/WHEEL +1 -1
  37. {mlrun-1.8.0rc57.dist-info → mlrun-1.8.0rc59.dist-info}/entry_points.txt +0 -0
  38. {mlrun-1.8.0rc57.dist-info → mlrun-1.8.0rc59.dist-info}/licenses/LICENSE +0 -0
  39. {mlrun-1.8.0rc57.dist-info → mlrun-1.8.0rc59.dist-info}/top_level.txt +0 -0
mlrun/artifacts/base.py CHANGED
@@ -219,7 +219,7 @@ class Artifact(ModelObj):
219
219
  project=None,
220
220
  src_path: typing.Optional[str] = None,
221
221
  # All params up until here are legacy params for compatibility with legacy artifacts.
222
- # TODO: remove them in 1.9.0.
222
+ # TODO: remove them in 1.10.0.
223
223
  metadata: ArtifactMetadata = None,
224
224
  spec: ArtifactSpec = None,
225
225
  ):
@@ -235,9 +235,9 @@ class Artifact(ModelObj):
235
235
  or src_path
236
236
  ):
237
237
  warnings.warn(
238
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
238
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
239
239
  "Use the metadata and spec parameters instead.",
240
- DeprecationWarning,
240
+ FutureWarning,
241
241
  )
242
242
 
243
243
  self._metadata = None
@@ -758,15 +758,15 @@ class LinkArtifact(Artifact):
758
758
  link_tree=None,
759
759
  project=None,
760
760
  # All params up until here are legacy params for compatibility with legacy artifacts.
761
- # TODO: remove them in 1.9.0.
761
+ # TODO: remove them in 1.10.0.
762
762
  metadata: ArtifactMetadata = None,
763
763
  spec: LinkArtifactSpec = None,
764
764
  ):
765
765
  if key or target_path or link_iteration or link_key or link_tree or project:
766
766
  warnings.warn(
767
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
767
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
768
768
  "Use the metadata and spec parameters instead.",
769
- DeprecationWarning,
769
+ FutureWarning,
770
770
  )
771
771
  super().__init__(
772
772
  key, target_path=target_path, project=project, metadata=metadata, spec=spec
@@ -907,7 +907,7 @@ def convert_legacy_artifact_to_new_format(
907
907
  artifact_key = f"{artifact_key}:{artifact_tag}"
908
908
  # TODO: Remove once data migration v5 is obsolete
909
909
  warnings.warn(
910
- f"Converting legacy artifact '{artifact_key}' to new format. This will not be supported in MLRun 1.9.0. "
910
+ f"Converting legacy artifact '{artifact_key}' to new format. This will not be supported in MLRun 1.10.0. "
911
911
  f"Make sure to save the artifact/project in the new format.",
912
912
  FutureWarning,
913
913
  )
@@ -163,9 +163,9 @@ class DatasetArtifact(Artifact):
163
163
  ):
164
164
  if key or format or target_path:
165
165
  warnings.warn(
166
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
166
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
167
167
  "Use the metadata and spec parameters instead.",
168
- DeprecationWarning,
168
+ FutureWarning,
169
169
  )
170
170
 
171
171
  format = (format or "").lower()
mlrun/artifacts/model.py CHANGED
@@ -152,9 +152,9 @@ class ModelArtifact(Artifact):
152
152
  ):
153
153
  if key or body or format or target_path:
154
154
  warnings.warn(
155
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
155
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
156
156
  "Use the metadata and spec parameters instead.",
157
- DeprecationWarning,
157
+ FutureWarning,
158
158
  )
159
159
  super().__init__(key, body, format=format, target_path=target_path, **kwargs)
160
160
  model_file = str(model_file or "")
mlrun/artifacts/plots.py CHANGED
@@ -37,9 +37,9 @@ class PlotArtifact(Artifact):
37
37
  ):
38
38
  if key or body or is_inline or target_path:
39
39
  warnings.warn(
40
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
40
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
41
41
  "Use the metadata and spec parameters instead.",
42
- DeprecationWarning,
42
+ FutureWarning,
43
43
  )
44
44
  super().__init__(key, body, format="html", target_path=target_path)
45
45
  self.metadata.description = title
@@ -96,9 +96,9 @@ class PlotlyArtifact(Artifact):
96
96
  """
97
97
  if key or target_path:
98
98
  warnings.warn(
99
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
99
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
100
100
  "Use the metadata and spec parameters instead.",
101
- DeprecationWarning,
101
+ FutureWarning,
102
102
  )
103
103
  # Validate the plotly package:
104
104
  try:
@@ -237,7 +237,7 @@ class RunStates:
237
237
  }[pipeline_run_status]
238
238
 
239
239
 
240
- # TODO: remove this class in 1.9.0 - use only MlrunInternalLabels
240
+ # TODO: remove this class in 1.10.0 - use only MlrunInternalLabels
241
241
  class RunLabels(enum.Enum):
242
242
  owner = mlrun_constants.MLRunInternalLabels.owner
243
243
  v3io_user = mlrun_constants.MLRunInternalLabels.v3io_user
@@ -80,7 +80,7 @@ class ArtifactIdentifier(pydantic.v1.BaseModel):
80
80
 
81
81
  @deprecated(
82
82
  version="1.7.0",
83
- reason="mlrun.common.schemas.ArtifactsFormat is deprecated and will be removed in 1.9.0. "
83
+ reason="mlrun.common.schemas.ArtifactsFormat is deprecated and will be removed in 1.10.0. "
84
84
  "Use mlrun.common.formatters.ArtifactFormat instead.",
85
85
  category=FutureWarning,
86
86
  )
@@ -22,7 +22,7 @@ import mlrun.common.types
22
22
 
23
23
  @deprecated(
24
24
  version="1.7.0",
25
- reason="mlrun.common.schemas.PipelinesFormat is deprecated and will be removed in 1.9.0. "
25
+ reason="mlrun.common.schemas.PipelinesFormat is deprecated and will be removed in 1.10.0. "
26
26
  "Use mlrun.common.formatters.PipelineFormat instead.",
27
27
  category=FutureWarning,
28
28
  )
@@ -26,7 +26,7 @@ from .object import ObjectKind, ObjectStatus
26
26
 
27
27
  @deprecated(
28
28
  version="1.7.0",
29
- reason="mlrun.common.schemas.ProjectsFormat is deprecated and will be removed in 1.9.0. "
29
+ reason="mlrun.common.schemas.ProjectsFormat is deprecated and will be removed in 1.10.0. "
30
30
  "Use mlrun.common.formatters.ProjectFormat instead.",
31
31
  category=FutureWarning,
32
32
  )
@@ -28,7 +28,7 @@ class RunIdentifier(pydantic.v1.BaseModel):
28
28
 
29
29
  @deprecated(
30
30
  version="1.7.0",
31
- reason="mlrun.common.schemas.RunsFormat is deprecated and will be removed in 1.9.0. "
31
+ reason="mlrun.common.schemas.RunsFormat is deprecated and will be removed in 1.10.0. "
32
32
  "Use mlrun.common.formatters.RunFormat instead.",
33
33
  category=FutureWarning,
34
34
  )
@@ -165,9 +165,9 @@ class DatastoreProfileKafkaTarget(DatastoreProfile):
165
165
  self.brokers = self.bootstrap_servers
166
166
  self.bootstrap_servers = None
167
167
  warnings.warn(
168
- "'bootstrap_servers' parameter is deprecated in 1.7.0 and will be removed in 1.9.0, "
168
+ "'bootstrap_servers' parameter is deprecated in 1.7.0 and will be removed in 1.10.0, "
169
169
  "use 'brokers' instead.",
170
- # TODO: Remove this in 1.9.0
170
+ # TODO: Remove this in 1.10.0
171
171
  FutureWarning,
172
172
  )
173
173
 
@@ -794,12 +794,12 @@ class SnowflakeSource(BaseSourceDriver):
794
794
  warehouse: Optional[str] = None,
795
795
  **kwargs,
796
796
  ):
797
- # TODO: Remove in 1.9.0
797
+ # TODO: Remove in 1.10.0
798
798
  if schema:
799
799
  warnings.warn(
800
- "schema is deprecated in 1.7.0, and will be removed in 1.9.0, please use db_schema"
800
+ "schema is deprecated in 1.7.0, and will be removed in 1.10.0, please use db_schema"
801
801
  )
802
- db_schema = db_schema or schema # TODO: Remove in 1.9.0
802
+ db_schema = db_schema or schema # TODO: Remove in 1.10.0
803
803
 
804
804
  attributes = attributes or {}
805
805
  if url:
@@ -443,8 +443,8 @@ class BaseStoreTarget(DataTargetBase):
443
443
  self.credentials_prefix = credentials_prefix
444
444
  if credentials_prefix:
445
445
  warnings.warn(
446
- "The 'credentials_prefix' parameter is deprecated and will be removed in "
447
- "1.9.0. Please use datastore profiles instead.",
446
+ "The 'credentials_prefix' parameter is deprecated in 1.7.0 and will be removed in "
447
+ "1.10.0. Please use datastore profiles instead.",
448
448
  FutureWarning,
449
449
  )
450
450
 
@@ -1671,7 +1671,7 @@ class KafkaTarget(BaseStoreTarget):
1671
1671
  ):
1672
1672
  attrs = {}
1673
1673
 
1674
- # TODO: Remove this in 1.9.0
1674
+ # TODO: Remove this in 1.10.0
1675
1675
  if bootstrap_servers:
1676
1676
  if brokers:
1677
1677
  raise mlrun.errors.MLRunInvalidArgumentError(
@@ -1679,7 +1679,7 @@ class KafkaTarget(BaseStoreTarget):
1679
1679
  "'bootstrap_servers' parameter. Please use 'brokers' only."
1680
1680
  )
1681
1681
  warnings.warn(
1682
- "'bootstrap_servers' parameter is deprecated in 1.7.0 and will be removed in 1.9.0, "
1682
+ "'bootstrap_servers' parameter is deprecated in 1.7.0 and will be removed in 1.10.0, "
1683
1683
  "use 'brokers' instead.",
1684
1684
  FutureWarning,
1685
1685
  )
mlrun/datastore/utils.py CHANGED
@@ -176,8 +176,8 @@ def get_kafka_brokers_from_dict(options: dict, pop=False) -> typing.Optional[str
176
176
  kafka_bootstrap_servers = get_or_pop("kafka_bootstrap_servers", None)
177
177
  if kafka_bootstrap_servers:
178
178
  warnings.warn(
179
- "The 'kafka_bootstrap_servers' parameter is deprecated and will be removed in "
180
- "1.9.0. Please pass the 'kafka_brokers' parameter instead.",
179
+ "The 'kafka_bootstrap_servers' parameter is deprecated in 1.7.0 and will be removed in "
180
+ "1.10.0. Please pass the 'kafka_brokers' parameter instead.",
181
181
  FutureWarning,
182
182
  )
183
183
  return kafka_bootstrap_servers
mlrun/db/base.py CHANGED
@@ -441,10 +441,10 @@ class RunDBInterface(ABC):
441
441
  ) -> dict:
442
442
  pass
443
443
 
444
- # TODO: remove in 1.9.0
444
+ # TODO: remove in 1.10.0
445
445
  @deprecated(
446
- version="1.9.0",
447
- reason="'list_features' will be removed in 1.9.0, use 'list_features_v2' instead",
446
+ version="1.7.0",
447
+ reason="'list_features' will be removed in 1.10.0, use 'list_features_v2' instead",
448
448
  category=FutureWarning,
449
449
  )
450
450
  @abstractmethod
@@ -469,10 +469,10 @@ class RunDBInterface(ABC):
469
469
  ) -> mlrun.common.schemas.FeaturesOutputV2:
470
470
  pass
471
471
 
472
- # TODO: remove in 1.9.0
472
+ # TODO: remove in 1.10.0
473
473
  @deprecated(
474
- version="1.9.0",
475
- reason="'list_entities' will be removed in 1.9.0, use 'list_entities_v2' instead",
474
+ version="1.7.0",
475
+ reason="'list_entities' will be removed in 1.10.0, use 'list_entities_v2' instead",
476
476
  category=FutureWarning,
477
477
  )
478
478
  @abstractmethod
@@ -734,7 +734,7 @@ class RunDBInterface(ABC):
734
734
  labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
735
735
  start: Optional[datetime.datetime] = None,
736
736
  end: Optional[datetime.datetime] = None,
737
- tsdb_metrics: bool = True,
737
+ tsdb_metrics: bool = False,
738
738
  metric_list: Optional[list[str]] = None,
739
739
  top_level: bool = False,
740
740
  uids: Optional[list[str]] = None,
mlrun/db/httpdb.py CHANGED
@@ -945,7 +945,7 @@ class HTTPRunDB(RunDBInterface):
945
945
  or just `"label"` for key existence.
946
946
  - A comma-separated string formatted as `"label1=value1,label2"` to match entities with
947
947
  the specified key-value pairs or key existence.
948
- :param state: Deprecated - List only runs whose state is specified (will be removed in 1.9.0)
948
+ :param state: Deprecated - List only runs whose state is specified (will be removed in 1.10.0)
949
949
  :param states: List only runs whose state is one of the provided states.
950
950
  :param sort: Whether to sort the result according to their start time. Otherwise, results will be
951
951
  returned by their internal order in the DB (order will not be guaranteed).
@@ -1277,7 +1277,7 @@ class HTTPRunDB(RunDBInterface):
1277
1277
  points to a run and is used to filter artifacts by the run that produced them when the artifact producer id
1278
1278
  is a workflow id (artifact was created as part of a workflow).
1279
1279
  :param format_: The format in which to return the artifacts. Default is 'full'.
1280
- :param limit: Deprecated - Maximum number of artifacts to return (will be removed in 1.10.0).
1280
+ :param limit: Deprecated - Maximum number of artifacts to return (will be removed in 1.11.0).
1281
1281
  :param partition_by: Field to group results by. When `partition_by` is specified, the `partition_sort_by`
1282
1282
  parameter must be provided as well.
1283
1283
  :param rows_per_partition: How many top rows (per sorting defined by `partition_sort_by` and `partition_order`)
@@ -2221,18 +2221,20 @@ class HTTPRunDB(RunDBInterface):
2221
2221
  elif pipe_file.endswith(".zip"):
2222
2222
  headers = {"content-type": "application/zip"}
2223
2223
  else:
2224
- raise ValueError("pipeline file must be .yaml or .zip")
2224
+ raise ValueError("'pipeline' file must be .yaml or .zip")
2225
2225
  if arguments:
2226
2226
  if not isinstance(arguments, dict):
2227
- raise ValueError("arguments must be dict type")
2227
+ raise ValueError("'arguments' must be dict type")
2228
2228
  headers[mlrun.common.schemas.HeaderNames.pipeline_arguments] = str(
2229
2229
  arguments
2230
2230
  )
2231
2231
 
2232
2232
  if not path.isfile(pipe_file):
2233
- raise OSError(f"file {pipe_file} doesnt exist")
2233
+ raise OSError(f"File {pipe_file} doesnt exist")
2234
2234
  with open(pipe_file, "rb") as fp:
2235
2235
  data = fp.read()
2236
+ if not data:
2237
+ raise ValueError("The compiled pipe file is empty")
2236
2238
  if not isinstance(pipeline, str):
2237
2239
  remove(pipe_file)
2238
2240
 
@@ -3767,7 +3769,7 @@ class HTTPRunDB(RunDBInterface):
3767
3769
  labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
3768
3770
  start: Optional[datetime] = None,
3769
3771
  end: Optional[datetime] = None,
3770
- tsdb_metrics: bool = True,
3772
+ tsdb_metrics: bool = False,
3771
3773
  metric_list: Optional[list[str]] = None,
3772
3774
  top_level: bool = False,
3773
3775
  uids: Optional[list[str]] = None,
@@ -3889,8 +3891,8 @@ class HTTPRunDB(RunDBInterface):
3889
3891
  attributes_keys = list(attributes.keys())
3890
3892
  attributes["name"] = name
3891
3893
  attributes["project"] = project
3892
- attributes["function-name"] = function_name or None
3893
- attributes["function-tag"] = function_tag or None
3894
+ attributes["function_name"] = function_name or None
3895
+ attributes["function_tag"] = function_tag or None
3894
3896
  attributes["uid"] = endpoint_id or None
3895
3897
  model_endpoint = mlrun.common.schemas.ModelEndpoint.from_flat_dict(attributes)
3896
3898
  path = f"projects/{project}/model-endpoints"
@@ -5100,9 +5102,9 @@ class HTTPRunDB(RunDBInterface):
5100
5102
  labels = self._parse_labels(labels)
5101
5103
 
5102
5104
  if limit:
5103
- # TODO: Remove this in 1.10.0
5105
+ # TODO: Remove this in 1.11.0
5104
5106
  warnings.warn(
5105
- "'limit' is deprecated and will be removed in 1.10.0. Use 'page' and 'page_size' instead.",
5107
+ "'limit' is deprecated and will be removed in 1.11.0. Use 'page' and 'page_size' instead.",
5106
5108
  FutureWarning,
5107
5109
  )
5108
5110
 
@@ -5242,9 +5244,9 @@ class HTTPRunDB(RunDBInterface):
5242
5244
  )
5243
5245
 
5244
5246
  if state:
5245
- # TODO: Remove this in 1.9.0
5247
+ # TODO: Remove this in 1.10.0
5246
5248
  warnings.warn(
5247
- "'state' is deprecated and will be removed in 1.9.0. Use 'states' instead.",
5249
+ "'state' is deprecated in 1.7.0 and will be removed in 1.10.0. Use 'states' instead.",
5248
5250
  FutureWarning,
5249
5251
  )
5250
5252
 
mlrun/db/nopdb.py CHANGED
@@ -631,7 +631,7 @@ class NopDB(RunDBInterface):
631
631
  labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
632
632
  start: Optional[datetime.datetime] = None,
633
633
  end: Optional[datetime.datetime] = None,
634
- tsdb_metrics: bool = True,
634
+ tsdb_metrics: bool = False,
635
635
  metric_list: Optional[list[str]] = None,
636
636
  top_level: bool = False,
637
637
  uids: Optional[list[str]] = None,
mlrun/execution.py CHANGED
@@ -976,7 +976,7 @@ class MLClientCtx:
976
976
  def get_cached_artifact(self, key):
977
977
  """Return a logged artifact from cache (for potential updates)"""
978
978
  warnings.warn(
979
- "get_cached_artifact is deprecated in 1.8.0 and will be removed in 1.10.0. Use get_artifact instead.",
979
+ "get_cached_artifact is deprecated in 1.8.0 and will be removed in 1.11.0. Use get_artifact instead.",
980
980
  FutureWarning,
981
981
  )
982
982
  return self.get_artifact(key)
@@ -690,10 +690,10 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
690
690
  }
691
691
  self._registered_artifacts = {}
692
692
 
693
- # Get the model artifact. If the model was logged during this run, use the cached artifact, otherwise use the
693
+ # Get the model artifact. If the model was logged during this run, use the artifact, otherwise use the
694
694
  # user's given model path:
695
695
  model_artifact = (
696
- self._context.get_cached_artifact(self._model_name)
696
+ self._context.get_artifact(self._model_name)
697
697
  if self._is_logged
698
698
  else self._model_path
699
699
  )
@@ -181,7 +181,7 @@ def record_results(
181
181
  if drift_threshold is not None or possible_drift_threshold is not None:
182
182
  warnings.warn(
183
183
  "Custom drift threshold arguments are deprecated since version "
184
- "1.7.0 and have no effect. They will be removed in version 1.9.0.\n"
184
+ "1.7.0 and have no effect. They will be removed in version 1.10.0.\n"
185
185
  "To enable the default histogram data drift application, run:\n"
186
186
  "`project.enable_model_monitoring()`.",
187
187
  FutureWarning,
@@ -189,7 +189,7 @@ def record_results(
189
189
  if trigger_monitoring_job is not False:
190
190
  warnings.warn(
191
191
  "`trigger_monitoring_job` argument is deprecated since version "
192
- "1.7.0 and has no effect. It will be removed in version 1.9.0.\n"
192
+ "1.7.0 and has no effect. It will be removed in version 1.10.0.\n"
193
193
  "To enable the default histogram data drift application, run:\n"
194
194
  "`project.enable_model_monitoring()`.",
195
195
  FutureWarning,
@@ -197,13 +197,13 @@ def record_results(
197
197
  if artifacts_tag != "":
198
198
  warnings.warn(
199
199
  "`artifacts_tag` argument is deprecated since version "
200
- "1.7.0 and has no effect. It will be removed in version 1.9.0.",
200
+ "1.7.0 and has no effect. It will be removed in version 1.10.0.",
201
201
  FutureWarning,
202
202
  )
203
203
  if default_batch_image != "mlrun/mlrun":
204
204
  warnings.warn(
205
205
  "`default_batch_image` argument is deprecated since version "
206
- "1.7.0 and has no effect. It will be removed in version 1.9.0.",
206
+ "1.7.0 and has no effect. It will be removed in version 1.10.0.",
207
207
  FutureWarning,
208
208
  )
209
209
 
@@ -14,19 +14,18 @@
14
14
 
15
15
  import json
16
16
  import posixpath
17
- import uuid
18
17
  import warnings
19
18
  from abc import ABC
19
+ from tempfile import NamedTemporaryFile
20
+ from typing import Optional
20
21
 
21
- import pandas as pd
22
22
  import semver
23
- from evidently.ui.storage.local.base import METADATA_PATH, FSLocation
24
23
 
25
24
  import mlrun.model_monitoring.applications.base as mm_base
26
25
  import mlrun.model_monitoring.applications.context as mm_context
27
- from mlrun.errors import MLRunIncompatibleVersionError
26
+ from mlrun.errors import MLRunIncompatibleVersionError, MLRunValueError
28
27
 
29
- SUPPORTED_EVIDENTLY_VERSION = semver.Version.parse("0.6.0")
28
+ SUPPORTED_EVIDENTLY_VERSION = semver.Version.parse("0.7.5")
30
29
 
31
30
 
32
31
  def _check_evidently_version(*, cur: semver.Version, ref: semver.Version) -> None:
@@ -60,36 +59,66 @@ except ModuleNotFoundError:
60
59
 
61
60
 
62
61
  if _HAS_EVIDENTLY:
63
- from evidently.suite.base_suite import Display
64
- from evidently.ui.type_aliases import STR_UUID
65
- from evidently.ui.workspace import Workspace
66
- from evidently.utils.dashboard import TemplateParams, file_html_template
62
+ from evidently.core.report import Snapshot
63
+ from evidently.legacy.ui.storage.local.base import METADATA_PATH, FSLocation
64
+ from evidently.ui.workspace import (
65
+ STR_UUID,
66
+ CloudWorkspace,
67
+ Project,
68
+ Workspace,
69
+ WorkspaceBase,
70
+ )
67
71
 
68
72
 
69
73
  class EvidentlyModelMonitoringApplicationBase(
70
74
  mm_base.ModelMonitoringApplicationBase, ABC
71
75
  ):
72
76
  def __init__(
73
- self, evidently_workspace_path: str, evidently_project_id: "STR_UUID"
77
+ self,
78
+ evidently_project_id: "STR_UUID",
79
+ evidently_workspace_path: Optional[str] = None,
80
+ cloud_workspace: bool = False,
74
81
  ) -> None:
75
82
  """
76
- A class for integrating Evidently for mlrun model monitoring within a monitoring application.
77
- Note: evidently is not installed by default in the mlrun/mlrun image.
78
- It must be installed separately to use this class.
83
+ A class for integrating Evidently for MLRun model monitoring within a monitoring application.
84
+
85
+ .. note::
86
+
87
+ The ``evidently`` package is not installed by default in the mlrun/mlrun image.
88
+ It must be installed separately to use this class.
79
89
 
80
- :param evidently_workspace_path: (str) The path to the Evidently workspace.
81
90
  :param evidently_project_id: (str) The ID of the Evidently project.
91
+ :param evidently_workspace_path: (str) The path to the Evidently workspace.
92
+ :param cloud_workspace: (bool) Whether the workspace is an Evidently Cloud workspace.
82
93
  """
83
-
84
- # TODO : more then one project (mep -> project)
85
94
  if not _HAS_EVIDENTLY:
86
95
  raise ModuleNotFoundError("Evidently is not installed - the app cannot run")
87
- self._log_location(evidently_workspace_path)
88
- self.evidently_workspace = Workspace.create(evidently_workspace_path)
96
+ self.evidently_workspace_path = evidently_workspace_path
97
+ if cloud_workspace:
98
+ self.get_workspace = self.get_cloud_workspace
99
+ self.evidently_workspace = self.get_workspace()
89
100
  self.evidently_project_id = evidently_project_id
90
- self.evidently_project = self.evidently_workspace.get_project(
91
- evidently_project_id
92
- )
101
+ self.evidently_project = self.load_project()
102
+
103
+ def load_project(self) -> Project:
104
+ """Load the Evidently project."""
105
+ return self.evidently_workspace.get_project(self.evidently_project_id)
106
+
107
+ def get_workspace(self) -> WorkspaceBase:
108
+ """Get the Evidently workspace. Override this method for customize access to the workspace."""
109
+ if self.evidently_workspace_path:
110
+ self._log_location(self.evidently_workspace_path)
111
+ return Workspace.create(self.evidently_workspace_path)
112
+ else:
113
+ raise MLRunValueError(
114
+ "A local workspace could not be created as `evidently_workspace_path` is not set.\n"
115
+ "If you intend to use a cloud workspace, please use `cloud_workspace=True` and set the "
116
+ "`EVIDENTLY_API_KEY` environment variable. In other cases, override this method."
117
+ )
118
+
119
+ def get_cloud_workspace(self) -> CloudWorkspace:
120
+ """Load the Evidently cloud workspace according to the `EVIDENTLY_API_KEY` environment variable."""
121
+ return CloudWorkspace()
93
122
 
94
123
  @staticmethod
95
124
  def _log_location(evidently_workspace_path):
@@ -128,7 +157,7 @@ class EvidentlyModelMonitoringApplicationBase(
128
157
  @staticmethod
129
158
  def log_evidently_object(
130
159
  monitoring_context: mm_context.MonitoringApplicationContext,
131
- evidently_object: "Display",
160
+ evidently_object: "Snapshot",
132
161
  artifact_name: str,
133
162
  unique_per_endpoint: bool = True,
134
163
  ) -> None:
@@ -141,56 +170,15 @@ class EvidentlyModelMonitoringApplicationBase(
141
170
  This method should be called on special occasions only.
142
171
 
143
172
  :param monitoring_context: (MonitoringApplicationContext) The monitoring context to process.
144
- :param evidently_object: (Display) The Evidently display to log, e.g. a report or a test suite object.
145
- :param artifact_name: (str) The name for the logged artifact.
146
- :param unique_per_endpoint: by default ``True``, we will log different artifact for each model endpoint,
147
- set to ``False`` without changing item key will cause artifact override.
148
- """
149
- evidently_object_html = evidently_object.get_html()
150
- monitoring_context.log_artifact(
151
- artifact_name,
152
- body=evidently_object_html.encode("utf-8"),
153
- format="html",
154
- unique_per_endpoint=unique_per_endpoint,
155
- )
156
-
157
- def log_project_dashboard(
158
- self,
159
- monitoring_context: mm_context.MonitoringApplicationContext,
160
- timestamp_start: pd.Timestamp,
161
- timestamp_end: pd.Timestamp,
162
- artifact_name: str = "dashboard",
163
- unique_per_endpoint: bool = True,
164
- ) -> None:
165
- """
166
- Logs an Evidently project dashboard.
167
-
168
- .. caution::
169
-
170
- Logging Evidently dashboards in every model monitoring window may cause scale issues.
171
- This method should be called on special occasions only.
172
-
173
- :param monitoring_context: (MonitoringApplicationContext) The monitoring context to process.
174
- :param timestamp_start: (pd.Timestamp) The start timestamp for the dashboard data.
175
- :param timestamp_end: (pd.Timestamp) The end timestamp for the dashboard data.
173
+ :param evidently_object: (Snapshot) The Evidently run to log, e.g. a report run.
176
174
  :param artifact_name: (str) The name for the logged artifact.
177
175
  :param unique_per_endpoint: by default ``True``, we will log different artifact for each model endpoint,
178
176
  set to ``False`` without changing item key will cause artifact override.
179
177
  """
180
-
181
- dashboard_info = self.evidently_project.build_dashboard_info(
182
- timestamp_start, timestamp_end
183
- )
184
- template_params = TemplateParams(
185
- dashboard_id="pd_" + str(uuid.uuid4()).replace("-", ""),
186
- dashboard_info=dashboard_info,
187
- additional_graphs={},
188
- )
189
-
190
- dashboard_html = file_html_template(params=template_params)
191
- monitoring_context.log_artifact(
192
- artifact_name,
193
- body=dashboard_html.encode("utf-8"),
194
- format="html",
195
- unique_per_endpoint=unique_per_endpoint,
196
- )
178
+ with NamedTemporaryFile(suffix=".html") as file:
179
+ evidently_object.save_html(filename=file.name)
180
+ monitoring_context.log_artifact(
181
+ artifact_name,
182
+ local_path=file.name,
183
+ unique_per_endpoint=unique_per_endpoint,
184
+ )