mlrun 1.7.0rc20__py3-none-any.whl → 1.7.0rc28__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 (92) hide show
  1. mlrun/__main__.py +10 -8
  2. mlrun/alerts/alert.py +55 -18
  3. mlrun/api/schemas/__init__.py +3 -3
  4. mlrun/artifacts/manager.py +26 -0
  5. mlrun/common/constants.py +3 -2
  6. mlrun/common/formatters/__init__.py +1 -0
  7. mlrun/common/formatters/artifact.py +26 -3
  8. mlrun/common/formatters/base.py +44 -9
  9. mlrun/common/formatters/function.py +12 -7
  10. mlrun/common/formatters/run.py +26 -0
  11. mlrun/common/helpers.py +11 -0
  12. mlrun/common/schemas/__init__.py +4 -0
  13. mlrun/common/schemas/alert.py +5 -9
  14. mlrun/common/schemas/api_gateway.py +64 -16
  15. mlrun/common/schemas/artifact.py +11 -0
  16. mlrun/common/schemas/constants.py +3 -0
  17. mlrun/common/schemas/feature_store.py +58 -28
  18. mlrun/common/schemas/model_monitoring/constants.py +21 -12
  19. mlrun/common/schemas/model_monitoring/model_endpoints.py +0 -12
  20. mlrun/common/schemas/pipeline.py +16 -0
  21. mlrun/common/schemas/project.py +17 -0
  22. mlrun/common/schemas/runs.py +17 -0
  23. mlrun/common/schemas/schedule.py +1 -1
  24. mlrun/common/types.py +6 -0
  25. mlrun/config.py +17 -25
  26. mlrun/datastore/azure_blob.py +2 -1
  27. mlrun/datastore/datastore.py +3 -3
  28. mlrun/datastore/google_cloud_storage.py +6 -2
  29. mlrun/datastore/snowflake_utils.py +3 -1
  30. mlrun/datastore/sources.py +26 -11
  31. mlrun/datastore/store_resources.py +2 -0
  32. mlrun/datastore/targets.py +68 -16
  33. mlrun/db/base.py +83 -2
  34. mlrun/db/httpdb.py +280 -63
  35. mlrun/db/nopdb.py +60 -3
  36. mlrun/errors.py +5 -3
  37. mlrun/execution.py +28 -13
  38. mlrun/feature_store/feature_vector.py +8 -0
  39. mlrun/feature_store/retrieval/spark_merger.py +13 -2
  40. mlrun/launcher/local.py +4 -0
  41. mlrun/launcher/remote.py +1 -0
  42. mlrun/model.py +32 -3
  43. mlrun/model_monitoring/api.py +7 -52
  44. mlrun/model_monitoring/applications/base.py +5 -7
  45. mlrun/model_monitoring/applications/histogram_data_drift.py +1 -1
  46. mlrun/model_monitoring/db/stores/__init__.py +37 -24
  47. mlrun/model_monitoring/db/stores/base/store.py +40 -1
  48. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +42 -87
  49. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +27 -35
  50. mlrun/model_monitoring/db/tsdb/__init__.py +15 -15
  51. mlrun/model_monitoring/db/tsdb/base.py +1 -14
  52. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +22 -18
  53. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +86 -56
  54. mlrun/model_monitoring/helpers.py +34 -9
  55. mlrun/model_monitoring/stream_processing.py +12 -11
  56. mlrun/model_monitoring/writer.py +11 -11
  57. mlrun/projects/operations.py +5 -0
  58. mlrun/projects/pipelines.py +35 -21
  59. mlrun/projects/project.py +216 -107
  60. mlrun/render.py +10 -5
  61. mlrun/run.py +15 -5
  62. mlrun/runtimes/__init__.py +2 -0
  63. mlrun/runtimes/base.py +17 -4
  64. mlrun/runtimes/daskjob.py +8 -1
  65. mlrun/runtimes/databricks_job/databricks_runtime.py +1 -0
  66. mlrun/runtimes/local.py +23 -4
  67. mlrun/runtimes/nuclio/application/application.py +0 -2
  68. mlrun/runtimes/nuclio/function.py +31 -2
  69. mlrun/runtimes/nuclio/serving.py +9 -6
  70. mlrun/runtimes/pod.py +5 -29
  71. mlrun/runtimes/remotesparkjob.py +8 -2
  72. mlrun/serving/__init__.py +8 -1
  73. mlrun/serving/routers.py +75 -59
  74. mlrun/serving/server.py +11 -0
  75. mlrun/serving/states.py +80 -8
  76. mlrun/serving/utils.py +19 -11
  77. mlrun/serving/v2_serving.py +66 -39
  78. mlrun/utils/helpers.py +91 -11
  79. mlrun/utils/logger.py +36 -2
  80. mlrun/utils/notifications/notification/base.py +43 -7
  81. mlrun/utils/notifications/notification/git.py +21 -0
  82. mlrun/utils/notifications/notification/slack.py +9 -14
  83. mlrun/utils/notifications/notification/webhook.py +41 -1
  84. mlrun/utils/notifications/notification_pusher.py +3 -9
  85. mlrun/utils/regex.py +9 -0
  86. mlrun/utils/version/version.json +2 -2
  87. {mlrun-1.7.0rc20.dist-info → mlrun-1.7.0rc28.dist-info}/METADATA +16 -9
  88. {mlrun-1.7.0rc20.dist-info → mlrun-1.7.0rc28.dist-info}/RECORD +92 -91
  89. {mlrun-1.7.0rc20.dist-info → mlrun-1.7.0rc28.dist-info}/WHEEL +1 -1
  90. {mlrun-1.7.0rc20.dist-info → mlrun-1.7.0rc28.dist-info}/LICENSE +0 -0
  91. {mlrun-1.7.0rc20.dist-info → mlrun-1.7.0rc28.dist-info}/entry_points.txt +0 -0
  92. {mlrun-1.7.0rc20.dist-info → mlrun-1.7.0rc28.dist-info}/top_level.txt +0 -0
