mlrun 1.6.4rc7__py3-none-any.whl → 1.7.0__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 (305) hide show
  1. mlrun/__init__.py +11 -1
  2. mlrun/__main__.py +40 -122
  3. mlrun/alerts/__init__.py +15 -0
  4. mlrun/alerts/alert.py +248 -0
  5. mlrun/api/schemas/__init__.py +5 -4
  6. mlrun/artifacts/__init__.py +8 -3
  7. mlrun/artifacts/base.py +47 -257
  8. mlrun/artifacts/dataset.py +11 -192
  9. mlrun/artifacts/manager.py +79 -47
  10. mlrun/artifacts/model.py +31 -159
  11. mlrun/artifacts/plots.py +23 -380
  12. mlrun/common/constants.py +74 -1
  13. mlrun/common/db/sql_session.py +5 -5
  14. mlrun/common/formatters/__init__.py +21 -0
  15. mlrun/common/formatters/artifact.py +45 -0
  16. mlrun/common/formatters/base.py +113 -0
  17. mlrun/common/formatters/feature_set.py +33 -0
  18. mlrun/common/formatters/function.py +46 -0
  19. mlrun/common/formatters/pipeline.py +53 -0
  20. mlrun/common/formatters/project.py +51 -0
  21. mlrun/common/formatters/run.py +29 -0
  22. mlrun/common/helpers.py +12 -3
  23. mlrun/common/model_monitoring/helpers.py +9 -5
  24. mlrun/{runtimes → common/runtimes}/constants.py +37 -9
  25. mlrun/common/schemas/__init__.py +31 -5
  26. mlrun/common/schemas/alert.py +202 -0
  27. mlrun/common/schemas/api_gateway.py +196 -0
  28. mlrun/common/schemas/artifact.py +25 -4
  29. mlrun/common/schemas/auth.py +16 -5
  30. mlrun/common/schemas/background_task.py +1 -1
  31. mlrun/common/schemas/client_spec.py +4 -2
  32. mlrun/common/schemas/common.py +7 -4
  33. mlrun/common/schemas/constants.py +3 -0
  34. mlrun/common/schemas/feature_store.py +74 -44
  35. mlrun/common/schemas/frontend_spec.py +15 -7
  36. mlrun/common/schemas/function.py +12 -1
  37. mlrun/common/schemas/hub.py +11 -18
  38. mlrun/common/schemas/memory_reports.py +2 -2
  39. mlrun/common/schemas/model_monitoring/__init__.py +20 -4
  40. mlrun/common/schemas/model_monitoring/constants.py +123 -42
  41. mlrun/common/schemas/model_monitoring/grafana.py +13 -9
  42. mlrun/common/schemas/model_monitoring/model_endpoints.py +101 -54
  43. mlrun/common/schemas/notification.py +71 -14
  44. mlrun/common/schemas/object.py +2 -2
  45. mlrun/{model_monitoring/controller_handler.py → common/schemas/pagination.py} +9 -12
  46. mlrun/common/schemas/pipeline.py +8 -1
  47. mlrun/common/schemas/project.py +69 -18
  48. mlrun/common/schemas/runs.py +7 -1
  49. mlrun/common/schemas/runtime_resource.py +8 -12
  50. mlrun/common/schemas/schedule.py +4 -4
  51. mlrun/common/schemas/tag.py +1 -2
  52. mlrun/common/schemas/workflow.py +12 -4
  53. mlrun/common/types.py +14 -1
  54. mlrun/config.py +154 -69
  55. mlrun/data_types/data_types.py +6 -1
  56. mlrun/data_types/spark.py +2 -2
  57. mlrun/data_types/to_pandas.py +67 -37
  58. mlrun/datastore/__init__.py +6 -8
  59. mlrun/datastore/alibaba_oss.py +131 -0
  60. mlrun/datastore/azure_blob.py +143 -42
  61. mlrun/datastore/base.py +102 -58
  62. mlrun/datastore/datastore.py +34 -13
  63. mlrun/datastore/datastore_profile.py +146 -20
  64. mlrun/datastore/dbfs_store.py +3 -7
  65. mlrun/datastore/filestore.py +1 -4
  66. mlrun/datastore/google_cloud_storage.py +97 -33
  67. mlrun/datastore/hdfs.py +56 -0
  68. mlrun/datastore/inmem.py +6 -3
  69. mlrun/datastore/redis.py +7 -2
  70. mlrun/datastore/s3.py +34 -12
  71. mlrun/datastore/snowflake_utils.py +45 -0
  72. mlrun/datastore/sources.py +303 -111
  73. mlrun/datastore/spark_utils.py +31 -2
  74. mlrun/datastore/store_resources.py +9 -7
  75. mlrun/datastore/storeytargets.py +151 -0
  76. mlrun/datastore/targets.py +453 -176
  77. mlrun/datastore/utils.py +72 -58
  78. mlrun/datastore/v3io.py +6 -1
  79. mlrun/db/base.py +274 -41
  80. mlrun/db/factory.py +1 -1
  81. mlrun/db/httpdb.py +893 -225
  82. mlrun/db/nopdb.py +291 -33
  83. mlrun/errors.py +36 -6
  84. mlrun/execution.py +115 -42
  85. mlrun/feature_store/__init__.py +0 -2
  86. mlrun/feature_store/api.py +65 -73
  87. mlrun/feature_store/common.py +7 -12
  88. mlrun/feature_store/feature_set.py +76 -55
  89. mlrun/feature_store/feature_vector.py +39 -31
  90. mlrun/feature_store/ingestion.py +7 -6
  91. mlrun/feature_store/retrieval/base.py +16 -11
  92. mlrun/feature_store/retrieval/dask_merger.py +2 -0
  93. mlrun/feature_store/retrieval/job.py +13 -4
  94. mlrun/feature_store/retrieval/local_merger.py +2 -0
  95. mlrun/feature_store/retrieval/spark_merger.py +24 -32
  96. mlrun/feature_store/steps.py +45 -34
  97. mlrun/features.py +11 -21
  98. mlrun/frameworks/_common/artifacts_library.py +9 -9
  99. mlrun/frameworks/_common/mlrun_interface.py +5 -5
  100. mlrun/frameworks/_common/model_handler.py +48 -48
  101. mlrun/frameworks/_common/plan.py +5 -6
  102. mlrun/frameworks/_common/producer.py +3 -4
  103. mlrun/frameworks/_common/utils.py +5 -5
  104. mlrun/frameworks/_dl_common/loggers/logger.py +6 -7
  105. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +9 -9
  106. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +23 -47
  107. mlrun/frameworks/_ml_common/artifacts_library.py +1 -2
  108. mlrun/frameworks/_ml_common/loggers/logger.py +3 -4
  109. mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +4 -5
  110. mlrun/frameworks/_ml_common/model_handler.py +24 -24
  111. mlrun/frameworks/_ml_common/pkl_model_server.py +2 -2
  112. mlrun/frameworks/_ml_common/plan.py +2 -2
  113. mlrun/frameworks/_ml_common/plans/calibration_curve_plan.py +2 -3
  114. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +2 -3
  115. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  116. mlrun/frameworks/_ml_common/plans/feature_importance_plan.py +3 -3
  117. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  118. mlrun/frameworks/_ml_common/utils.py +4 -4
  119. mlrun/frameworks/auto_mlrun/auto_mlrun.py +9 -9
  120. mlrun/frameworks/huggingface/model_server.py +4 -4
  121. mlrun/frameworks/lgbm/__init__.py +33 -33
  122. mlrun/frameworks/lgbm/callbacks/callback.py +2 -4
  123. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -5
  124. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -5
  125. mlrun/frameworks/lgbm/mlrun_interfaces/booster_mlrun_interface.py +1 -3
  126. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +6 -6
  127. mlrun/frameworks/lgbm/model_handler.py +10 -10
  128. mlrun/frameworks/lgbm/model_server.py +6 -6
  129. mlrun/frameworks/lgbm/utils.py +5 -5
  130. mlrun/frameworks/onnx/dataset.py +8 -8
  131. mlrun/frameworks/onnx/mlrun_interface.py +3 -3
  132. mlrun/frameworks/onnx/model_handler.py +6 -6
  133. mlrun/frameworks/onnx/model_server.py +7 -7
  134. mlrun/frameworks/parallel_coordinates.py +6 -6
  135. mlrun/frameworks/pytorch/__init__.py +18 -18
  136. mlrun/frameworks/pytorch/callbacks/callback.py +4 -5
  137. mlrun/frameworks/pytorch/callbacks/logging_callback.py +17 -17
  138. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +11 -11
  139. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +23 -29
  140. mlrun/frameworks/pytorch/callbacks_handler.py +38 -38
  141. mlrun/frameworks/pytorch/mlrun_interface.py +20 -20
  142. mlrun/frameworks/pytorch/model_handler.py +17 -17
  143. mlrun/frameworks/pytorch/model_server.py +7 -7
  144. mlrun/frameworks/sklearn/__init__.py +13 -13
  145. mlrun/frameworks/sklearn/estimator.py +4 -4
  146. mlrun/frameworks/sklearn/metrics_library.py +14 -14
  147. mlrun/frameworks/sklearn/mlrun_interface.py +16 -9
  148. mlrun/frameworks/sklearn/model_handler.py +2 -2
  149. mlrun/frameworks/tf_keras/__init__.py +10 -7
  150. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +15 -15
  151. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +11 -11
  152. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +19 -23
  153. mlrun/frameworks/tf_keras/mlrun_interface.py +9 -11
  154. mlrun/frameworks/tf_keras/model_handler.py +14 -14
  155. mlrun/frameworks/tf_keras/model_server.py +6 -6
  156. mlrun/frameworks/xgboost/__init__.py +13 -13
  157. mlrun/frameworks/xgboost/model_handler.py +6 -6
  158. mlrun/k8s_utils.py +61 -17
  159. mlrun/launcher/__init__.py +1 -1
  160. mlrun/launcher/base.py +16 -15
  161. mlrun/launcher/client.py +13 -11
  162. mlrun/launcher/factory.py +1 -1
  163. mlrun/launcher/local.py +23 -13
  164. mlrun/launcher/remote.py +17 -10
  165. mlrun/lists.py +7 -6
  166. mlrun/model.py +478 -103
  167. mlrun/model_monitoring/__init__.py +1 -1
  168. mlrun/model_monitoring/api.py +163 -371
  169. mlrun/{runtimes/mpijob/v1alpha1.py → model_monitoring/applications/__init__.py} +9 -15
  170. mlrun/model_monitoring/applications/_application_steps.py +188 -0
  171. mlrun/model_monitoring/applications/base.py +108 -0
  172. mlrun/model_monitoring/applications/context.py +341 -0
  173. mlrun/model_monitoring/{evidently_application.py → applications/evidently_base.py} +27 -22
  174. mlrun/model_monitoring/applications/histogram_data_drift.py +354 -0
  175. mlrun/model_monitoring/applications/results.py +99 -0
  176. mlrun/model_monitoring/controller.py +131 -278
  177. mlrun/model_monitoring/db/__init__.py +18 -0
  178. mlrun/model_monitoring/db/stores/__init__.py +136 -0
  179. mlrun/model_monitoring/db/stores/base/__init__.py +15 -0
  180. mlrun/model_monitoring/db/stores/base/store.py +213 -0
  181. mlrun/model_monitoring/db/stores/sqldb/__init__.py +13 -0
  182. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +71 -0
  183. mlrun/model_monitoring/db/stores/sqldb/models/base.py +190 -0
  184. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +103 -0
  185. mlrun/model_monitoring/{stores/models/mysql.py → db/stores/sqldb/models/sqlite.py} +19 -13
  186. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +659 -0
  187. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +13 -0
  188. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +726 -0
  189. mlrun/model_monitoring/db/tsdb/__init__.py +105 -0
  190. mlrun/model_monitoring/db/tsdb/base.py +448 -0
  191. mlrun/model_monitoring/db/tsdb/helpers.py +30 -0
  192. mlrun/model_monitoring/db/tsdb/tdengine/__init__.py +15 -0
  193. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +279 -0
  194. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +42 -0
  195. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +507 -0
  196. mlrun/model_monitoring/db/tsdb/v3io/__init__.py +15 -0
  197. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +158 -0
  198. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +849 -0
  199. mlrun/model_monitoring/features_drift_table.py +134 -106
  200. mlrun/model_monitoring/helpers.py +199 -55
  201. mlrun/model_monitoring/metrics/__init__.py +13 -0
  202. mlrun/model_monitoring/metrics/histogram_distance.py +127 -0
  203. mlrun/model_monitoring/model_endpoint.py +3 -2
  204. mlrun/model_monitoring/stream_processing.py +131 -398
  205. mlrun/model_monitoring/tracking_policy.py +9 -2
  206. mlrun/model_monitoring/writer.py +161 -125
  207. mlrun/package/__init__.py +6 -6
  208. mlrun/package/context_handler.py +5 -5
  209. mlrun/package/packager.py +7 -7
  210. mlrun/package/packagers/default_packager.py +8 -8
  211. mlrun/package/packagers/numpy_packagers.py +15 -15
  212. mlrun/package/packagers/pandas_packagers.py +5 -5
  213. mlrun/package/packagers/python_standard_library_packagers.py +10 -10
  214. mlrun/package/packagers_manager.py +19 -23
  215. mlrun/package/utils/_formatter.py +6 -6
  216. mlrun/package/utils/_pickler.py +2 -2
  217. mlrun/package/utils/_supported_format.py +4 -4
  218. mlrun/package/utils/log_hint_utils.py +2 -2
  219. mlrun/package/utils/type_hint_utils.py +4 -9
  220. mlrun/platforms/__init__.py +11 -10
  221. mlrun/platforms/iguazio.py +24 -203
  222. mlrun/projects/operations.py +52 -25
  223. mlrun/projects/pipelines.py +191 -197
  224. mlrun/projects/project.py +1227 -400
  225. mlrun/render.py +16 -19
  226. mlrun/run.py +209 -184
  227. mlrun/runtimes/__init__.py +83 -15
  228. mlrun/runtimes/base.py +51 -35
  229. mlrun/runtimes/daskjob.py +17 -10
  230. mlrun/runtimes/databricks_job/databricks_cancel_task.py +1 -1
  231. mlrun/runtimes/databricks_job/databricks_runtime.py +8 -7
  232. mlrun/runtimes/databricks_job/databricks_wrapper.py +1 -1
  233. mlrun/runtimes/funcdoc.py +1 -29
  234. mlrun/runtimes/function_reference.py +1 -1
  235. mlrun/runtimes/kubejob.py +34 -128
  236. mlrun/runtimes/local.py +40 -11
  237. mlrun/runtimes/mpijob/__init__.py +0 -20
  238. mlrun/runtimes/mpijob/abstract.py +9 -10
  239. mlrun/runtimes/mpijob/v1.py +1 -1
  240. mlrun/{model_monitoring/stores/models/sqlite.py → runtimes/nuclio/__init__.py} +7 -9
  241. mlrun/runtimes/nuclio/api_gateway.py +769 -0
  242. mlrun/runtimes/nuclio/application/__init__.py +15 -0
  243. mlrun/runtimes/nuclio/application/application.py +758 -0
  244. mlrun/runtimes/nuclio/application/reverse_proxy.go +95 -0
  245. mlrun/runtimes/{function.py → nuclio/function.py} +200 -83
  246. mlrun/runtimes/{nuclio.py → nuclio/nuclio.py} +6 -6
  247. mlrun/runtimes/{serving.py → nuclio/serving.py} +65 -68
  248. mlrun/runtimes/pod.py +281 -101
  249. mlrun/runtimes/remotesparkjob.py +12 -9
  250. mlrun/runtimes/sparkjob/spark3job.py +67 -51
  251. mlrun/runtimes/utils.py +41 -75
  252. mlrun/secrets.py +9 -5
  253. mlrun/serving/__init__.py +8 -1
  254. mlrun/serving/remote.py +2 -7
  255. mlrun/serving/routers.py +85 -69
  256. mlrun/serving/server.py +69 -44
  257. mlrun/serving/states.py +209 -36
  258. mlrun/serving/utils.py +22 -14
  259. mlrun/serving/v1_serving.py +6 -7
  260. mlrun/serving/v2_serving.py +129 -54
  261. mlrun/track/tracker.py +2 -1
  262. mlrun/track/tracker_manager.py +3 -3
  263. mlrun/track/trackers/mlflow_tracker.py +6 -2
  264. mlrun/utils/async_http.py +6 -8
  265. mlrun/utils/azure_vault.py +1 -1
  266. mlrun/utils/clones.py +1 -2
  267. mlrun/utils/condition_evaluator.py +3 -3
  268. mlrun/utils/db.py +21 -3
  269. mlrun/utils/helpers.py +405 -225
  270. mlrun/utils/http.py +3 -6
  271. mlrun/utils/logger.py +112 -16
  272. mlrun/utils/notifications/notification/__init__.py +17 -13
  273. mlrun/utils/notifications/notification/base.py +50 -2
  274. mlrun/utils/notifications/notification/console.py +2 -0
  275. mlrun/utils/notifications/notification/git.py +24 -1
  276. mlrun/utils/notifications/notification/ipython.py +3 -1
  277. mlrun/utils/notifications/notification/slack.py +96 -21
  278. mlrun/utils/notifications/notification/webhook.py +59 -2
  279. mlrun/utils/notifications/notification_pusher.py +149 -30
  280. mlrun/utils/regex.py +9 -0
  281. mlrun/utils/retryer.py +208 -0
  282. mlrun/utils/singleton.py +1 -1
  283. mlrun/utils/v3io_clients.py +4 -6
  284. mlrun/utils/version/version.json +2 -2
  285. mlrun/utils/version/version.py +2 -6
  286. mlrun-1.7.0.dist-info/METADATA +378 -0
  287. mlrun-1.7.0.dist-info/RECORD +351 -0
  288. {mlrun-1.6.4rc7.dist-info → mlrun-1.7.0.dist-info}/WHEEL +1 -1
  289. mlrun/feature_store/retrieval/conversion.py +0 -273
  290. mlrun/kfpops.py +0 -868
  291. mlrun/model_monitoring/application.py +0 -310
  292. mlrun/model_monitoring/batch.py +0 -1095
  293. mlrun/model_monitoring/prometheus.py +0 -219
  294. mlrun/model_monitoring/stores/__init__.py +0 -111
  295. mlrun/model_monitoring/stores/kv_model_endpoint_store.py +0 -576
  296. mlrun/model_monitoring/stores/model_endpoint_store.py +0 -147
  297. mlrun/model_monitoring/stores/models/__init__.py +0 -27
  298. mlrun/model_monitoring/stores/models/base.py +0 -84
  299. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -384
  300. mlrun/platforms/other.py +0 -306
  301. mlrun-1.6.4rc7.dist-info/METADATA +0 -272
  302. mlrun-1.6.4rc7.dist-info/RECORD +0 -314
  303. {mlrun-1.6.4rc7.dist-info → mlrun-1.7.0.dist-info}/LICENSE +0 -0
  304. {mlrun-1.6.4rc7.dist-info → mlrun-1.7.0.dist-info}/entry_points.txt +0 -0
  305. {mlrun-1.6.4rc7.dist-info → mlrun-1.7.0.dist-info}/top_level.txt +0 -0
