mlrun 1.6.4rc2__py3-none-any.whl → 1.7.0rc20__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 (291) hide show
  1. mlrun/__init__.py +11 -1
  2. mlrun/__main__.py +26 -112
  3. mlrun/alerts/__init__.py +15 -0
  4. mlrun/alerts/alert.py +144 -0
  5. mlrun/api/schemas/__init__.py +5 -4
  6. mlrun/artifacts/__init__.py +8 -3
  7. mlrun/artifacts/base.py +46 -257
  8. mlrun/artifacts/dataset.py +11 -192
  9. mlrun/artifacts/manager.py +47 -48
  10. mlrun/artifacts/model.py +31 -159
  11. mlrun/artifacts/plots.py +23 -380
  12. mlrun/common/constants.py +69 -0
  13. mlrun/common/db/sql_session.py +2 -3
  14. mlrun/common/formatters/__init__.py +19 -0
  15. mlrun/common/formatters/artifact.py +21 -0
  16. mlrun/common/formatters/base.py +78 -0
  17. mlrun/common/formatters/function.py +41 -0
  18. mlrun/common/formatters/pipeline.py +53 -0
  19. mlrun/common/formatters/project.py +51 -0
  20. mlrun/common/helpers.py +1 -2
  21. mlrun/common/model_monitoring/helpers.py +9 -5
  22. mlrun/{runtimes → common/runtimes}/constants.py +37 -9
  23. mlrun/common/schemas/__init__.py +24 -4
  24. mlrun/common/schemas/alert.py +203 -0
  25. mlrun/common/schemas/api_gateway.py +148 -0
  26. mlrun/common/schemas/artifact.py +18 -8
  27. mlrun/common/schemas/auth.py +11 -5
  28. mlrun/common/schemas/background_task.py +1 -1
  29. mlrun/common/schemas/client_spec.py +4 -1
  30. mlrun/common/schemas/feature_store.py +16 -16
  31. mlrun/common/schemas/frontend_spec.py +8 -7
  32. mlrun/common/schemas/function.py +5 -1
  33. mlrun/common/schemas/hub.py +11 -18
  34. mlrun/common/schemas/memory_reports.py +2 -2
  35. mlrun/common/schemas/model_monitoring/__init__.py +18 -3
  36. mlrun/common/schemas/model_monitoring/constants.py +83 -26
  37. mlrun/common/schemas/model_monitoring/grafana.py +13 -9
  38. mlrun/common/schemas/model_monitoring/model_endpoints.py +99 -16
  39. mlrun/common/schemas/notification.py +4 -4
  40. mlrun/common/schemas/object.py +2 -2
  41. mlrun/{runtimes/mpijob/v1alpha1.py → common/schemas/pagination.py} +10 -13
  42. mlrun/common/schemas/pipeline.py +1 -10
  43. mlrun/common/schemas/project.py +24 -23
  44. mlrun/common/schemas/runtime_resource.py +8 -12
  45. mlrun/common/schemas/schedule.py +3 -3
  46. mlrun/common/schemas/tag.py +1 -2
  47. mlrun/common/schemas/workflow.py +2 -2
  48. mlrun/common/types.py +7 -1
  49. mlrun/config.py +54 -17
  50. mlrun/data_types/to_pandas.py +10 -12
  51. mlrun/datastore/__init__.py +5 -8
  52. mlrun/datastore/alibaba_oss.py +130 -0
  53. mlrun/datastore/azure_blob.py +17 -5
  54. mlrun/datastore/base.py +62 -39
  55. mlrun/datastore/datastore.py +28 -9
  56. mlrun/datastore/datastore_profile.py +146 -20
  57. mlrun/datastore/filestore.py +0 -1
  58. mlrun/datastore/google_cloud_storage.py +6 -2
  59. mlrun/datastore/hdfs.py +56 -0
  60. mlrun/datastore/inmem.py +2 -2
  61. mlrun/datastore/redis.py +6 -2
  62. mlrun/datastore/s3.py +9 -0
  63. mlrun/datastore/snowflake_utils.py +43 -0
  64. mlrun/datastore/sources.py +201 -96
  65. mlrun/datastore/spark_utils.py +1 -2
  66. mlrun/datastore/store_resources.py +7 -7
  67. mlrun/datastore/targets.py +358 -104
  68. mlrun/datastore/utils.py +72 -58
  69. mlrun/datastore/v3io.py +5 -1
  70. mlrun/db/base.py +185 -35
  71. mlrun/db/factory.py +1 -1
  72. mlrun/db/httpdb.py +614 -179
  73. mlrun/db/nopdb.py +210 -26
  74. mlrun/errors.py +12 -1
  75. mlrun/execution.py +41 -24
  76. mlrun/feature_store/__init__.py +0 -2
  77. mlrun/feature_store/api.py +40 -72
  78. mlrun/feature_store/common.py +1 -1
  79. mlrun/feature_store/feature_set.py +76 -55
  80. mlrun/feature_store/feature_vector.py +28 -30
  81. mlrun/feature_store/ingestion.py +7 -6
  82. mlrun/feature_store/retrieval/base.py +16 -11
  83. mlrun/feature_store/retrieval/conversion.py +11 -13
  84. mlrun/feature_store/retrieval/dask_merger.py +2 -0
  85. mlrun/feature_store/retrieval/job.py +9 -3
  86. mlrun/feature_store/retrieval/local_merger.py +2 -0
  87. mlrun/feature_store/retrieval/spark_merger.py +34 -24
  88. mlrun/feature_store/steps.py +37 -34
  89. mlrun/features.py +9 -20
  90. mlrun/frameworks/_common/artifacts_library.py +9 -9
  91. mlrun/frameworks/_common/mlrun_interface.py +5 -5
  92. mlrun/frameworks/_common/model_handler.py +48 -48
  93. mlrun/frameworks/_common/plan.py +2 -3
  94. mlrun/frameworks/_common/producer.py +3 -4
  95. mlrun/frameworks/_common/utils.py +5 -5
  96. mlrun/frameworks/_dl_common/loggers/logger.py +6 -7
  97. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +9 -9
  98. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +23 -47
  99. mlrun/frameworks/_ml_common/artifacts_library.py +1 -2
  100. mlrun/frameworks/_ml_common/loggers/logger.py +3 -4
  101. mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +4 -5
  102. mlrun/frameworks/_ml_common/model_handler.py +24 -24
  103. mlrun/frameworks/_ml_common/pkl_model_server.py +2 -2
  104. mlrun/frameworks/_ml_common/plan.py +1 -1
  105. mlrun/frameworks/_ml_common/plans/calibration_curve_plan.py +2 -3
  106. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +2 -3
  107. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  108. mlrun/frameworks/_ml_common/plans/feature_importance_plan.py +3 -3
  109. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  110. mlrun/frameworks/_ml_common/utils.py +4 -4
  111. mlrun/frameworks/auto_mlrun/auto_mlrun.py +9 -9
  112. mlrun/frameworks/huggingface/model_server.py +4 -4
  113. mlrun/frameworks/lgbm/__init__.py +33 -33
  114. mlrun/frameworks/lgbm/callbacks/callback.py +2 -4
  115. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -5
  116. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -5
  117. mlrun/frameworks/lgbm/mlrun_interfaces/booster_mlrun_interface.py +1 -3
  118. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +6 -6
  119. mlrun/frameworks/lgbm/model_handler.py +10 -10
  120. mlrun/frameworks/lgbm/model_server.py +6 -6
  121. mlrun/frameworks/lgbm/utils.py +5 -5
  122. mlrun/frameworks/onnx/dataset.py +8 -8
  123. mlrun/frameworks/onnx/mlrun_interface.py +3 -3
  124. mlrun/frameworks/onnx/model_handler.py +6 -6
  125. mlrun/frameworks/onnx/model_server.py +7 -7
  126. mlrun/frameworks/parallel_coordinates.py +4 -3
  127. mlrun/frameworks/pytorch/__init__.py +18 -18
  128. mlrun/frameworks/pytorch/callbacks/callback.py +4 -5
  129. mlrun/frameworks/pytorch/callbacks/logging_callback.py +17 -17
  130. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +11 -11
  131. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +23 -29
  132. mlrun/frameworks/pytorch/callbacks_handler.py +38 -38
  133. mlrun/frameworks/pytorch/mlrun_interface.py +20 -20
  134. mlrun/frameworks/pytorch/model_handler.py +17 -17
  135. mlrun/frameworks/pytorch/model_server.py +7 -7
  136. mlrun/frameworks/sklearn/__init__.py +13 -13
  137. mlrun/frameworks/sklearn/estimator.py +4 -4
  138. mlrun/frameworks/sklearn/metrics_library.py +14 -14
  139. mlrun/frameworks/sklearn/mlrun_interface.py +3 -6
  140. mlrun/frameworks/sklearn/model_handler.py +2 -2
  141. mlrun/frameworks/tf_keras/__init__.py +10 -7
  142. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +15 -15
  143. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +11 -11
  144. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +19 -23
  145. mlrun/frameworks/tf_keras/mlrun_interface.py +9 -11
  146. mlrun/frameworks/tf_keras/model_handler.py +14 -14
  147. mlrun/frameworks/tf_keras/model_server.py +6 -6
  148. mlrun/frameworks/xgboost/__init__.py +13 -13
  149. mlrun/frameworks/xgboost/model_handler.py +6 -6
  150. mlrun/k8s_utils.py +14 -16
  151. mlrun/launcher/__init__.py +1 -1
  152. mlrun/launcher/base.py +16 -15
  153. mlrun/launcher/client.py +8 -6
  154. mlrun/launcher/factory.py +1 -1
  155. mlrun/launcher/local.py +17 -11
  156. mlrun/launcher/remote.py +16 -10
  157. mlrun/lists.py +7 -6
  158. mlrun/model.py +238 -73
  159. mlrun/model_monitoring/__init__.py +1 -1
  160. mlrun/model_monitoring/api.py +138 -315
  161. mlrun/model_monitoring/application.py +5 -296
  162. mlrun/model_monitoring/applications/__init__.py +24 -0
  163. mlrun/model_monitoring/applications/_application_steps.py +157 -0
  164. mlrun/model_monitoring/applications/base.py +282 -0
  165. mlrun/model_monitoring/applications/context.py +214 -0
  166. mlrun/model_monitoring/applications/evidently_base.py +211 -0
  167. mlrun/model_monitoring/applications/histogram_data_drift.py +349 -0
  168. mlrun/model_monitoring/applications/results.py +99 -0
  169. mlrun/model_monitoring/controller.py +104 -84
  170. mlrun/model_monitoring/controller_handler.py +13 -5
  171. mlrun/model_monitoring/db/__init__.py +18 -0
  172. mlrun/model_monitoring/{stores → db/stores}/__init__.py +43 -36
  173. mlrun/model_monitoring/db/stores/base/__init__.py +15 -0
  174. mlrun/model_monitoring/{stores/model_endpoint_store.py → db/stores/base/store.py} +64 -40
  175. mlrun/model_monitoring/db/stores/sqldb/__init__.py +13 -0
  176. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +71 -0
  177. mlrun/model_monitoring/{stores → db/stores/sqldb}/models/base.py +109 -5
  178. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +88 -0
  179. mlrun/model_monitoring/{stores/models/mysql.py → db/stores/sqldb/models/sqlite.py} +19 -13
  180. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +684 -0
  181. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +13 -0
  182. mlrun/model_monitoring/{stores/kv_model_endpoint_store.py → db/stores/v3io_kv/kv_store.py} +310 -165
  183. mlrun/model_monitoring/db/tsdb/__init__.py +100 -0
  184. mlrun/model_monitoring/db/tsdb/base.py +329 -0
  185. mlrun/model_monitoring/db/tsdb/helpers.py +30 -0
  186. mlrun/model_monitoring/db/tsdb/tdengine/__init__.py +15 -0
  187. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +240 -0
  188. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +45 -0
  189. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +397 -0
  190. mlrun/model_monitoring/db/tsdb/v3io/__init__.py +15 -0
  191. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +117 -0
  192. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +630 -0
  193. mlrun/model_monitoring/evidently_application.py +6 -118
  194. mlrun/model_monitoring/features_drift_table.py +134 -106
  195. mlrun/model_monitoring/helpers.py +127 -28
  196. mlrun/model_monitoring/metrics/__init__.py +13 -0
  197. mlrun/model_monitoring/metrics/histogram_distance.py +127 -0
  198. mlrun/model_monitoring/model_endpoint.py +3 -2
  199. mlrun/model_monitoring/prometheus.py +1 -4
  200. mlrun/model_monitoring/stream_processing.py +62 -231
  201. mlrun/model_monitoring/tracking_policy.py +9 -2
  202. mlrun/model_monitoring/writer.py +152 -124
  203. mlrun/package/__init__.py +6 -6
  204. mlrun/package/context_handler.py +5 -5
  205. mlrun/package/packager.py +7 -7
  206. mlrun/package/packagers/default_packager.py +6 -6
  207. mlrun/package/packagers/numpy_packagers.py +15 -15
  208. mlrun/package/packagers/pandas_packagers.py +5 -5
  209. mlrun/package/packagers/python_standard_library_packagers.py +10 -10
  210. mlrun/package/packagers_manager.py +19 -23
  211. mlrun/package/utils/_formatter.py +6 -6
  212. mlrun/package/utils/_pickler.py +2 -2
  213. mlrun/package/utils/_supported_format.py +4 -4
  214. mlrun/package/utils/log_hint_utils.py +2 -2
  215. mlrun/package/utils/type_hint_utils.py +4 -9
  216. mlrun/platforms/__init__.py +11 -10
  217. mlrun/platforms/iguazio.py +24 -203
  218. mlrun/projects/operations.py +35 -21
  219. mlrun/projects/pipelines.py +68 -99
  220. mlrun/projects/project.py +830 -266
  221. mlrun/render.py +3 -11
  222. mlrun/run.py +162 -166
  223. mlrun/runtimes/__init__.py +62 -7
  224. mlrun/runtimes/base.py +39 -32
  225. mlrun/runtimes/daskjob.py +8 -8
  226. mlrun/runtimes/databricks_job/databricks_cancel_task.py +1 -1
  227. mlrun/runtimes/databricks_job/databricks_runtime.py +7 -7
  228. mlrun/runtimes/databricks_job/databricks_wrapper.py +1 -1
  229. mlrun/runtimes/funcdoc.py +0 -28
  230. mlrun/runtimes/function_reference.py +1 -1
  231. mlrun/runtimes/kubejob.py +28 -122
  232. mlrun/runtimes/local.py +6 -3
  233. mlrun/runtimes/mpijob/__init__.py +0 -20
  234. mlrun/runtimes/mpijob/abstract.py +9 -10
  235. mlrun/runtimes/mpijob/v1.py +1 -1
  236. mlrun/{model_monitoring/stores/models/sqlite.py → runtimes/nuclio/__init__.py} +7 -9
  237. mlrun/runtimes/nuclio/api_gateway.py +709 -0
  238. mlrun/runtimes/nuclio/application/__init__.py +15 -0
  239. mlrun/runtimes/nuclio/application/application.py +523 -0
  240. mlrun/runtimes/nuclio/application/reverse_proxy.go +95 -0
  241. mlrun/runtimes/{function.py → nuclio/function.py} +112 -73
  242. mlrun/runtimes/{nuclio.py → nuclio/nuclio.py} +6 -6
  243. mlrun/runtimes/{serving.py → nuclio/serving.py} +45 -51
  244. mlrun/runtimes/pod.py +286 -88
  245. mlrun/runtimes/remotesparkjob.py +2 -2
  246. mlrun/runtimes/sparkjob/spark3job.py +51 -34
  247. mlrun/runtimes/utils.py +7 -75
  248. mlrun/secrets.py +9 -5
  249. mlrun/serving/remote.py +2 -7
  250. mlrun/serving/routers.py +13 -10
  251. mlrun/serving/server.py +22 -26
  252. mlrun/serving/states.py +99 -25
  253. mlrun/serving/utils.py +3 -3
  254. mlrun/serving/v1_serving.py +6 -7
  255. mlrun/serving/v2_serving.py +59 -20
  256. mlrun/track/tracker.py +2 -1
  257. mlrun/track/tracker_manager.py +3 -3
  258. mlrun/track/trackers/mlflow_tracker.py +1 -2
  259. mlrun/utils/async_http.py +5 -7
  260. mlrun/utils/azure_vault.py +1 -1
  261. mlrun/utils/clones.py +1 -2
  262. mlrun/utils/condition_evaluator.py +3 -3
  263. mlrun/utils/db.py +3 -3
  264. mlrun/utils/helpers.py +183 -197
  265. mlrun/utils/http.py +2 -5
  266. mlrun/utils/logger.py +76 -14
  267. mlrun/utils/notifications/notification/__init__.py +17 -12
  268. mlrun/utils/notifications/notification/base.py +14 -2
  269. mlrun/utils/notifications/notification/console.py +2 -0
  270. mlrun/utils/notifications/notification/git.py +3 -1
  271. mlrun/utils/notifications/notification/ipython.py +3 -1
  272. mlrun/utils/notifications/notification/slack.py +101 -21
  273. mlrun/utils/notifications/notification/webhook.py +11 -1
  274. mlrun/utils/notifications/notification_pusher.py +155 -30
  275. mlrun/utils/retryer.py +208 -0
  276. mlrun/utils/singleton.py +1 -1
  277. mlrun/utils/v3io_clients.py +2 -4
  278. mlrun/utils/version/version.json +2 -2
  279. mlrun/utils/version/version.py +2 -6
  280. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/METADATA +31 -19
  281. mlrun-1.7.0rc20.dist-info/RECORD +353 -0
  282. mlrun/kfpops.py +0 -868
  283. mlrun/model_monitoring/batch.py +0 -1095
  284. mlrun/model_monitoring/stores/models/__init__.py +0 -27
  285. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -384
  286. mlrun/platforms/other.py +0 -306
  287. mlrun-1.6.4rc2.dist-info/RECORD +0 -314
  288. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/LICENSE +0 -0
  289. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/WHEEL +0 -0
  290. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/entry_points.txt +0 -0
  291. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/top_level.txt +0 -0
