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/__init__.py CHANGED
@@ -22,11 +22,16 @@ __all__ = [
22
22
  "handler",
23
23
  "ArtifactType",
24
24
  "get_secret_or_env",
25
+ "mount_v3io",
26
+ "v3io_cred",
27
+ "auto_mount",
28
+ "VolumeMount",
25
29
  ]
26
30
 
27
31
  from os import environ, path
28
32
 
29
33
  import dotenv
34
+ import mlrun_pipelines
30
35
 
31
36
  from .config import config as mlconf
32
37
  from .datastore import DataItem, store_manager
@@ -35,7 +40,6 @@ from .errors import MLRunInvalidArgumentError, MLRunNotFoundError
35
40
  from .execution import MLClientCtx
36
41
  from .model import RunObject, RunTemplate, new_task
37
42
  from .package import ArtifactType, DefaultPackager, Packager, handler
38
- from .platforms import VolumeMount, auto_mount, mount_v3io, v3io_cred
39
43
  from .projects import (
40
44
  ProjectMetadata,
41
45
  build_function,
@@ -65,6 +69,11 @@ from .utils.version import Version
65
69
 
66
70
  __version__ = Version().get()["version"]
67
71
 
72
+ VolumeMount = mlrun_pipelines.common.mounts.VolumeMount
73
+ mount_v3io = mlrun_pipelines.mounts.mount_v3io
74
+ v3io_cred = mlrun_pipelines.mounts.v3io_cred
75
+ auto_mount = mlrun_pipelines.mounts.auto_mount
76
+
68
77
 
69
78
  def get_version():
70
79
  """get current mlrun version"""
@@ -97,6 +106,7 @@ def set_environment(
97
106
  example::
98
107
 
99
108
  from os import path
109
+
100
110
  project_name, artifact_path = set_environment()
101
111
  set_environment("http://localhost:8080", artifact_path="./")
102
112
  set_environment(env_file="mlrun.env")
mlrun/__main__.py CHANGED
@@ -22,17 +22,16 @@ from ast import literal_eval
22
22
  from base64 import b64decode, b64encode
23
23
  from os import environ, path, remove
24
24
  from pprint import pprint
25
- from subprocess import Popen
26
- from sys import executable
27
- from urllib.parse import urlparse
28
25
 
29
26
  import click
30
27
  import dotenv
31
28
  import pandas as pd
32
29
  import yaml
30
+ from mlrun_pipelines.mounts import auto_mount as auto_mount_modifier
33
31
  from tabulate import tabulate
34
32
 
35
33
  import mlrun
34
+ import mlrun.common.constants as mlrun_constants
36
35
  import mlrun.common.schemas
37
36
  from mlrun.common.helpers import parse_versioned_object_uri
38
37
 
@@ -40,7 +39,6 @@ from .config import config as mlconf
40
39
  from .db import get_run_db
41
40
  from .errors import err_to_str
42
41
  from .model import RunTemplate
43
- from .platforms import auto_mount as auto_mount_modifier
44
42
  from .projects import load_project
45
43
  from .run import (
46
44
  get_object,
@@ -259,8 +257,10 @@ def run(
259
257
  runobj.metadata.labels[k] = v
260
258
 
261
259
  if workflow:
262
- runobj.metadata.labels["workflow"] = workflow
263
- runobj.metadata.labels["mlrun/runner-pod"] = socket.gethostname()
260
+ runobj.metadata.labels[mlrun_constants.MLRunInternalLabels.workflow] = workflow
261
+ runobj.metadata.labels[mlrun_constants.MLRunInternalLabels.runner_pod] = (
262
+ socket.gethostname()
263
+ )
264
264
 
265
265
  if db:
266
266
  mlconf.dbpath = db
@@ -469,6 +469,17 @@ def run(
469
469
  is_flag=True,
470
470
  help="ensure the project exists, if not, create project",
471
471
  )
472
+ @click.option(
473
+ "--state-file-path", default="/tmp/state", help="path to file with state data"
474
+ )
475
+ @click.option(
476
+ "--image-file-path", default="/tmp/image", help="path to file with image data"
477
+ )
478
+ @click.option(
479
+ "--full-image-file-path",
480
+ default="/tmp/fullimage",
481
+ help="path to file with full image data",
482
+ )
472
483
  def build(
473
484
  func_url,
474
485
  name,
@@ -488,6 +499,9 @@ def build(
488
499
  skip,
489
500
  env_file,
490
501
  ensure_project,
502
+ state_file_path,
503
+ image_file_path,
504
+ full_image_file_path,
491
505
  ):
492
506
  """Build a container image from code and requirements."""
493
507
 
@@ -505,6 +519,8 @@ def build(
505
519
  if kfp:
506
520
  print("Runtime:")
507
521
  pprint(runtime)
522
+ # use kind = "job" by default if not specified
523
+ runtime.setdefault("kind", "job")
508
524
  func = new_function(runtime=runtime)
509
525
 
510
526
  elif func_url:
@@ -575,12 +591,12 @@ def build(
575
591
  state = func.status.state
576
592
  image = func.spec.image
577
593
  if kfp:
578
- with open("/tmp/state", "w") as fp:
594
+ with open(state_file_path, "w") as fp:
579
595
  fp.write(state or "none")
580
596
  full_image = func.full_image_path(image) or ""
581
- with open("/tmp/image", "w") as fp:
597
+ with open(image_file_path, "w") as fp:
582
598
  fp.write(image)
583
- with open("/tmp/fullimage", "w") as fp:
599
+ with open(full_image_file_path, "w") as fp:
584
600
  fp.write(full_image)
585
601
  print("Full image path = ", full_image)
586
602
 
@@ -825,108 +841,6 @@ def get(kind, name, selector, namespace, uid, project, tag, db, extra_args):
825
841
  )
826
842
 
827
843
 
828
- @main.command(deprecated=True)
829
- @click.option("--port", "-p", help="port to listen on", type=int)
830
- @click.option("--dirpath", "-d", help="database directory (dirpath)")
831
- @click.option("--dsn", "-s", help="database dsn, e.g. sqlite:///db/mlrun.db")
832
- @click.option("--logs-path", "-l", help="logs directory path")
833
- @click.option("--data-volume", "-v", help="path prefix to the location of artifacts")
834
- @click.option("--verbose", is_flag=True, help="verbose log")
835
- @click.option("--background", "-b", is_flag=True, help="run in background process")
836
- @click.option("--artifact-path", "-a", help="default artifact path")
837
- @click.option(
838
- "--update-env",
839
- default="",
840
- is_flag=False,
841
- flag_value=mlrun.config.default_env_file,
842
- help=f"update the specified mlrun .env file (if TEXT not provided defaults to {mlrun.config.default_env_file})",
843
- )
844
- def db(
845
- port,
846
- dirpath,
847
- dsn,
848
- logs_path,
849
- data_volume,
850
- verbose,
851
- background,
852
- artifact_path,
853
- update_env,
854
- ):
855
- """Run HTTP api/database server"""
856
- warnings.warn(
857
- "The `mlrun db` command is deprecated in 1.5.0 and will be removed in 1.7.0, it is for internal use only.",
858
- FutureWarning,
859
- )
860
- env = environ.copy()
861
- # ignore client side .env file (so import mlrun in server will not try to connect to local/remote DB)
862
- env["MLRUN_IGNORE_ENV_FILE"] = "true"
863
- env["MLRUN_DBPATH"] = ""
864
-
865
- if port is not None:
866
- env["MLRUN_httpdb__port"] = str(port)
867
- if dirpath is not None:
868
- env["MLRUN_httpdb__dirpath"] = dirpath
869
- if dsn is not None:
870
- if dsn.startswith("sqlite://") and "check_same_thread=" not in dsn:
871
- dsn += "?check_same_thread=false"
872
- env["MLRUN_HTTPDB__DSN"] = dsn
873
- if logs_path is not None:
874
- env["MLRUN_HTTPDB__LOGS_PATH"] = logs_path
875
- if data_volume is not None:
876
- env["MLRUN_HTTPDB__DATA_VOLUME"] = data_volume
877
- if verbose:
878
- env["MLRUN_LOG_LEVEL"] = "DEBUG"
879
- if artifact_path or "MLRUN_ARTIFACT_PATH" not in env:
880
- if not artifact_path:
881
- artifact_path = (
882
- env.get("MLRUN_HTTPDB__DATA_VOLUME", "./artifacts").rstrip("/")
883
- + "/{{project}}"
884
- )
885
- env["MLRUN_ARTIFACT_PATH"] = path.realpath(path.expanduser(artifact_path))
886
-
887
- env["MLRUN_IS_API_SERVER"] = "true"
888
-
889
- # create the DB dir if needed
890
- dsn = dsn or mlconf.httpdb.dsn
891
- if dsn and dsn.startswith("sqlite:///"):
892
- parsed = urlparse(dsn)
893
- p = pathlib.Path(parsed.path[1:]).parent
894
- p.mkdir(parents=True, exist_ok=True)
895
-
896
- cmd = [executable, "-m", "server.api.main"]
897
- pid = None
898
- if background:
899
- print("Starting MLRun API service in the background...")
900
- child = Popen(
901
- cmd,
902
- env=env,
903
- stdout=open("mlrun-stdout.log", "w"),
904
- stderr=open("mlrun-stderr.log", "w"),
905
- start_new_session=True,
906
- )
907
- pid = child.pid
908
- print(
909
- f"Background pid: {pid}, logs written to mlrun-stdout.log and mlrun-stderr.log, use:\n"
910
- f"`kill {pid}` (linux/mac) or `taskkill /pid {pid} /t /f` (windows), to kill the mlrun service process"
911
- )
912
- else:
913
- child = Popen(cmd, env=env)
914
- returncode = child.wait()
915
- if returncode != 0:
916
- raise SystemExit(returncode)
917
- if update_env:
918
- # update mlrun client env file with the API path, so client will use the new DB
919
- # update and PID, allow killing the correct process in a config script
920
- filename = path.expanduser(update_env)
921
- dotenv.set_key(
922
- filename, "MLRUN_DBPATH", f"http://localhost:{port or 8080}", quote_mode=""
923
- )
924
- dotenv.set_key(filename, "MLRUN_MOCK_NUCLIO_DEPLOYMENT", "auto", quote_mode="")
925
- if pid:
926
- dotenv.set_key(filename, "MLRUN_SERVICE_PID", str(pid), quote_mode="")
927
- print(f"Updated configuration in {update_env} .env file")
928
-
929
-
930
844
  @main.command()
931
845
  def version():
932
846
  """get mlrun version"""
@@ -1452,7 +1366,7 @@ def load_notification(notifications: str, project: mlrun.projects.MlrunProject):
1452
1366
  for notification in notifications:
1453
1367
  if notification.startswith("file="):
1454
1368
  file_path = notification.split("=")[-1]
1455
- notification = open(file_path, "r")
1369
+ notification = open(file_path)
1456
1370
  notification = json.load(notification)
1457
1371
  else:
1458
1372
  notification = json.loads(notification)
@@ -0,0 +1,15 @@
1
+ # Copyright 2024 Iguazio
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from .alert import AlertConfig
mlrun/alerts/alert.py ADDED
@@ -0,0 +1,144 @@
1
+ # Copyright 2024 Iguazio
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from typing import Union
16
+
17
+ import mlrun
18
+ import mlrun.common.schemas.alert as alert_objects
19
+ from mlrun.model import ModelObj
20
+
21
+
22
+ class AlertConfig(ModelObj):
23
+ _dict_fields = [
24
+ "project",
25
+ "name",
26
+ "description",
27
+ "summary",
28
+ "severity",
29
+ "criteria",
30
+ "reset_policy",
31
+ "state",
32
+ ]
33
+
34
+ def __init__(
35
+ self,
36
+ project: str = None,
37
+ name: str = None,
38
+ template: Union[alert_objects.AlertTemplate, str] = None,
39
+ description: str = None,
40
+ summary: str = None,
41
+ severity: alert_objects.AlertSeverity = None,
42
+ trigger: alert_objects.AlertTrigger = None,
43
+ criteria: alert_objects.AlertCriteria = None,
44
+ reset_policy: alert_objects.ResetPolicy = None,
45
+ notifications: list[alert_objects.AlertNotification] = None,
46
+ entities: alert_objects.EventEntities = None,
47
+ id: int = None,
48
+ state: alert_objects.AlertActiveState = None,
49
+ created: str = None,
50
+ count: int = None,
51
+ ):
52
+ self.project = project
53
+ self.name = name
54
+ self.description = description
55
+ self.summary = summary
56
+ self.severity = severity
57
+ self.trigger = trigger
58
+ self.criteria = criteria
59
+ self.reset_policy = reset_policy
60
+ self.notifications = notifications or []
61
+ self.entities = entities
62
+ self.id = id
63
+ self.state = state
64
+ self.created = created
65
+ self.count = count
66
+
67
+ if template:
68
+ self._apply_template(template)
69
+
70
+ def validate_required_fields(self):
71
+ if not self.project or not self.name:
72
+ raise mlrun.errors.MLRunBadRequestError("Project and name must be provided")
73
+
74
+ def to_dict(self, fields: list = None, exclude: list = None, strip: bool = False):
75
+ data = super().to_dict(self._dict_fields)
76
+
77
+ data["entities"] = (
78
+ self.entities.dict()
79
+ if not isinstance(self.entities, dict)
80
+ else self.entities
81
+ )
82
+ data["notifications"] = [
83
+ notification_data.dict()
84
+ if not isinstance(notification_data, dict)
85
+ else notification_data
86
+ for notification_data in self.notifications
87
+ ]
88
+ data["trigger"] = (
89
+ self.trigger.dict() if not isinstance(self.trigger, dict) else self.trigger
90
+ )
91
+ return data
92
+
93
+ @classmethod
94
+ def from_dict(cls, struct=None, fields=None, deprecated_fields: dict = None):
95
+ new_obj = super().from_dict(struct, fields=fields)
96
+
97
+ entity_data = struct.get("entities")
98
+ if entity_data:
99
+ entity_obj = alert_objects.EventEntities.parse_obj(entity_data)
100
+ new_obj.entities = entity_obj
101
+
102
+ notifications_data = struct.get("notifications")
103
+ if notifications_data:
104
+ notifications_objs = [
105
+ alert_objects.AlertNotification.parse_obj(notification)
106
+ for notification in notifications_data
107
+ ]
108
+ new_obj.notifications = notifications_objs
109
+
110
+ trigger_data = struct.get("trigger")
111
+ if trigger_data:
112
+ trigger_obj = alert_objects.AlertTrigger.parse_obj(trigger_data)
113
+ new_obj.trigger = trigger_obj
114
+
115
+ return new_obj
116
+
117
+ def with_notifications(self, notifications: list[alert_objects.AlertNotification]):
118
+ if not isinstance(notifications, list) or not all(
119
+ isinstance(item, alert_objects.AlertNotification) for item in notifications
120
+ ):
121
+ raise ValueError(
122
+ "Notifications parameter must be a list of AlertNotification"
123
+ )
124
+ for notification_data in notifications:
125
+ self.notifications.append(notification_data)
126
+ return self
127
+
128
+ def with_entities(self, entities: alert_objects.EventEntities):
129
+ if not isinstance(entities, alert_objects.EventEntities):
130
+ raise ValueError("Entities parameter must be of type: EventEntities")
131
+ self.entities = entities
132
+ return self
133
+
134
+ def _apply_template(self, template):
135
+ if isinstance(template, str):
136
+ db = mlrun.get_run_db()
137
+ template = db.get_alert_template(template)
138
+
139
+ # Extract parameters from the template and apply them to the AlertConfig object
140
+ self.summary = template.summary
141
+ self.severity = template.severity
142
+ self.criteria = template.criteria
143
+ self.trigger = template.trigger
144
+ self.reset_policy = template.reset_policy
@@ -25,6 +25,7 @@ schema.
25
25
  import sys
26
26
  import warnings
27
27
 
28
+ import mlrun.common.formatters
28
29
  import mlrun.common.schemas
29
30
  import mlrun.common.schemas.artifact as old_artifact
30
31
  import mlrun.common.schemas.auth as old_auth
@@ -48,7 +49,7 @@ import mlrun.common.schemas.secret as old_secret
48
49
  import mlrun.common.schemas.tag as old_tag
49
50
 
50
51
 
51
- class DeprecationHelper(object):
52
+ class DeprecationHelper:
52
53
  """A helper class to deprecate old schemas"""
53
54
 
54
55
  def __init__(self, new_target, version="1.4.0"):
@@ -96,7 +97,7 @@ sys.modules["mlrun.api.schemas.tag"] = old_tag
96
97
  # and return the new schema. This is done for backwards compatibility with mlrun.api.schemas.
97
98
  ArtifactCategories = DeprecationHelper(mlrun.common.schemas.ArtifactCategories)
98
99
  ArtifactIdentifier = DeprecationHelper(mlrun.common.schemas.ArtifactIdentifier)
99
- ArtifactsFormat = DeprecationHelper(mlrun.common.schemas.ArtifactsFormat)
100
+ ArtifactsFormat = DeprecationHelper(mlrun.common.formatters.ArtifactsFormat)
100
101
  AuthInfo = DeprecationHelper(mlrun.common.schemas.AuthInfo)
101
102
  AuthorizationAction = DeprecationHelper(mlrun.common.schemas.AuthorizationAction)
102
103
  AuthorizationResourceTypes = DeprecationHelper(
@@ -221,7 +222,7 @@ ObjectKind = DeprecationHelper(mlrun.common.schemas.ObjectKind)
221
222
  ObjectMetadata = DeprecationHelper(mlrun.common.schemas.ObjectMetadata)
222
223
  ObjectSpec = DeprecationHelper(mlrun.common.schemas.ObjectSpec)
223
224
  ObjectStatus = DeprecationHelper(mlrun.common.schemas.ObjectStatus)
224
- PipelinesFormat = DeprecationHelper(mlrun.common.schemas.PipelinesFormat)
225
+ PipelinesFormat = DeprecationHelper(mlrun.common.formatters.PipelinesFormat)
225
226
  PipelinesOutput = DeprecationHelper(mlrun.common.schemas.PipelinesOutput)
226
227
  PipelinesPagination = DeprecationHelper(mlrun.common.schemas.PipelinesPagination)
227
228
  IguazioProject = DeprecationHelper(mlrun.common.schemas.IguazioProject)
@@ -229,7 +230,7 @@ Project = DeprecationHelper(mlrun.common.schemas.Project)
229
230
  ProjectDesiredState = DeprecationHelper(mlrun.common.schemas.ProjectDesiredState)
230
231
  ProjectMetadata = DeprecationHelper(mlrun.common.schemas.ProjectMetadata)
231
232
  ProjectOwner = DeprecationHelper(mlrun.common.schemas.ProjectOwner)
232
- ProjectsFormat = DeprecationHelper(mlrun.common.schemas.ProjectsFormat)
233
+ ProjectsFormat = DeprecationHelper(mlrun.common.formatters.ProjectsFormat)
233
234
  ProjectsOutput = DeprecationHelper(mlrun.common.schemas.ProjectsOutput)
234
235
  ProjectSpec = DeprecationHelper(mlrun.common.schemas.ProjectSpec)
235
236
  ProjectState = DeprecationHelper(mlrun.common.schemas.ProjectState)
@@ -17,14 +17,19 @@
17
17
  # Don't remove this, used by sphinx documentation
18
18
  __all__ = ["get_model", "update_model"]
19
19
 
20
- from .base import Artifact, ArtifactMetadata, ArtifactSpec, get_artifact_meta
20
+ from .base import (
21
+ Artifact,
22
+ ArtifactMetadata,
23
+ ArtifactSpec,
24
+ DirArtifact,
25
+ get_artifact_meta,
26
+ )
21
27
  from .dataset import DatasetArtifact, TableArtifact, update_dataset_meta
22
28
  from .manager import (
23
29
  ArtifactManager,
24
30
  ArtifactProducer,
25
31
  artifact_types,
26
32
  dict_to_artifact,
27
- legacy_artifact_types,
28
33
  )
29
34
  from .model import ModelArtifact, get_model, update_model
30
- from .plots import BokehArtifact, ChartArtifact, PlotArtifact, PlotlyArtifact
35
+ from .plots import PlotArtifact, PlotlyArtifact