@@ -22,11 +22,48 @@ import mlrun.common.types
22
22
 
23
23
 
24
24
  class NotificationKind(mlrun.common.types.StrEnum):
25
- console = "console"
26
- git = "git"
27
- ipython = "ipython"
28
- slack = "slack"
29
- webhook = "webhook"
25
+ """Currently, the supported notification kinds and their params are as follows:"""
26
+
27
+ console: str = "console"
28
+ """no params, local only"""
29
+
30
+ git: str = "git"
31
+ """
32
+ **token** - The git token to use for the git notification.\n
33
+ **repo** - The git repo to which to send the notification.\n
34
+ **issue** - The git issue to which to send the notification.\n
35
+ **merge_request** -
36
+ In GitLab (as opposed to GitHub), merge requests and issues are separate entities.
37
+ If using merge request, the issue will be ignored, and vice versa.\n
38
+ **server** - The git server to which to send the notification.\n
39
+ **gitlab** - (bool) Whether the git server is GitLab or not.\n
40
+ """
41
+
42
+ ipython: str = "ipython"
43
+ """no params, local only"""
44
+
45
+ slack: str = "slack"
46
+ """**webhook** - The slack webhook to which to send the notification."""
47
+
48
+ webhook: str = "webhook"
49
+ """
50
+ **url** - The webhook url to which to send the notification.\n
51
+ **method** - The http method to use when sending the notification (GET, POST, PUT, etc…).\n
52
+ **headers** - (dict) The http headers to send with the notification.\n
53
+ **override_body** -
54
+ (dict) The body to send with the notification. If not specified, the
55
+ default body will be a dictionary containing `name`, `message`, `severity`, and a `runs` list of the
56
+ completed runs. You can also add the run's details.\n
57
+ Example::
58
+
59
+ "override_body": {"message":"Run Completed {{ runs }}"
60
+ # Results would look like:
61
+ "message": "Run Completed [{'project': 'my-project', 'name': 'my-function', 'host': <run-host>,
62
+ 'status': {'state': 'completed', 'results': <run-results>}}]"
63
+ **verify_ssl** -
64
+ (bool) Whether SSL certificates are validated during HTTP requests or not.
65
+ The default is set to True.\n
66
+ """
30
67
 