mlrun/datastore/utils.py CHANGED
@@ -12,10 +12,12 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
+ import math
15
16
  import tarfile
16
17
  import tempfile
17
18
  import typing
18
- from urllib.parse import parse_qs, urlparse, urlunparse
19
+ import warnings
20
+ from urllib.parse import parse_qs, urlparse
19
21
 
20
22
  import pandas as pd
21
23
  import semver
@@ -23,73 +25,29 @@ import semver
23
25
  import mlrun.datastore
24
26
 
25
27
 
26
- def store_path_to_spark(path, spark_options=None):
27
- schemas = ["redis://", "rediss://", "ds://"]
28
- if any(path.startswith(schema) for schema in schemas):
29
- url = urlparse(path)
30
- if url.path:
31
- path = url.path
32
- elif path.startswith("gcs://"):
33
- path = "gs:" + path[len("gcs:") :]
34
- elif path.startswith("v3io:///"):
35
- path = "v3io:" + path[len("v3io:/") :]
36
- elif path.startswith("az://"):
37
- account_key = None
38
- path = "wasbs:" + path[len("az:") :]
39
- prefix = "spark.hadoop.fs.azure.account.key."
40
- if spark_options:
41
- for key in spark_options:
42
- if key.startswith(prefix):
43
- account_key = key[len(prefix) :]
44
- break
45
- if account_key:
46
- # transfer "wasb://basket/some/path" to wasb://basket@account_key.blob.core.windows.net/some/path
47
- parsed_url = urlparse(path)
48
- new_netloc = f"{parsed_url.hostname}@{account_key}"
49
- path = urlunparse(
50
- (
51
- parsed_url.scheme,
52
- new_netloc,
53
- parsed_url.path,
54
- parsed_url.params,
55
- parsed_url.query,
56
- parsed_url.fragment,
57
- )
58
- )
59
- elif path.startswith("s3://"):
60
- if path.startswith("s3:///"):
61
- # 's3:///' not supported since mlrun 0.9.0 should use s3:// instead
62
- from mlrun.errors import MLRunInvalidArgumentError
63
-
64
- valid_path = "s3:" + path[len("s3:/") :]
65
- raise MLRunInvalidArgumentError(
66
- f"'s3:///' is not supported, try using 's3://' instead.\nE.g: '{valid_path}'"
67
- )
68
- else:
69
- path = "s3a:" + path[len("s3:") :]
70
- return path
71
-
72
-
73
28
  def parse_kafka_url(
74
- url: str, bootstrap_servers: typing.List = None
75
- ) -> typing.Tuple[str, typing.List]:
29
+ url: str, brokers: typing.Union[list, str] = None
30
+ ) -> tuple[str, list]:
76
31
  """Generating Kafka topic and adjusting a list of bootstrap servers.
77
32
 
78
33
  :param url: URL path to parse using urllib.parse.urlparse.
79
- :param bootstrap_servers: List of bootstrap servers for the kafka brokers.
34
+ :param brokers: List of kafka brokers.
80
35
 
81
36
  :return: A tuple of:
82
37
  [0] = Kafka topic value
83
38
  [1] = List of bootstrap servers
84
39
  """