@@ -29,7 +29,10 @@ from mergedeep import merge
29
29
  import mlrun
30
30
  import mlrun.utils.helpers
31
31
  from mlrun.config import config
32
- from mlrun.datastore.snowflake_utils import get_snowflake_spark_options
32
+ from mlrun.datastore.snowflake_utils import (
33
+ get_snowflake_password,
34
+ get_snowflake_spark_options,
35
+ )
33
36
  from mlrun.datastore.utils import transform_list_filters_to_tuple
34
37
  from mlrun.model import DataSource, DataTarget, DataTargetBase, TargetPathObject
35
38
  from mlrun.utils import logger, now_date
@@ -696,6 +699,7 @@ class BaseStoreTarget(DataTargetBase):
696
699
  self.kind, self.name, self.get_target_templated_path()
697
700
  )
698
701
  target = self._target
702
+ target.attributes = self.attributes
699
703
  target.run_id = self.run_id
700
704
  target.status = status or target.status or "created"
701
705
  target.updated = now_date().isoformat()
@@ -727,8 +731,18 @@ class BaseStoreTarget(DataTargetBase):
727
731
  raise NotImplementedError()
728
732
 
729
733
  def purge(self):
734
+ """
735
+ Delete the files of the target.
736
+
737
+ Do not use this function directly from the sdk. Use FeatureSet.purge_targets.
738
+ """
730
739
  store, path_in_store, target_path = self._get_store_and_path()
731
- store.rm(target_path, recursive=True)
740
+ if path_in_store not in ["", "/"]:
741
+ store.rm(path_in_store, recursive=True)
742
+ else:
743
+ raise mlrun.errors.MLRunInvalidArgumentError(
744
+ "Unable to delete target. Please Use purge_targets from FeatureSet object."
745
+ )
732
746
 