31
68
 
32
69
  class NotificationSeverity(mlrun.common.types.StrEnum):
@@ -50,18 +87,38 @@ class NotificationLimits(enum.Enum):
50
87
 
51
88
 
52
89
  class Notification(pydantic.BaseModel):
90
+ """
91
+ Notification object schema
92
+
93
+ :param kind: notification implementation kind - slack, webhook, etc.
94
+ :param name: for logging and identification
95
+ :param message: message content in the notification
96
+ :param severity: severity to display in the notification
97
+ :param when: list of statuses to trigger the notification: 'running', 'completed', 'error'
98
+ :param condition: optional condition to trigger the notification, a jinja2 expression that can use run data
99
+ to evaluate if the notification should be sent in addition to the 'when' statuses.
100
+ e.g.: '{{ run["status"]["results"]["accuracy"] < 0.9}}'
101
+ :param params: Implementation specific parameters for the notification implementation (e.g. slack webhook url,
102
+ git repository details, etc.)
103
+ :param secret_params: secret parameters for the notification implementation, same as params but will be stored
104
+ in a k8s secret and passed as a secret reference to the implementation.
105
+ :param status: notification status - pending, sent, error
106
+ :param sent_time: time the notification was sent
107
+ :param reason: failure reason if the notification failed to send
108
+ """
109
+
53
110
  kind: NotificationKind