85
- bootstrap_servers = bootstrap_servers or []
40
+ brokers = brokers or []
41
+
42
+ if isinstance(brokers, str):
43
+ brokers = brokers.split(",")
86
44
 
87
45
  # Parse the provided URL into six components according to the general structure of a URL
88
46
  url = urlparse(url)
89
47
 
90
48
  # Add the network location to the bootstrap servers list
91
49
  if url.netloc:
92
- bootstrap_servers = [url.netloc] + bootstrap_servers
50
+ brokers = [url.netloc] + brokers
93
51
 
94
52
  # Get the topic value from the parsed url
95
53
  query_dict = parse_qs(url.query)
@@ -98,7 +56,7 @@ def parse_kafka_url(
98
56
  else:
99
57
  topic = url.path
100
58
  topic = topic.lstrip("/")
101
- return topic, bootstrap_servers
59
+ return topic, brokers
102
60
 
103
61
 
104
62
  def upload_tarball(source_dir, target, secrets=None):
@@ -107,7 +65,7 @@ def upload_tarball(source_dir, target, secrets=None):
107
65
  with tarfile.open(mode="w:gz", fileobj=temp_fh) as tar:
108
66
  tar.add(source_dir, arcname="")
109
67
  stores = mlrun.datastore.store_manager.set(secrets)
110
- datastore, subpath = stores.get_or_create_store(target)
68
+ datastore, subpath, url = stores.get_or_create_store(target)
111
69
  datastore.upload(subpath, temp_fh.name)
112
70
 
113
71
 
@@ -157,7 +115,7 @@ def _execute_time_filter(
157
115
 
158
116
  def select_columns_from_df(
159
117
  df: typing.Union[pd.DataFrame, typing.Iterator[pd.DataFrame]],
160
- columns: typing.List[str],
118
+ columns: list[str],
161
119
  ) -> typing.Union[pd.DataFrame, typing.Iterator[pd.DataFrame]]:
162
120
  if not columns:
163
121
  return df
@@ -169,7 +127,7 @@ def select_columns_from_df(
169
127
 
170
128
  def select_columns_generator(
171
129
  dfs: typing.Union[pd.DataFrame, typing.Iterator[pd.DataFrame]],
172
- columns: typing.List[str],
130
+ columns: list[str],
173
131
  ) -> typing.Iterator[pd.DataFrame]:
174
132
  for df in dfs:
175
133
  yield df[columns]
@@ -179,7 +137,7 @@ def _generate_sql_query_with_time_filter(
179
137
  table_name: str,
180
138
  engine: "sqlalchemy.engine.Engine", # noqa: F821,
181
139
  time_column: str,
182
- parse_dates: typing.List[str],
140
+ parse_dates: list[str],
183
141
  start_time: pd.Timestamp,
184
142
  end_time: pd.Timestamp,
185
143
  ):
@@ -208,3 +166,59 @@ def _generate_sql_query_with_time_filter(
208
166
  query = query.filter(getattr(table.c, time_column) <= end_time)
209
167
 
210
168
  return query, parse_dates
169
+
170
+
171
+ def get_kafka_brokers_from_dict(options: dict, pop=False) -> typing.Optional[str]:
172
+ get_or_pop = options.pop if pop else options.get
173
+ kafka_brokers = get_or_pop("kafka_brokers", None)
174
+ if kafka_brokers:
175
+ return kafka_brokers
176
+ kafka_bootstrap_servers = get_or_pop("kafka_bootstrap_servers", None)
177
+ if kafka_bootstrap_servers:
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.",
181
+ FutureWarning,
182
+ )
183
+ return kafka_bootstrap_servers
184
+
185
+
186
+ def transform_list_filters_to_tuple(additional_filters):
187
+ tuple_filters = []
188
+ if not additional_filters:
189
+ return tuple_filters
190
+ validate_additional_filters(additional_filters)
191
+ for additional_filter in additional_filters:
192
+ tuple_filters.append(tuple(additional_filter))
193
+ return tuple_filters
194
+
195
+
196
+ def validate_additional_filters(additional_filters):
197
+ nan_error_message = "using NaN in additional_filters is not supported"
198
+ if additional_filters in [None, [], ()]:
199
+ return
200
+ for filter_tuple in additional_filters:
201
+ if filter_tuple == () or filter_tuple == []:
202
+ continue
203
+ if not isinstance(filter_tuple, (list, tuple)):
204
+ raise mlrun.errors.MLRunInvalidArgumentError(
205
+ f"mlrun supports additional_filters only as a list of tuples."
206
+ f" Current additional_filters: {additional_filters}"
207
+ )
208
+ if isinstance(filter_tuple[0], (list, tuple)):
209
+ raise mlrun.errors.MLRunInvalidArgumentError(
210
+ f"additional_filters does not support nested list inside filter tuples except in -in- logic."
211
+ f" Current filter_tuple: {filter_tuple}."
212
+ )
213
+ if len(filter_tuple) != 3:
214
+ raise mlrun.errors.MLRunInvalidArgumentError(
215
+ f"illegal filter tuple length, {filter_tuple} in additional filters:"
216
+ f" {additional_filters}"
217
+ )
218
+ col_name, op, value = filter_tuple
219
+ if isinstance(value, float) and math.isnan(value):
220
+ raise mlrun.errors.MLRunInvalidArgumentError(nan_error_message)
221
+ elif isinstance(value, (list, tuple)):
222
+ for sub_value in value:
223
+ if isinstance(sub_value, float) and math.isnan(sub_value):
224
+ raise mlrun.errors.MLRunInvalidArgumentError(nan_error_message)
mlrun/datastore/v3io.py CHANGED
@@ -29,7 +29,7 @@ from .base import (
29
29
  )
30
30
 
31
31
  V3IO_LOCAL_ROOT = "v3io"
32
- V3IO_DEFAULT_UPLOAD_CHUNK_SIZE = 1024 * 1024 * 100
32
+ V3IO_DEFAULT_UPLOAD_CHUNK_SIZE = 1024 * 1024 * 10
33
33
 
34
34
 
35
35
  class V3ioStore(DataStore):
@@ -77,6 +77,10 @@ class V3ioStore(DataStore):
77
77
  schema = "https" if self.secure else "http"
78
78
  return f"{schema}://{self.endpoint}"
79
79
 
80
+ @property
81
+ def spark_url(self):
82
+ return "v3io:/"
83
+
80
84
  @property
81
85
  def filesystem(self):
82
86
  """return fsspec file system object, if supported"""
mlrun/db/base.py CHANGED
@@ -13,12 +13,14 @@
13
13
  # limitations under the License.
14
14
 
15
15
  import datetime
16
- import typing
17
16
  from abc import ABC, abstractmethod
18
- from typing import List, Optional, Union
17
+ from typing import Optional, Union
19
18
 
19
+ import mlrun.alerts
20
+ import mlrun.common.formatters
21
+ import mlrun.common.runtimes.constants
20
22
  import mlrun.common.schemas
21
- import mlrun.model_monitoring.model_endpoint
23
+ import mlrun.model_monitoring
22
24
 
23
25
 
24
26
  class RunDBError(Exception):
@@ -60,10 +62,13 @@ class RunDBInterface(ABC):
60
62
  def list_runs(
61
63
  self,
62
64
  name: Optional[str] = None,
63
- uid: Optional[Union[str, List[str]]] = None,
65
+ uid: Optional[Union[str, list[str]]] = None,
64
66
  project: Optional[str] = None,
65
- labels: Optional[Union[str, List[str]]] = None,
66
- state: Optional[str] = None,
67
+ labels: Optional[Union[str, list[str]]] = None,
68
+ state: Optional[
69
+ mlrun.common.runtimes.constants.RunStates
70
+ ] = None, # Backward compatibility
71
+ states: Optional[list[mlrun.common.runtimes.constants.RunStates]] = None,
67
72
  sort: bool = True,
68
73
  last: int = 0,
69
74
  iter: bool = False,
@@ -118,7 +123,18 @@ class RunDBInterface(ABC):
118
123
  pass
119
124
 
120
125
  @abstractmethod
121
- def del_artifact(self, key, tag="", project="", tree=None, uid=None):
126
+ def del_artifact(
127
+ self,
128
+ key,
129
+ tag="",
130
+ project="",
131
+ tree=None,
132
+ uid=None,
133
+ deletion_strategy: mlrun.common.schemas.artifact.ArtifactsDeletionStrategies = (
134
+ mlrun.common.schemas.artifact.ArtifactsDeletionStrategies.metadata_only
135
+ ),
136
+ secrets: dict = None,
137
+ ):
122
138
  pass
123
139
 
124
140
  @abstractmethod
@@ -252,8 +268,8 @@ class RunDBInterface(ABC):
252
268
  def list_projects(
253
269
  self,
254
270
  owner: str = None,
255
- format_: mlrun.common.schemas.ProjectsFormat = mlrun.common.schemas.ProjectsFormat.name_only,
256
- labels: List[str] = None,
271
+ format_: mlrun.common.formatters.ProjectFormat = mlrun.common.formatters.ProjectFormat.name_only,
272
+ labels: list[str] = None,
257
273
  state: mlrun.common.schemas.ProjectState = None,
258
274
  ) -> mlrun.common.schemas.ProjectsOutput:
259
275
  pass
@@ -291,8 +307,8 @@ class RunDBInterface(ABC):
291
307
  project: str,
292
308
  name: str = None,
293
309
  tag: str = None,
294
- entities: List[str] = None,
295
- labels: List[str] = None,
310
+ entities: list[str] = None,
311
+ labels: list[str] = None,
296
312
  ) -> mlrun.common.schemas.FeaturesOutput:
297
313
  pass
298
314
 
@@ -302,7 +318,7 @@ class RunDBInterface(ABC):
302
318
  project: str,
303
319
  name: str = None,
304
320
  tag: str = None,
305
- labels: List[str] = None,
321
+ labels: list[str] = None,
306
322
  ) -> mlrun.common.schemas.EntitiesOutput:
307
323
  pass
308
324
 
@@ -313,9 +329,9 @@ class RunDBInterface(ABC):
313
329
  name: str = None,
314
330
  tag: str = None,
315
331
  state: str = None,
316
- entities: List[str] = None,
317
- features: List[str] = None,
318
- labels: List[str] = None,
332
+ entities: list[str] = None,
333
+ features: list[str] = None,
334
+ labels: list[str] = None,
319
335
  partition_by: Union[
320
336
  mlrun.common.schemas.FeatureStorePartitionByField, str
321
337
  ] = None,
@@ -324,7 +340,7 @@ class RunDBInterface(ABC):
324
340
  partition_order: Union[
325
341
  mlrun.common.schemas.OrderType, str
326
342
  ] = mlrun.common.schemas.OrderType.desc,
327
- ) -> List[dict]:
343
+ ) -> list[dict]:
328
344
  pass