733
747
  def as_df(
734
748
  self,
@@ -764,6 +778,10 @@ class BaseStoreTarget(DataTargetBase):
764
778
  def get_dask_options(self):
765
779
  raise NotImplementedError()
766
780
 
781
+ @property
782
+ def source_spark_attributes(self) -> dict:
783
+ return {}
784
+
767
785
 
768
786
  class ParquetTarget(BaseStoreTarget):
769
787
  """Parquet target storage driver, used to materialize feature set/vector data into parquet files.
@@ -1197,19 +1215,20 @@ class SnowflakeTarget(BaseStoreTarget):
1197
1215
  warehouse: str = None,
1198
1216
  table_name: str = None,
1199
1217
  ):
1200
- attrs = {
1201
- "url": url,
1202
- "user": user,
1203
- "database": database,
1204
- "schema": db_schema,
1205
- "warehouse": warehouse,
1206
- "table": table_name,
1207
- }
1208
- extended_attrs = {
1209
- key: value for key, value in attrs.items() if value is not None
1210
- }
1211
- attributes = {} if not attributes else attributes
1212
- attributes.update(extended_attrs)
1218
+ attributes = attributes or {}
1219
+ if url:
1220
+ attributes["url"] = url
1221
+ if user:
1222
+ attributes["user"] = user
1223
+ if database:
1224
+ attributes["database"] = database
1225
+ if db_schema:
1226
+ attributes["db_schema"] = db_schema
1227
+ if warehouse:
1228
+ attributes["warehouse"] = warehouse
1229
+ if table_name:
1230
+ attributes["table"] = table_name
1231
+
1213
1232
  super().__init__(
1214
1233
  name,
1215
1234
  path,
@@ -1233,7 +1252,31 @@ class SnowflakeTarget(BaseStoreTarget):
1233
1252
  return spark_options
1234
1253
 
1235
1254
  def purge(self):
1236
- pass
1255
+ import snowflake.connector
1256
+
1257
+ missing = [
1258
+ key
1259
+ for key in ["database", "db_schema", "table", "url", "user", "warehouse"]
1260
+ if self.attributes.get(key) is None
1261
+ ]
1262
+ if missing:
1263
+ raise mlrun.errors.MLRunRuntimeError(
1264
+ f"Can't purge Snowflake target, "
1265
+ f"some attributes are missing: {', '.join(missing)}"
1266
+ )
1267
+ account = self.attributes["url"].replace(".snowflakecomputing.com", "")
1268
+
1269
+ with snowflake.connector.connect(
1270
+ account=account,
1271
+ user=self.attributes["user"],
1272
+ password=get_snowflake_password(),
1273
+ warehouse=self.attributes["warehouse"],
1274
+ ) as snowflake_connector:
1275
+ drop_statement = (
1276
+ f"DROP TABLE IF EXISTS {self.attributes['database']}.{self.attributes['db_schema']}"
1277
+ f".{self.attributes['table']}"
1278
+ )
1279
+ snowflake_connector.execute_string(drop_statement)
1237
1280
 
1238
1281
  def as_df(
1239
1282
  self,
@@ -1248,6 +1291,15 @@ class SnowflakeTarget(BaseStoreTarget):
1248
1291
  ):
1249
1292
  raise NotImplementedError()
1250
1293
 
1294
+ @property
1295
+ def source_spark_attributes(self) -> dict:
1296
+ keys = ["url", "user", "database", "db_schema", "warehouse"]
1297
+ attributes = self.attributes or {}
1298
+ snowflake_dict = {key: attributes.get(key) for key in keys}
1299
+ table = attributes.get("table")
1300
+ snowflake_dict["query"] = f"SELECT * from {table}" if table else None
1301
+ return snowflake_dict
1302
+
1251
1303
 
1252
1304
  class NoSqlBaseTarget(BaseStoreTarget):
1253
1305
  is_table = True
mlrun/db/base.py CHANGED
@@ -16,7 +16,10 @@ import datetime
16
16
  from abc import ABC, abstractmethod
17
17
  from typing import Optional, Union
18
18
 
19
+ from deprecated import deprecated
20
+
19
21
  import mlrun.alerts
22
+ import mlrun.common
20
23
  import mlrun.common.formatters
21
24
  import mlrun.common.runtimes.constants
22
25
  import mlrun.common.schemas
@@ -55,7 +58,13 @@ class RunDBInterface(ABC):
55
58
  pass
56
59
 
57
60
  @abstractmethod
58
- def read_run(self, uid, project="", iter=0):
61
+ def read_run(
62
+ self,
63
+ uid: str,
64
+ project: str = "",
65
+ iter: int = 0,
66
+ format_: mlrun.common.formatters.RunFormat = mlrun.common.formatters.RunFormat.full,
67
+ ):
59
68
  pass
60
69
 
61
70
  @abstractmethod
@@ -102,7 +111,16 @@ class RunDBInterface(ABC):
102
111
  pass
103
112
 
104
113
  @abstractmethod
105
- def read_artifact(self, key, tag="", iter=None, project="", tree=None, uid=None):
114
+ def read_artifact(
115
+ self,
116
+ key,
117
+ tag="",
118
+ iter=None,
119
+ project="",
120
+ tree=None,
121
+ uid=None,
122
+ format_: mlrun.common.formatters.ArtifactFormat = mlrun.common.formatters.ArtifactFormat.full,
123
+ ):
106
124
  pass
107
125
 
108
126
  @abstractmethod
@@ -119,6 +137,8 @@ class RunDBInterface(ABC):
119
137
  kind: str = None,
120
138
  category: Union[str, mlrun.common.schemas.ArtifactCategories] = None,
121
139
  tree: str = None,
140
+ format_: mlrun.common.formatters.ArtifactFormat = mlrun.common.formatters.ArtifactFormat.full,
141
+ limit: int = None,
122
142
  ):
123
143
  pass
124
144
 
@@ -301,6 +321,12 @@ class RunDBInterface(ABC):
301
321
  ) -> dict:
302
322
  pass
303
323
 
324
+ # TODO: remove in 1.9.0
325
+ @deprecated(
326
+ version="1.9.0",
327
+ reason="'list_features' will be removed in 1.9.0, use 'list_features_v2' instead",
328
+ category=FutureWarning,
329
+ )
304
330
  @abstractmethod
305
331
  def list_features(
306
332
  self,
@@ -312,6 +338,23 @@ class RunDBInterface(ABC):
312
338
  ) -> mlrun.common.schemas.FeaturesOutput:
313
339
  pass
314
340
 
341
+ @abstractmethod
342
+ def list_features_v2(
343
+ self,
344
+ project: str,
345
+ name: str = None,
346
+ tag: str = None,
347
+ entities: list[str] = None,
348
+ labels: list[str] = None,
349
+ ) -> mlrun.common.schemas.FeaturesOutputV2:
350
+ pass
351
+
352
+ # TODO: remove in 1.9.0
353
+ @deprecated(
354
+ version="1.9.0",
355
+ reason="'list_entities' will be removed in 1.9.0, use 'list_entities_v2' instead",
356
+ category=FutureWarning,
357
+ )
315
358
  @abstractmethod
316
359
  def list_entities(
317
360
  self,
@@ -322,6 +365,16 @@ class RunDBInterface(ABC):
322
365
  ) -> mlrun.common.schemas.EntitiesOutput:
323
366
  pass
324
367
 
368
+ @abstractmethod
369
+ def list_entities_v2(
370
+ self,
371
+ project: str,
372
+ name: str = None,
373
+ tag: str = None,
374
+ labels: list[str] = None,
375
+ ) -> mlrun.common.schemas.EntitiesOutputV2:
376
+ pass
377
+
325
378
  @abstractmethod
326
379
  def list_feature_sets(
327
380
  self,
@@ -837,11 +890,39 @@ class RunDBInterface(ABC):
837
890
  base_period: int = 10,
838
891
  image: str = "mlrun/mlrun",
839
892
  deploy_histogram_data_drift_app: bool = True,
893
+ rebuild_images: bool = False,
894
+ fetch_credentials_from_sys_config: bool = False,
840
895
  ) -> None:
841
896
  pass
842
897
 
898
+ @abstractmethod
899
+ def disable_model_monitoring(
900
+ self,
901
+ project: str,
902
+ delete_resources: bool = True,
903
+ delete_stream_function: bool = False,
904
+ delete_histogram_data_drift_app: bool = True,
905
+ delete_user_applications: bool = False,
906
+ user_application_list: list[str] = None,
907
+ ) -> bool:
908
+ pass
909
+
910
+ @abstractmethod
911
+ def delete_model_monitoring_function(
912
+ self, project: str, functions: list[str]
913
+ ) -> bool:
914
+ pass
915
+
843
916
  @abstractmethod
844
917
  def deploy_histogram_data_drift_app(
845
918
  self, project: str, image: str = "mlrun/mlrun"
846
919
  ) -> None:
847
920
  pass
921
+
922
+ @abstractmethod
923
+ def set_model_monitoring_credentials(
924
+ self,
925
+ project: str,
926
+ credentials: dict[str, str],
927
+ ) -> None:
928
+ pass