54
111
  name: str
55
- message: str
56
- severity: NotificationSeverity
57
- when: typing.List[str]
58
- condition: str
59
- params: typing.Dict[str, typing.Any] = None
60
- status: NotificationStatus = None
61
- sent_time: typing.Union[str, datetime.datetime] = None
62
- secret_params: typing.Optional[typing.Dict[str, typing.Any]] = None
112
+ message: typing.Optional[str] = None
113
+ severity: typing.Optional[NotificationSeverity] = None
114
+ when: typing.Optional[list[str]] = None
115
+ condition: typing.Optional[str] = None
116
+ params: typing.Optional[dict[str, typing.Any]] = None
117
+ status: typing.Optional[NotificationStatus] = None
118
+ sent_time: typing.Optional[typing.Union[str, datetime.datetime]] = None
119
+ secret_params: typing.Optional[dict[str, typing.Any]] = None
63
120
  reason: typing.Optional[str] = None
64
121
 
65
122
 
66
123
  class SetNotificationRequest(pydantic.BaseModel):
67
- notifications: typing.List[Notification] = None
124
+ notifications: list[Notification] = None
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from datetime import datetime
16
- from typing import List, Optional
16
+ from typing import Optional
17
17
 
18
18
  from pydantic import BaseModel, Extra