329
345
 
330
346
  @abstractmethod
@@ -379,7 +395,7 @@ class RunDBInterface(ABC):
379
395
  name: str = None,
380
396
  tag: str = None,
381
397
  state: str = None,
382
- labels: List[str] = None,
398
+ labels: list[str] = None,
383
399
  partition_by: Union[
384
400
  mlrun.common.schemas.FeatureStorePartitionByField, str
385
401
  ] = None,
@@ -388,7 +404,7 @@ class RunDBInterface(ABC):
388
404
  partition_order: Union[
389
405
  mlrun.common.schemas.OrderType, str
390
406
  ] = mlrun.common.schemas.OrderType.desc,
391
- ) -> List[dict]:
407
+ ) -> list[dict]:
392
408
  pass
393
409
 
394
410
  @abstractmethod
@@ -428,8 +444,8 @@ class RunDBInterface(ABC):
428
444
  namespace: str = None,
429
445
  timeout: int = 30,
430
446
  format_: Union[
431
- str, mlrun.common.schemas.PipelinesFormat
432
- ] = mlrun.common.schemas.PipelinesFormat.summary,
447
+ str, mlrun.common.formatters.PipelineFormat
448
+ ] = mlrun.common.formatters.PipelineFormat.summary,
433
449
  project: str = None,
