mlrun 1.8.0rc50__py3-none-any.whl → 1.8.0rc52__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.

@@ -38,21 +38,30 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
38
38
 
39
39
  For example, :code:`MyApp` below is a simplistic custom application::
40
40
 
41
+ from mlrun.common.schemas.model_monitoring.constants import (
42
+ ResultKindApp,
43
+ ResultStatusApp,
44
+ )
45
+ from mlrun.model_monitoring.applications import (
46
+ ModelMonitoringApplicationBase,
47
+ ModelMonitoringApplicationResult,
48
+ MonitoringApplicationContext,
49
+ )
50
+
51
+
41
52
  class MyApp(ModelMonitoringApplicationBase):
42
53
  def do_tracking(
43
- self,
44
- monitoring_context: mm_context.MonitoringApplicationContext,
54
+ self, monitoring_context: MonitoringApplicationContext
45
55
  ) -> ModelMonitoringApplicationResult:
46
- monitoring_context.log_artifact(
47
- TableArtifact(
48
- "sample_df_stats", df=self.dict_to_histogram(sample_df_stats)
49
- )
56
+ monitoring_context.logger.info(
57
+ "Running application",
58
+ application_name=monitoring_context.application_name,
50
59
  )
51
60
  return ModelMonitoringApplicationResult(
52
61
  name="data_drift_test",
53
62
  value=0.5,
54
- kind=mm_constant.ResultKindApp.data_drift,
55
- status=mm_constant.ResultStatusApp.detected,
63
+ kind=ResultKindApp.data_drift,
64
+ status=ResultStatusApp.detected,
56
65
  )
57
66
  """
58
67
 
@@ -330,9 +330,17 @@ class MonitoringApplicationContext:
330
330
  ) -> Artifact:
331
331
  """
332
332
  Log an artifact.
333
- See :func:`~mlrun.projects.MlrunProject.log_artifact` for the documentation.
334
- :param unique_per_endpoint: by default True, we will log different artifact for each model endpoint,
335
- set to False without changing item key will cause artifact override
333
+
334
+ .. caution::
335
+
336
+ Logging artifacts in every model monitoring window may cause scale issues.
337
+ This method should be called on special occasions only.
338
+
339
+ See :func:`~mlrun.projects.MlrunProject.log_artifact` for the full documentation, except for one
340
+ new argument:
341
+
342
+ :param unique_per_endpoint: by default ``True``, we will log different artifact for each model endpoint,
343
+ set to ``False`` without changing item key will cause artifact override.
336
344
  """
337
345
  labels = self._add_default_labels(labels)
338
346
  # By default, we want to log different artifact for each model endpoint
@@ -375,9 +383,17 @@ class MonitoringApplicationContext:
375
383
  ) -> DatasetArtifact:
376
384
  """
377
385
  Log a dataset artifact.
378
- See :func:`~mlrun.projects.MlrunProject.log_dataset` for the documentation.
379
- :param unique_per_endpoint: by default True, we will log different dataset for each model endpoint,
380
- set to False without changing item key will cause dataset override
386
+
387
+ .. caution::
388
+
389
+ Logging datasets in every model monitoring window may cause scale issues.
390
+ This method should be called on special occasions only.
391
+
392
+ See :func:`~mlrun.projects.MlrunProject.log_dataset` for the full documentation, except for one
393
+ new argument:
394
+
395
+ :param unique_per_endpoint: by default ``True``, we will log different artifact for each model endpoint,
396
+ set to ``False`` without changing item key will cause artifact override.
381
397
  """
382
398
  labels = self._add_default_labels(labels)
383
399
  # By default, we want to log different artifact for each model endpoint
@@ -130,17 +130,28 @@ class EvidentlyModelMonitoringApplicationBase(
130
130
  monitoring_context: mm_context.MonitoringApplicationContext,
131
131
  evidently_object: "Display",
132
132
  artifact_name: str,
133
+ unique_per_endpoint: bool = True,
133
134
  ) -> None:
134
135
  """
135
- Logs an Evidently report or suite as an artifact.
136
+ Logs an Evidently report or suite as an artifact.
137
+
138
+ .. caution::
139
+
140
+ Logging Evidently objects in every model monitoring window may cause scale issues.
141
+ This method should be called on special occasions only.
136
142
 
137
143
  :param monitoring_context: (MonitoringApplicationContext) The monitoring context to process.
138
144
  :param evidently_object: (Display) The Evidently display to log, e.g. a report or a test suite object.
139
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.
140
148
  """
141
149
  evidently_object_html = evidently_object.get_html()
142
150
  monitoring_context.log_artifact(
143
- artifact_name, body=evidently_object_html.encode("utf-8"), format="html"
151
+ artifact_name,
152
+ body=evidently_object_html.encode("utf-8"),
153
+ format="html",
154
+ unique_per_endpoint=unique_per_endpoint,
144
155
  )
145
156
 
146
157
  def log_project_dashboard(
@@ -149,14 +160,22 @@ class EvidentlyModelMonitoringApplicationBase(
149
160
  timestamp_start: pd.Timestamp,
150
161
  timestamp_end: pd.Timestamp,
151
162
  artifact_name: str = "dashboard",
163
+ unique_per_endpoint: bool = True,
152
164
  ) -> None:
153
165
  """
154
166
  Logs an Evidently project dashboard.
155
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
+
156
173
  :param monitoring_context: (MonitoringApplicationContext) The monitoring context to process.
157
174
  :param timestamp_start: (pd.Timestamp) The start timestamp for the dashboard data.
158
175
  :param timestamp_end: (pd.Timestamp) The end timestamp for the dashboard data.
159
176
  :param artifact_name: (str) The name for the logged artifact.
177
+ :param unique_per_endpoint: by default ``True``, we will log different artifact for each model endpoint,
178
+ set to ``False`` without changing item key will cause artifact override.
160
179
  """
161
180
 
162
181
  dashboard_info = self.evidently_project.build_dashboard_info(
@@ -170,5 +189,8 @@ class EvidentlyModelMonitoringApplicationBase(
170
189
 
171
190
  dashboard_html = file_html_template(params=template_params)
172
191
  monitoring_context.log_artifact(
173
- artifact_name, body=dashboard_html.encode("utf-8"), format="html"
192
+ artifact_name,
193
+ body=dashboard_html.encode("utf-8"),
194
+ format="html",
195
+ unique_per_endpoint=unique_per_endpoint,
174
196
  )
@@ -102,10 +102,10 @@ class HistogramDataDriftApplication(ModelMonitoringApplicationBase):
102
102
  Each metric is calculated over all the features individually and the mean is taken as the metric value.
103
103
  The average of Hellinger and total variance distance is taken as the result.
104
104
 
105
- The application can log two artifacts:
105
+ The application can log two artifacts (disabled by default due to performance issues):
106
106
 
107
- * JSON with the general drift value per feature, produced by default.
108
- * Plotly table with the various metrics and histograms per feature (disabled by default due to performance issues).
107
+ * JSON with the general drift value per feature.
108
+ * Plotly table with the various metrics and histograms per feature.
109
109
 
110
110
  This application is deployed by default when calling
111
111
  :py:func:`~mlrun.projects.MlrunProject.enable_model_monitoring`.
@@ -134,12 +134,14 @@ class HistogramDataDriftApplication(ModelMonitoringApplicationBase):
134
134
  def __init__(
135
135
  self,
136
136
  value_classifier: Optional[ValueClassifier] = None,
137
- produce_json_artifact: bool = True,
137
+ produce_json_artifact: bool = False,
138
138
  produce_plotly_artifact: bool = False,
139
139
  ) -> None:
140
140
  """
141
- :param value_classifier: Classifier object that adheres to the :py:class:`~ValueClassifier` protocol.
142
- If not provided, the default :py:class:`~DataDriftClassifier` is used.
141
+ :param value_classifier: Classifier object that adheres to the :py:class:`~ValueClassifier` protocol.
142
+ If not provided, the default :py:class:`~DataDriftClassifier` is used.
143
+ :param produce_json_artifact: Whether to produce the JSON artifact or not, ``False`` by default.
144
+ :param produce_plotly_artifact: Whether to produce the Plotly artifact or not, ``False`` by default.
143
145
  """
144
146
  self._value_classifier = value_classifier or DataDriftClassifier()
145
147
  assert self._REQUIRED_METRICS <= set(
@@ -384,9 +384,6 @@ class ProcessEndpointEvent(mlrun.feature_store.steps.MapClass):
384
384
  # Set time for the first request of the current endpoint
385
385
  self.first_request[endpoint_id] = timestamp
386
386
 
387
- # Set time for the last reqeust of the current endpoint
388
- self.last_request[endpoint_id] = timestamp
389
-
390
387
  if not self.is_valid(
391
388
  validation_function=is_not_none,
392
389
  field=request_id,
@@ -413,7 +410,7 @@ class ProcessEndpointEvent(mlrun.feature_store.steps.MapClass):
413
410
  return None
414
411
 
415
412
  # Convert timestamp to a datetime object
416
- timestamp = datetime.datetime.fromisoformat(timestamp)
413
+ timestamp_obj = datetime.datetime.fromisoformat(timestamp)
417
414
 
418
415
  # Separate each model invocation into sub events that will be stored as dictionary
419
416
  # in list of events. This list will be used as the body for the storey event.
@@ -454,16 +451,16 @@ class ProcessEndpointEvent(mlrun.feature_store.steps.MapClass):
454
451
  EventFieldType.FUNCTION_URI: function_uri,
455
452
  EventFieldType.ENDPOINT_NAME: event.get(EventFieldType.MODEL),
456
453
  EventFieldType.MODEL_CLASS: model_class,
457
- EventFieldType.TIMESTAMP: timestamp,
454
+ EventFieldType.TIMESTAMP: timestamp_obj,
458
455
  EventFieldType.ENDPOINT_ID: endpoint_id,
459
456
  EventFieldType.REQUEST_ID: request_id,
460
457
  EventFieldType.LATENCY: latency,
461
458
  EventFieldType.FEATURES: feature,
462
459
  EventFieldType.PREDICTION: prediction,
463
460
  EventFieldType.FIRST_REQUEST: self.first_request[endpoint_id],
464
- EventFieldType.LAST_REQUEST: self.last_request[endpoint_id],
461
+ EventFieldType.LAST_REQUEST: timestamp,
465
462
  EventFieldType.LAST_REQUEST_TIMESTAMP: mlrun.utils.enrich_datetime_with_tz_info(
466
- self.last_request[endpoint_id]
463
+ timestamp
467
464
  ).timestamp(),
468
465
  EventFieldType.LABELS: event.get(EventFieldType.LABELS, {}),
469
466
  EventFieldType.METRICS: event.get(EventFieldType.METRICS, {}),
@@ -492,6 +489,7 @@ class ProcessEndpointEvent(mlrun.feature_store.steps.MapClass):
492
489
  project=self.project,
493
490
  endpoint_id=endpoint_id,
494
491
  name=endpoint_name,
492
+ tsdb_metrics=False,
495
493
  )
496
494
  .flat_dict()
497
495
  )
@@ -503,10 +501,6 @@ class ProcessEndpointEvent(mlrun.feature_store.steps.MapClass):
503
501
  if first_request:
504
502
  self.first_request[endpoint_id] = first_request
505
503
 
506
- last_request = endpoint_record.get(EventFieldType.LAST_REQUEST)
507
- if last_request:
508
- self.last_request[endpoint_id] = last_request
509
-
510
504
  # add endpoint to endpoints set
511
505
  self.endpoints.add(endpoint_id)
512
506
 
@@ -619,6 +613,7 @@ class MapFeatureNames(mlrun.feature_store.steps.MapClass):
619
613
  project=self.project,
620
614
  endpoint_id=endpoint_id,
621
615
  name=event[EventFieldType.ENDPOINT_NAME],
616
+ tsdb_metrics=False,
622
617
  )
623
618
  .flat_dict()
624
619
  )
@@ -692,6 +687,7 @@ class MapFeatureNames(mlrun.feature_store.steps.MapClass):
692
687
  project=self.project,
693
688
  endpoint_id=endpoint_id,
694
689
  name=event[EventFieldType.ENDPOINT_NAME],
690
+ tsdb_metrics=False,
695
691
  )
696
692
  .flat_dict()
697
693
  )
mlrun/serving/states.py CHANGED
@@ -415,15 +415,18 @@ class BaseStep(ModelObj):
415
415
  steps: list[Union[str, StepToDict, dict[str, Any]]],
416
416
  force: bool = False,
417
417
  ):
418
- """set list of steps as downstream from this step, in the order specified. This will overwrite any existing
418
+ """
419
+ Set list of steps as downstream from this step, in the order specified. This will overwrite any existing
419
420
  downstream steps.
420
421
 
421
422
  :param steps: list of steps to follow this one
422
423
  :param force: whether to overwrite existing downstream steps. If False, this method will fail if any downstream
423
- steps have already been defined. Defaults to False.
424
+ steps have already been defined. Defaults to False.
425
+
424
426
  :return: the last step added to the flow
425
427
 
426
- example:
428
+ example::
429
+
427
430
  The below code sets the downstream nodes of step1 by using a list of steps (provided to `set_flow()`) and a
428
431
  single step (provided to `to()`), resulting in the graph (step1 -> step2 -> step3 -> step4).
429
432
  Notice that using `force=True` is required in case step1 already had downstream nodes (e.g. if the existing
@@ -1,4 +1,4 @@
1
1
  {
2
- "git_commit": "d53dc82d7c943cd7610b345057aa0f6ffe9595f9",
3
- "version": "1.8.0-rc50"
2
+ "git_commit": "88743368a195fa6a646e11a97a605e76a44d3ab2",
3
+ "version": "1.8.0-rc52"
4
4
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlrun
3
- Version: 1.8.0rc50
3
+ Version: 1.8.0rc52
4
4
  Summary: Tracking and config of machine learning runs
5
5
  Home-page: https://github.com/mlrun/mlrun
6
6
  Author: Yaron Haviv
@@ -222,17 +222,17 @@ mlrun/model_monitoring/api.py,sha256=LU58dzE4QZiMH23lgiqfI__3m2E3eEZP-DQe2ioUSwM
222
222
  mlrun/model_monitoring/controller.py,sha256=m4Zx_NQ0C-A7WtjBoXnqBmS11RRtLvBaFgbFbIgrdVc,36847
223
223
  mlrun/model_monitoring/features_drift_table.py,sha256=c6GpKtpOJbuT1u5uMWDL_S-6N4YPOmlktWMqPme3KFY,25308
224
224
  mlrun/model_monitoring/helpers.py,sha256=8QsoYRPOVSnR3Lcv99m4XYrp_cR6hSqBUflYSOkJmFQ,21019
225
- mlrun/model_monitoring/stream_processing.py,sha256=CEVcIFJ0jYvkIMu8hKsIH0HEkrn5l_NoHsxNLk72D5E,33583
225
+ mlrun/model_monitoring/stream_processing.py,sha256=Gu3TQzYoNjbreZYI73-F49QpYrod9RZOyGSgininBsA,33373
226
226
  mlrun/model_monitoring/tracking_policy.py,sha256=PBIGrUYWrwcE5gwXupBIVzOb0QRRwPJsgQm_yLGQxB4,5595
227
227
  mlrun/model_monitoring/writer.py,sha256=ibbhvfSHb8Reqlb7RGFEAUNM4iTyK1gk8-2m46mP6VM,8428
228
228
  mlrun/model_monitoring/applications/__init__.py,sha256=xDBxkBjl-whHSG_4t1mLkxiypLH-fzn8TmAW9Mjo2uI,759
229
229
  mlrun/model_monitoring/applications/_application_steps.py,sha256=PxULZznKW66Oq-fKaraOAbsTuGnV0zgXh6_91wX3KUo,8367
230
- mlrun/model_monitoring/applications/base.py,sha256=7XL12idItWkoE3CJ_48F6cwVx5pJH3bgfG92hb8LcN8,24872
231
- mlrun/model_monitoring/applications/context.py,sha256=l7HculkdcrWbMLjy9tsxEhm-1X6zxJE5Blk-U7yc-5I,16449
232
- mlrun/model_monitoring/applications/histogram_data_drift.py,sha256=09t0tfC35W0SeJA3fzN29pJiB6G-V_8GlcvULVq6H9Q,15179
230
+ mlrun/model_monitoring/applications/base.py,sha256=f73LycKUG85invl6l7V4MRiRd1bx8jmepayrpwpr3c0,25131
231
+ mlrun/model_monitoring/applications/context.py,sha256=VfyPCIdO4z73uqFcJs87jzSI4PatX5N5Xicg8Ye1Bag,16968
232
+ mlrun/model_monitoring/applications/histogram_data_drift.py,sha256=2qgfFmrpHf-x0_EaHD-0T28piwSQzw-HH71aV1GwbZs,15389
233
233
  mlrun/model_monitoring/applications/results.py,sha256=_qmj6TWT0SR2bi7gUyRKBU418eGgGoLW2_hTJ7S-ock,5782
234
234
  mlrun/model_monitoring/applications/evidently/__init__.py,sha256=-DqdPnBSrjZhFvKOu_Ie3MiFvlur9sPTZpZ1u0_1AE8,690
235
- mlrun/model_monitoring/applications/evidently/base.py,sha256=_n_2CCQL-fC6hGUZSCLZxZuvXqMqjDHSFX0Giok8HZw,6793
235
+ mlrun/model_monitoring/applications/evidently/base.py,sha256=3loXT5gOn5v7j2CiXDQnA0cQXroItBSso6aU0t_pzBs,7851
236
236
  mlrun/model_monitoring/db/__init__.py,sha256=r47xPGZpIfMuv8J3PQCZTSqVPMhUta4sSJCZFKcS7FM,644
237
237
  mlrun/model_monitoring/db/_schedules.py,sha256=RWn4wtKsIXg668gMLpxO9I8GlkxvPSaA5y7w-wFDcgE,9048
238
238
  mlrun/model_monitoring/db/_stats.py,sha256=VVMWLMqG3Us3ozBkLaokJF22Ewv8WKmVE1-OvS_g9vA,6943
@@ -306,7 +306,7 @@ mlrun/serving/remote.py,sha256=gxJkj_J3j-sZcVUbUzbAmJafP6t6y4NVFsu0kWmYngA,18818
306
306
  mlrun/serving/routers.py,sha256=SY6AsaiSnh8ssXq8hQE2z9MYapOxFOFJBx9QomiZMO8,53915
307
307
  mlrun/serving/server.py,sha256=KiNhW0nTV5STZPzR6kEAUFVzCCAX8qv0g9AoCopARrM,23429
308
308
  mlrun/serving/serving_wrapper.py,sha256=R670-S6PX_d5ER6jiHtRvacuPyFzQH0mEf2K0sBIIOM,836
309
- mlrun/serving/states.py,sha256=Hh3FBoQbHoO4KiofHfSwi_aUx7mQ26iXpKijcGiDJ6c,73341
309
+ mlrun/serving/states.py,sha256=PaVdgZ8GyE8bxr_-RvuSUINwHuPypJmqaQs27aEPweo,73367
310
310
  mlrun/serving/utils.py,sha256=k2EIYDWHUGkE-IBI6T0UNT32fw-KySsccIJM_LObI00,4171
311
311
  mlrun/serving/v1_serving.py,sha256=c6J_MtpE-Tqu00-6r4eJOCO6rUasHDal9W2eBIcrl50,11853
312
312
  mlrun/serving/v2_serving.py,sha256=b3C5Utv2_AOPrH_hPi3NarjNbAK3kRoeIfqMU4qNuUo,25362
@@ -340,11 +340,11 @@ mlrun/utils/notifications/notification/mail.py,sha256=ZyJ3eqd8simxffQmXzqd3bgbAq
340
340
  mlrun/utils/notifications/notification/slack.py,sha256=eQvmctTh6wIG5xVOesLLV9S1-UUCu5UEQ9JIJOor3ts,7183
341
341
  mlrun/utils/notifications/notification/webhook.py,sha256=NeyIMSBojjjTJaUHmPbxMByp34GxYkl1-16NqzU27fU,4943
342
342
  mlrun/utils/version/__init__.py,sha256=7kkrB7hEZ3cLXoWj1kPoDwo4MaswsI2JVOBpbKgPAgc,614
343
- mlrun/utils/version/version.json,sha256=RjTCuRy3GfFmwMHEpX2EDiMuT-NVXkkSv3yDkLci76E,89
343
+ mlrun/utils/version/version.json,sha256=HlVx8qU6Ht_XX26OtQRbBPB8miakWzI_Bf8z22d2ABo,89
344
344
  mlrun/utils/version/version.py,sha256=eEW0tqIAkU9Xifxv8Z9_qsYnNhn3YH7NRAfM-pPLt1g,1878
345
- mlrun-1.8.0rc50.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
346
- mlrun-1.8.0rc50.dist-info/METADATA,sha256=YlWNT5wCVmdArEFkjRbixRD0tAY-Kzaz54rgHYdQabY,26009
347
- mlrun-1.8.0rc50.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
348
- mlrun-1.8.0rc50.dist-info/entry_points.txt,sha256=1Owd16eAclD5pfRCoJpYC2ZJSyGNTtUr0nCELMioMmU,46
349
- mlrun-1.8.0rc50.dist-info/top_level.txt,sha256=NObLzw3maSF9wVrgSeYBv-fgnHkAJ1kEkh12DLdd5KM,6
350
- mlrun-1.8.0rc50.dist-info/RECORD,,
345
+ mlrun-1.8.0rc52.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
346
+ mlrun-1.8.0rc52.dist-info/METADATA,sha256=__VKEJN8imT-7CR8JC5kKzi8Jpi9ENEwkGV2abMV1Zw,26009
347
+ mlrun-1.8.0rc52.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
348
+ mlrun-1.8.0rc52.dist-info/entry_points.txt,sha256=1Owd16eAclD5pfRCoJpYC2ZJSyGNTtUr0nCELMioMmU,46
349
+ mlrun-1.8.0rc52.dist-info/top_level.txt,sha256=NObLzw3maSF9wVrgSeYBv-fgnHkAJ1kEkh12DLdd5KM,6
350
+ mlrun-1.8.0rc52.dist-info/RECORD,,