19
19
 
@@ -60,7 +60,7 @@ class ObjectRecord(BaseModel):
60
60
  project: str
61
61
  uid: str
62
62
  updated: Optional[datetime] = None
63
- labels: List[LabelRecord]
63
+ labels: list[LabelRecord]
64
64
  # state is extracted from the full status dict to enable queries
65
65
  state: Optional[str] = None
66
66
  full_object: Optional[dict] = None
@@ -12,18 +12,15 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- import mlrun
16
- from mlrun.model_monitoring.controller import MonitoringApplicationController
15
+ import typing
17
16
 
17
+ import pydantic
18
18
 
19
- def handler(context: mlrun.run.MLClientCtx) -> None:
20
- """
21
- Run model monitoring application processor
22
19
 
23
- :param context: the MLRun context
24
- """
25
- monitor_app_controller = MonitoringApplicationController(
26
- context=context,
27
- project=context.project,
28
- )
29
- monitor_app_controller.run()
20
+ class PaginationInfo(pydantic.BaseModel):
21
+ class Config:
22
+ allow_population_by_field_name = True
23
+
24
+ page: typing.Optional[int]
25
+ page_size: typing.Optional[int] = pydantic.Field(alias="page-size")
26
+ page_token: typing.Optional[str] = pydantic.Field(alias="page-token")
@@ -15,10 +15,17 @@
15
15
  import typing