434
450
  ):
435
451
  pass
@@ -443,8 +459,8 @@ class RunDBInterface(ABC):
443
459
  page_token: str = "",
444
460
  filter_: str = "",
445
461
  format_: Union[
446
- str, mlrun.common.schemas.PipelinesFormat
447
- ] = mlrun.common.schemas.PipelinesFormat.metadata_only,
462
+ str, mlrun.common.formatters.PipelineFormat
463
+ ] = mlrun.common.formatters.PipelineFormat.metadata_only,
448
464
  page_size: int = None,
449
465
  ) -> mlrun.common.schemas.PipelinesOutput:
450
466
  pass
@@ -468,7 +484,7 @@ class RunDBInterface(ABC):
468
484
  provider: Union[
469
485
  str, mlrun.common.schemas.SecretProviderName
470
486
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
471
- secrets: List[str] = None,
487
+ secrets: list[str] = None,
472
488
  ) -> mlrun.common.schemas.SecretsData:
473
489
  pass
474
490
 
@@ -490,7 +506,7 @@ class RunDBInterface(ABC):
490
506
  provider: Union[
491
507
  str, mlrun.common.schemas.SecretProviderName
492
508
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
493
- secrets: List[str] = None,
509
+ secrets: list[str] = None,
494
510
  ):