16
16
 
17
17
  import pydantic
18
+ from deprecated import deprecated
18
19
 
19
20
  import mlrun.common.types
20
21
 
21
22
 
23
+ @deprecated(
24
+ version="1.7.0",
25
+ reason="mlrun.common.schemas.PipelinesFormat is deprecated and will be removed in 1.9.0. "
26
+ "Use mlrun.common.formatters.PipelineFormat instead.",
27
+ category=FutureWarning,
28
+ )
22
29
  class PipelinesFormat(mlrun.common.types.StrEnum):
23
30
  full = "full"
24
31
  metadata_only = "metadata_only"
@@ -34,6 +41,6 @@ class PipelinesPagination(str):
34
41
 
35
42
  class PipelinesOutput(pydantic.BaseModel):
36
43
  # use the format query param to control what is returned
37
- runs: typing.List[typing.Union[dict, str]]
44
+ runs: list[typing.Union[dict, str]]
38
45
  total_size: int
39
46
  next_page_token: typing.Optional[str]
@@ -16,6 +16,7 @@ import datetime
16
16
  import typing
17
17
 
18
18
  import pydantic
19
+ from deprecated import deprecated
19
20
 
20
21
  import mlrun.common.types
21
22
 
@@ -23,6 +24,12 @@ from .common import ImageBuilder
23
24
  from .object import ObjectKind, ObjectStatus
24
25
 
25
26
 
27
+ @deprecated(
28
+ version="1.7.0",
29
+ reason="mlrun.common.schemas.ProjectsFormat is deprecated and will be removed in 1.9.0. "
30
+ "Use mlrun.common.formatters.ProjectFormat instead.",
31
+ category=FutureWarning,
32
+ )
26
33
  class ProjectsFormat(mlrun.common.types.StrEnum):
27
34
  full = "full"
28
35
  name_only = "name_only"
@@ -84,9 +91,33 @@ class ProjectSpec(pydantic.BaseModel):
84
91
  subpath: typing.Optional[str] = None
85
92
  origin_url: typing.Optional[str] = None
86
93
  desired_state: typing.Optional[ProjectDesiredState] = ProjectDesiredState.online
87
- custom_packagers: typing.Optional[typing.List[typing.Tuple[str, bool]]] = None
94
+ custom_packagers: typing.Optional[list[tuple[str, bool]]] = None
88
95
  default_image: typing.Optional[str] = None
89
96
  build: typing.Optional[ImageBuilder] = None
97
+ default_function_node_selector: typing.Optional[dict] = {}
98
+
99
+ class Config:
100
+ extra = pydantic.Extra.allow
101
+
102
+
103
+ class ProjectSpecOut(pydantic.BaseModel):
104
+ description: typing.Optional[str] = None
105
+ owner: typing.Optional[str] = None
106
+ goals: typing.Optional[str] = None
107
+ params: typing.Optional[dict] = {}
108
+ functions: typing.Optional[list] = []
109
+ workflows: typing.Optional[list] = []
110
+ artifacts: typing.Optional[list] = []
111
+ artifact_path: typing.Optional[str] = None
112
+ conda: typing.Optional[str] = None
113
+ source: typing.Optional[str] = None
114
+ subpath: typing.Optional[str] = None
115
+ origin_url: typing.Optional[str] = None
116
+ desired_state: typing.Optional[ProjectDesiredState] = ProjectDesiredState.online
117
+ custom_packagers: typing.Optional[list[tuple[str, bool]]] = None
118
+ default_image: typing.Optional[str] = None
119
+ build: typing.Any = None
120
+ default_function_node_selector: typing.Optional[dict] = {}
90
121
 
91
122
  class Config:
92
123
  extra = pydantic.Extra.allow
@@ -99,6 +130,15 @@ class Project(pydantic.BaseModel):
99
130
  status: ObjectStatus = ObjectStatus()
100
131
 
101
132
 
133
+ # The reason we have a different schema for the response model is that we don't want to validate project.spec.build in
134
+ # the response as the validation was added late and there may be corrupted values in the DB.
135
+ class ProjectOut(pydantic.BaseModel):
136
+ kind: ObjectKind = pydantic.Field(ObjectKind.project, const=True)
137
+ metadata: ProjectMetadata
138
+ spec: ProjectSpecOut = ProjectSpecOut()
139
+ status: ObjectStatus = ObjectStatus()
140
+
141
+
102
142
  class ProjectOwner(pydantic.BaseModel):
103
143
  username: str
104
144
  access_key: str
@@ -106,31 +146,42 @@ class ProjectOwner(pydantic.BaseModel):
106
146
 
107
147
  class ProjectSummary(pydantic.BaseModel):
108
148
  name: str
109
- files_count: int
110
- feature_sets_count: int
111
- models_count: int
112
- runs_failed_recent_count: int
113
- runs_running_count: int
114
- schedules_count: int
149
+ files_count: int = 0
150
+ feature_sets_count: int = 0
151
+ models_count: int = 0
152
+ runs_completed_recent_count: int = 0
153
+ runs_failed_recent_count: int = 0
154
+ runs_running_count: int = 0
155
+ distinct_schedules_count: int = 0
156
+ distinct_scheduled_jobs_pending_count: int = 0
157
+ distinct_scheduled_pipelines_pending_count: int = 0
158
+ pipelines_completed_recent_count: typing.Optional[int] = None
159
+ pipelines_failed_recent_count: typing.Optional[int] = None
115
160
  pipelines_running_count: typing.Optional[int] = None
161
+ updated: typing.Optional[datetime.datetime] = None
116
162
 
117
163
 
118
164
  class IguazioProject(pydantic.BaseModel):
119
165
  data: dict
120
166
 
121
167
 
168
+ # The format query param controls the project type used:
169
+ # full - ProjectOut
170
+ # name_only - str
171
+ # summary - ProjectSummary
172
+ # leader - currently only IguazioProject supported
173
+ # The way pydantic handles typing.Union is that it takes the object and tries to coerce it to be the types of the
174
+ # union by the definition order. Therefore, we can't currently add generic dict for all leader formats, but we need
175
+ # to add a specific classes for them. it's frustrating but couldn't find other workaround, see:
176
+ # https://github.com/samuelcolvin/pydantic/issues/1423, https://github.com/samuelcolvin/pydantic/issues/619
177
+ ProjectOutput = typing.TypeVar(
178
+ "ProjectOutput", ProjectOut, str, ProjectSummary, IguazioProject
179
+ )
180
+
181
+
122
182
  class ProjectsOutput(pydantic.BaseModel):
123
- # The format query param controls the project type used:
124
- # full - Project
125
- # name_only - str
126
- # summary - ProjectSummary
127
- # leader - currently only IguazioProject supported
128
- # The way pydantic handles typing.Union is that it takes the object and tries to coerce it to be the types of the
129
- # union by the definition order. Therefore we can't currently add generic dict for all leader formats, but we need
130
- # to add a specific classes for them. it's frustrating but couldn't find other workaround, see:
131
- # https://github.com/samuelcolvin/pydantic/issues/1423, https://github.com/samuelcolvin/pydantic/issues/619
132
- projects: typing.List[typing.Union[Project, str, ProjectSummary, IguazioProject]]
183
+ projects: list[ProjectOutput]
133
184
 
134
185
 
135
186
  class ProjectSummariesOutput(pydantic.BaseModel):
136
- project_summaries: typing.List[ProjectSummary]
187
+ project_summaries: list[ProjectSummary]
@@ -15,6 +15,7 @@
15
15
  import typing
16
16
 
17
17
  import pydantic
18
+ from deprecated import deprecated
18
19
 
19
20
  import mlrun.common.types
20
21
 
@@ -25,7 +26,12 @@ class RunIdentifier(pydantic.BaseModel):
25
26
  iter: typing.Optional[int]
26
27
 
27
28
 
28
- # In 1.7 should be moved to mlrun.common.formatters.run.py
29
+ @deprecated(
30
+ version="1.7.0",
31
+ reason="mlrun.common.schemas.RunsFormat is deprecated and will be removed in 1.9.0. "
32
+ "Use mlrun.common.formatters.RunFormat instead.",
33
+ category=FutureWarning,
34
+ )
29
35
  class RunsFormat(mlrun.common.types.StrEnum):
30
36
  # No enrichment, data is pulled as-is from the database.
31
37
  standard = "standard"
@@ -26,15 +26,15 @@ class ListRuntimeResourcesGroupByField(mlrun.common.types.StrEnum):
26
26
 
27
27
  class RuntimeResource(pydantic.BaseModel):
28
28
  name: str
29
- labels: typing.Dict[str, str] = {}
30
- status: typing.Optional[typing.Dict]
29
+ labels: dict[str, str] = {}
30
+ status: typing.Optional[dict]
31
31
 
32
32
 
33
33
  class RuntimeResources(pydantic.BaseModel):
34
- crd_resources: typing.List[RuntimeResource] = []
35
- pod_resources: typing.List[RuntimeResource] = []
34
+ crd_resources: list[RuntimeResource] = []
35
+ pod_resources: list[RuntimeResource] = []
36
36
  # only for dask runtime
37
- service_resources: typing.Optional[typing.List[RuntimeResource]] = None
37
+ service_resources: typing.Optional[list[RuntimeResource]] = None
38
38
 
39
39
  class Config:
40
40
  extra = pydantic.Extra.allow
@@ -45,14 +45,10 @@ class KindRuntimeResources(pydantic.BaseModel):
45
45
  resources: RuntimeResources
46
46
 
47
47
 
48
- RuntimeResourcesOutput = typing.List[KindRuntimeResources]
48
+ RuntimeResourcesOutput = list[KindRuntimeResources]
49
49
 
50
50
 