495
511
  pass
496
512
 
@@ -510,9 +526,7 @@ class RunDBInterface(ABC):
510
526
  self,
511
527
  project: str,
512
528
  endpoint_id: str,
513
- model_endpoint: Union[
514
- mlrun.model_monitoring.model_endpoint.ModelEndpoint, dict
515
- ],
529
+ model_endpoint: Union[mlrun.model_monitoring.ModelEndpoint, dict],
516
530
  ):
517
531
  pass
518
532
 
@@ -530,10 +544,10 @@ class RunDBInterface(ABC):
530
544
  project: str,
531
545
  model: Optional[str] = None,
532
546
  function: Optional[str] = None,
533
- labels: List[str] = None,
547
+ labels: list[str] = None,
534
548
  start: str = "now-1h",
535
549
  end: str = "now",
536
- metrics: Optional[List[str]] = None,
550
+ metrics: Optional[list[str]] = None,
537
551
  ):
538
552
  pass
539
553
 
@@ -544,9 +558,9 @@ class RunDBInterface(ABC):
544
558
  endpoint_id: str,
545
559
  start: Optional[str] = None,
546
560
  end: Optional[str] = None,
547
- metrics: Optional[List[str]] = None,
561
+ metrics: Optional[list[str]] = None,
548
562
  features: bool = False,