51
51
  # project name -> job uid -> runtime resources
52
- GroupedByJobRuntimeResourcesOutput = typing.Dict[
53
- str, typing.Dict[str, RuntimeResources]
54
- ]
52
+ GroupedByJobRuntimeResourcesOutput = dict[str, dict[str, RuntimeResources]]
55
53
  # project name -> kind -> runtime resources
56
- GroupedByProjectRuntimeResourcesOutput = typing.Dict[
57
- str, typing.Dict[str, RuntimeResources]
58
- ]
54
+ GroupedByProjectRuntimeResourcesOutput = dict[str, dict[str, RuntimeResources]]
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from datetime import datetime
16
- from typing import Any, List, Literal, Optional, Union
16
+ from typing import Any, Literal, Optional, Union
17
17
 
18
18
  from pydantic import BaseModel
19
19
 
@@ -96,7 +96,7 @@ class ScheduleUpdate(BaseModel):
96
96
  scheduled_object: Optional[Any]
97
97
  cron_trigger: Optional[Union[str, ScheduleCronTrigger]]
98
98
  desired_state: Optional[str]
99
- labels: Optional[dict] = {}
99
+ labels: Optional[dict] = None
100
100
  concurrency_limit: Optional[int]
101
101
  credentials: Credentials = Credentials()
102
102
 
@@ -119,7 +119,7 @@ class ScheduleRecord(ScheduleInput):
119
119
  project: str
120
120
  last_run_uri: Optional[str]
121
121
  state: Optional[str]
122
- labels: Optional[List[LabelRecord]]
122
+ labels: Optional[list[LabelRecord]]
123
123
  next_run_time: Optional[datetime]
124
124
 
125
125
  class Config:
@@ -135,7 +135,7 @@ class ScheduleOutput(ScheduleRecord):
135
135
 
136
136
 
137
137
  class SchedulesOutput(BaseModel):
138
- schedules: List[ScheduleOutput]
138
+ schedules: list[ScheduleOutput]
139
139
 
140
140
 
141
141
  class ScheduleIdentifier(BaseModel):
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
- import typing
16
15
 
17
16
  import pydantic
18
17
 
@@ -29,4 +28,4 @@ class TagObjects(pydantic.BaseModel):
29
28
 
30
29
  kind: str
31
30
  # TODO: Add more types to the list for new supported tagged objects
32
- identifiers: typing.List[ArtifactIdentifier]
31
+ identifiers: list[ArtifactIdentifier]
@@ -16,8 +16,9 @@ import typing
16
16
 
17
17
  import pydantic
18
18
 
19
- from .notification import Notification
20
- from .schedule import ScheduleCronTrigger
19
+ from mlrun.common.schemas.notification import Notification
20
+ from mlrun.common.schemas.schedule import ScheduleCronTrigger
21
+ from mlrun.common.types import StrEnum
21
22
 
22
23
 
23
24
  class WorkflowSpec(pydantic.BaseModel):
@@ -32,16 +33,17 @@ class WorkflowSpec(pydantic.BaseModel):
32
33
  schedule: typing.Union[str, ScheduleCronTrigger] = None
33
34
  run_local: typing.Optional[bool] = None
34
35
  image: typing.Optional[str] = None
36
+ workflow_runner_node_selector: typing.Optional[dict[str, str]] = None
35
37
 
36
38
 
37
39
  class WorkflowRequest(pydantic.BaseModel):
38
40
  spec: typing.Optional[WorkflowSpec] = None
39
- arguments: typing.Optional[typing.Dict] = None
41
+ arguments: typing.Optional[dict] = None
40
42
  artifact_path: typing.Optional[str] = None
41
43
  source: typing.Optional[str] = None
42
44
  run_name: typing.Optional[str] = None
43
45
  namespace: typing.Optional[str] = None
44
- notifications: typing.Optional[typing.List[Notification]] = None
46
+ notifications: typing.Optional[list[Notification]] = None
45
47
 
46
48
 
47
49
  class WorkflowResponse(pydantic.BaseModel):
@@ -54,3 +56,9 @@ class WorkflowResponse(pydantic.BaseModel):
54
56
 
55
57
  class GetWorkflowResponse(pydantic.BaseModel):
56
58
  workflow_id: str = None
59
+
60
+
61
+ class EngineType(StrEnum):
62
+ LOCAL = "local"
63
+ REMOTE = "remote"
64
+ KFP = "kfp"
mlrun/common/types.py CHANGED
@@ -11,7 +11,6 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
14
 
16
15
  import enum
17
16
 
@@ -23,3 +22,17 @@ class StrEnum(str, enum.Enum):
23
22
 
24
23
  def __repr__(self):
25
24
  return self.value
25
+
26
+
27
+ # Partial backport from Python 3.11
28
+ # https://docs.python.org/3/library/http.html#http.HTTPMethod
29
+ class HTTPMethod(StrEnum):
30
+ GET = "GET"
31
+ POST = "POST"
32
+ DELETE = "DELETE"
33
+ PATCH = "PATCH"
34
+
35
+
36
+ class Operation(StrEnum):
37
+ ADD = "add"
38
+ REMOVE = "remove"