549
- ):
563
+ ) -> mlrun.model_monitoring.ModelEndpoint:
550
564
  pass
551
565
 
552
566
  @abstractmethod
@@ -617,6 +631,86 @@ class RunDBInterface(ABC):
617
631
  ):
618
632
  pass
619
633
 
634
+ @abstractmethod
635
+ def store_api_gateway(
636
+ self,
637
+ api_gateway: mlrun.common.schemas.APIGateway,
638
+ project: str = None,
639
+ ):
640
+ pass
641
+
642
+ @abstractmethod
643
+ def list_api_gateways(self, project=None) -> mlrun.common.schemas.APIGatewaysOutput:
644
+ pass
645
+
646
+ @abstractmethod
647
+ def get_api_gateway(self, name, project=None) -> mlrun.common.schemas.APIGateway:
648
+ pass
649
+
650
+ @abstractmethod
651
+ def delete_api_gateway(self, name, project=None):
652
+ pass
653
+
654
+ @abstractmethod
655
+ def remote_builder(
656
+ self,
657
+ func: "mlrun.runtimes.BaseRuntime",
658
+ with_mlrun: bool,
659
+ mlrun_version_specifier: Optional[str] = None,
660
+ skip_deployed: bool = False,
661
+ builder_env: Optional[dict] = None,
662
+ force_build: bool = False,
663
+ ):
664
+ pass
665
+
666
+ @abstractmethod
667
+ def deploy_nuclio_function(
668
+ self,
669
+ func: "mlrun.runtimes.RemoteRuntime",
670
+ builder_env: Optional[dict] = None,
671
+ ):
672
+ pass
673
+
674
+ @abstractmethod
675
+ def generate_event(
676
+ self, name: str, event_data: Union[dict, mlrun.common.schemas.Event], project=""
677
+ ):
678
+ pass
679
+
680
+ @abstractmethod
681
+ def store_alert_config(
682
+ self,
683
+ alert_name: str,
684
+ alert_data: Union[dict, mlrun.alerts.alert.AlertConfig],
685
+ project="",
686
+ ):
687
+ pass
688
+
689
+ @abstractmethod
690
+ def get_alert_config(self, alert_name: str, project=""):
691
+ pass
692
+
693
+ @abstractmethod
694
+ def list_alerts_configs(self, project=""):
695
+ pass
696
+
697
+ @abstractmethod
698
+ def delete_alert_config(self, alert_name: str, project=""):
699
+ pass
700
+
701
+ @abstractmethod
702
+ def reset_alert_config(self, alert_name: str, project=""):
703
+ pass
704
+
705
+ @abstractmethod
706
+ def get_alert_template(self, template_name: str):
707
+ pass
708
+
709
+ @abstractmethod
710
+ def list_alert_templates(self):
711
+ pass
712
+
713
+ @abstractmethod
620
714
  def get_builder_status(
621
715
  self,
622
716
  func: "mlrun.runtimes.BaseRuntime",
@@ -627,57 +721,88 @@ class RunDBInterface(ABC):
627
721
  ):
628
722
  pass
629
723
 
724
+ @abstractmethod
725
+ def get_nuclio_deploy_status(
726
+ self,
727
+ func: "mlrun.runtimes.RemoteRuntime",
728
+ last_log_timestamp: float = 0.0,
729
+ verbose: bool = False,
730
+ ):
731
+ pass
732
+
733
+ @abstractmethod
630
734
  def set_run_notifications(
631
735
  self,
632
736
  project: str,
633
- runs: typing.List[mlrun.model.RunObject],
634
- notifications: typing.List[mlrun.model.Notification],
737
+ runs: list[mlrun.model.RunObject],
738
+ notifications: list[mlrun.model.Notification],
635
739
  ):
636
740
  pass
637
741
 
742
+ @abstractmethod
638
743
  def store_run_notifications(
639
744
  self,
640
- notification_objects: typing.List[mlrun.model.Notification],
745
+ notification_objects: list[mlrun.model.Notification],
641
746
  run_uid: str,
642
747
  project: str = None,
643
748
  mask_params: bool = True,
644
749
  ):
645
750
  pass
646
751
 
752
+ @abstractmethod
647
753
  def get_log_size(self, uid, project=""):
648
754
  pass
649
755
 
756
+ @abstractmethod
757
+ def store_alert_notifications(
758
+ self,
759
+ session,
760
+ notification_objects: list[mlrun.model.Notification],
761
+ alert_id: str,
762
+ project: str,
763
+ mask_params: bool = True,
764
+ ):
765
+ pass
766
+
767
+ @abstractmethod
650
768
  def watch_log(self, uid, project="", watch=True, offset=0):
651
769
  pass
652
770
 
771
+ @abstractmethod
653
772
  def get_datastore_profile(
654
773
  self, name: str, project: str
655
774
  ) -> Optional[mlrun.common.schemas.DatastoreProfile]:
656
775
  pass
657
776
 
777
+ @abstractmethod
658
778
  def delete_datastore_profile(
659
779
  self, name: str, project: str
660
780
  ) -> mlrun.common.schemas.DatastoreProfile:
661
781
  pass
662
782
 
783
+ @abstractmethod
663
784
  def list_datastore_profiles(
664
785
  self, project: str
665
- ) -> List[mlrun.common.schemas.DatastoreProfile]:
786
+ ) -> list[mlrun.common.schemas.DatastoreProfile]:
666
787
  pass
667
788
 
789
+ @abstractmethod
668
790
  def store_datastore_profile(
669
791
  self, profile: mlrun.common.schemas.DatastoreProfile, project: str
670
792
  ):
671
793
  pass
672
794
 
795
+ @abstractmethod
673
796
  def function_status(self, project, name, kind, selector):
674
797
  pass
675
798
 
799
+ @abstractmethod
676
800
  def start_function(
677
801
  self, func_url: str = None, function: "mlrun.runtimes.BaseRuntime" = None
678
802
  ):
679
803
  pass
680
804
 
805
+ @abstractmethod
681
806
  def submit_workflow(
682
807
  self,
683
808
  project: str,
@@ -695,3 +820,28 @@ class RunDBInterface(ABC):
695
820
  notifications: list["mlrun.model.Notification"] = None,
696
821
  ) -> "mlrun.common.schemas.WorkflowResponse":
697
822
  pass
823
+
824
+ @abstractmethod
825
+ def update_model_monitoring_controller(
826
+ self,
827
+ project: str,
828
+ base_period: int = 10,
829
+ image: str = "mlrun/mlrun",
830
+ ) -> None:
831
+ pass
832
+
833
+ @abstractmethod
834
+ def enable_model_monitoring(
835
+ self,
836
+ project: str,
837
+ base_period: int = 10,
838
+ image: str = "mlrun/mlrun",
839
+ deploy_histogram_data_drift_app: bool = True,
840
+ ) -> None:
841
+ pass
842
+
843
+ @abstractmethod
844
+ def deploy_histogram_data_drift_app(
845
+ self, project: str, image: str = "mlrun/mlrun"
846
+ ) -> None:
847
+ pass
mlrun/db/factory.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2023 MLRun Authors
1
+ # Copyright 2023 Iguazio
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.