mlrun 1.3.3rc1__py3-none-any.whl → 1.4.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 (444) hide show
  1. mlrun/__init__.py +3 -3
  2. mlrun/__main__.py +79 -37
  3. mlrun/api/__init__.py +1 -1
  4. mlrun/api/api/__init__.py +1 -1
  5. mlrun/api/api/api.py +4 -4
  6. mlrun/api/api/deps.py +10 -21
  7. mlrun/api/api/endpoints/__init__.py +1 -1
  8. mlrun/api/api/endpoints/artifacts.py +64 -36
  9. mlrun/api/api/endpoints/auth.py +4 -4
  10. mlrun/api/api/endpoints/background_tasks.py +11 -11
  11. mlrun/api/api/endpoints/client_spec.py +5 -5
  12. mlrun/api/api/endpoints/clusterization_spec.py +6 -4
  13. mlrun/api/api/endpoints/feature_store.py +124 -115
  14. mlrun/api/api/endpoints/files.py +22 -14
  15. mlrun/api/api/endpoints/frontend_spec.py +28 -21
  16. mlrun/api/api/endpoints/functions.py +142 -87
  17. mlrun/api/api/endpoints/grafana_proxy.py +89 -442
  18. mlrun/api/api/endpoints/healthz.py +20 -7
  19. mlrun/api/api/endpoints/hub.py +320 -0
  20. mlrun/api/api/endpoints/internal/__init__.py +1 -1
  21. mlrun/api/api/endpoints/internal/config.py +1 -1
  22. mlrun/api/api/endpoints/internal/memory_reports.py +9 -9
  23. mlrun/api/api/endpoints/logs.py +11 -11
  24. mlrun/api/api/endpoints/model_endpoints.py +74 -70
  25. mlrun/api/api/endpoints/operations.py +13 -9
  26. mlrun/api/api/endpoints/pipelines.py +93 -88
  27. mlrun/api/api/endpoints/projects.py +35 -35
  28. mlrun/api/api/endpoints/runs.py +69 -27
  29. mlrun/api/api/endpoints/runtime_resources.py +28 -28
  30. mlrun/api/api/endpoints/schedules.py +98 -41
  31. mlrun/api/api/endpoints/secrets.py +37 -32
  32. mlrun/api/api/endpoints/submit.py +12 -12
  33. mlrun/api/api/endpoints/tags.py +20 -22
  34. mlrun/api/api/utils.py +251 -42
  35. mlrun/api/constants.py +1 -1
  36. mlrun/api/crud/__init__.py +18 -15
  37. mlrun/api/crud/artifacts.py +10 -10
  38. mlrun/api/crud/client_spec.py +4 -4
  39. mlrun/api/crud/clusterization_spec.py +3 -3
  40. mlrun/api/crud/feature_store.py +54 -46
  41. mlrun/api/crud/functions.py +3 -3
  42. mlrun/api/crud/hub.py +312 -0
  43. mlrun/api/crud/logs.py +11 -9
  44. mlrun/api/crud/model_monitoring/__init__.py +3 -3
  45. mlrun/api/crud/model_monitoring/grafana.py +435 -0
  46. mlrun/api/crud/model_monitoring/model_endpoints.py +352 -129
  47. mlrun/api/crud/notifications.py +149 -0
  48. mlrun/api/crud/pipelines.py +67 -52
  49. mlrun/api/crud/projects.py +51 -23
  50. mlrun/api/crud/runs.py +7 -5
  51. mlrun/api/crud/runtime_resources.py +13 -13
  52. mlrun/api/{db/filedb → crud/runtimes}/__init__.py +1 -1
  53. mlrun/api/crud/runtimes/nuclio/__init__.py +14 -0
  54. mlrun/api/crud/runtimes/nuclio/function.py +505 -0
  55. mlrun/api/crud/runtimes/nuclio/helpers.py +310 -0
  56. mlrun/api/crud/secrets.py +88 -46
  57. mlrun/api/crud/tags.py +5 -5
  58. mlrun/api/db/__init__.py +1 -1
  59. mlrun/api/db/base.py +102 -54
  60. mlrun/api/db/init_db.py +2 -3
  61. mlrun/api/db/session.py +4 -12
  62. mlrun/api/db/sqldb/__init__.py +1 -1
  63. mlrun/api/db/sqldb/db.py +439 -196
  64. mlrun/api/db/sqldb/helpers.py +1 -1
  65. mlrun/api/db/sqldb/models/__init__.py +3 -3
  66. mlrun/api/db/sqldb/models/models_mysql.py +82 -64
  67. mlrun/api/db/sqldb/models/models_sqlite.py +76 -64
  68. mlrun/api/db/sqldb/session.py +27 -20
  69. mlrun/api/initial_data.py +82 -24
  70. mlrun/api/launcher.py +196 -0
  71. mlrun/api/main.py +91 -22
  72. mlrun/api/middlewares.py +6 -5
  73. mlrun/api/migrations_mysql/env.py +1 -1
  74. mlrun/api/migrations_mysql/versions/28383af526f3_market_place_to_hub.py +40 -0
  75. mlrun/api/migrations_mysql/versions/32bae1b0e29c_increase_timestamp_fields_precision.py +1 -1
  76. mlrun/api/migrations_mysql/versions/4903aef6a91d_tag_foreign_key_and_cascades.py +1 -1
  77. mlrun/api/migrations_mysql/versions/5f1351c88a19_adding_background_tasks_table.py +1 -1
  78. mlrun/api/migrations_mysql/versions/88e656800d6a_add_requested_logs_column_and_index_to_.py +1 -1
  79. mlrun/api/migrations_mysql/versions/9d16de5f03a7_adding_data_versions_table.py +1 -1
  80. mlrun/api/migrations_mysql/versions/b86f5b53f3d7_adding_name_and_updated_to_runs_table.py +1 -1
  81. mlrun/api/migrations_mysql/versions/c4af40b0bf61_init.py +1 -1
  82. mlrun/api/migrations_mysql/versions/c905d15bd91d_notifications.py +72 -0
  83. mlrun/api/migrations_mysql/versions/ee041e8fdaa0_adding_next_run_time_column_to_schedule_.py +1 -1
  84. mlrun/api/migrations_sqlite/env.py +1 -1
  85. mlrun/api/migrations_sqlite/versions/11f8dd2dc9fe_init.py +1 -1
  86. mlrun/api/migrations_sqlite/versions/1c954f8cb32d_schedule_last_run_uri.py +1 -1
  87. mlrun/api/migrations_sqlite/versions/2b6d23c715aa_adding_feature_sets.py +1 -1
  88. mlrun/api/migrations_sqlite/versions/4acd9430b093_market_place_to_hub.py +77 -0
  89. mlrun/api/migrations_sqlite/versions/6401142f2d7c_adding_next_run_time_column_to_schedule_.py +1 -1
  90. mlrun/api/migrations_sqlite/versions/64d90a1a69bc_adding_background_tasks_table.py +1 -1
  91. mlrun/api/migrations_sqlite/versions/803438ecd005_add_requested_logs_column_to_runs.py +1 -1
  92. mlrun/api/migrations_sqlite/versions/863114f0c659_refactoring_feature_set.py +1 -1
  93. mlrun/api/migrations_sqlite/versions/959ae00528ad_notifications.py +63 -0
  94. mlrun/api/migrations_sqlite/versions/accf9fc83d38_adding_data_versions_table.py +1 -1
  95. mlrun/api/migrations_sqlite/versions/b68e8e897a28_schedule_labels.py +1 -1
  96. mlrun/api/migrations_sqlite/versions/bcd0c1f9720c_adding_project_labels.py +1 -1
  97. mlrun/api/migrations_sqlite/versions/cf21882f938e_schedule_id.py +1 -1
  98. mlrun/api/migrations_sqlite/versions/d781f58f607f_tag_object_name_string.py +1 -1
  99. mlrun/api/migrations_sqlite/versions/deac06871ace_adding_marketplace_sources_table.py +1 -1
  100. mlrun/api/migrations_sqlite/versions/e1dd5983c06b_schedule_concurrency_limit.py +1 -1
  101. mlrun/api/migrations_sqlite/versions/e5594ed3ab53_adding_name_and_updated_to_runs_table.py +1 -1
  102. mlrun/api/migrations_sqlite/versions/f4249b4ba6fa_adding_feature_vectors.py +1 -1
  103. mlrun/api/migrations_sqlite/versions/f7b5a1a03629_adding_feature_labels.py +1 -1
  104. mlrun/api/schemas/__init__.py +216 -138
  105. mlrun/api/utils/__init__.py +1 -1
  106. mlrun/api/utils/asyncio.py +1 -1
  107. mlrun/api/utils/auth/__init__.py +1 -1
  108. mlrun/api/utils/auth/providers/__init__.py +1 -1
  109. mlrun/api/utils/auth/providers/base.py +7 -7
  110. mlrun/api/utils/auth/providers/nop.py +6 -7
  111. mlrun/api/utils/auth/providers/opa.py +17 -17
  112. mlrun/api/utils/auth/verifier.py +36 -34
  113. mlrun/api/utils/background_tasks.py +24 -24
  114. mlrun/{builder.py → api/utils/builder.py} +216 -123
  115. mlrun/api/utils/clients/__init__.py +1 -1
  116. mlrun/api/utils/clients/chief.py +19 -4
  117. mlrun/api/utils/clients/iguazio.py +106 -60
  118. mlrun/api/utils/clients/log_collector.py +1 -1
  119. mlrun/api/utils/clients/nuclio.py +23 -23
  120. mlrun/api/utils/clients/protocols/grpc.py +2 -2
  121. mlrun/api/utils/db/__init__.py +1 -1
  122. mlrun/api/utils/db/alembic.py +1 -1
  123. mlrun/api/utils/db/backup.py +1 -1
  124. mlrun/api/utils/db/mysql.py +24 -25
  125. mlrun/api/utils/db/sql_collation.py +1 -1
  126. mlrun/api/utils/db/sqlite_migration.py +2 -2
  127. mlrun/api/utils/events/__init__.py +14 -0
  128. mlrun/api/utils/events/base.py +57 -0
  129. mlrun/api/utils/events/events_factory.py +41 -0
  130. mlrun/api/utils/events/iguazio.py +217 -0
  131. mlrun/api/utils/events/nop.py +55 -0
  132. mlrun/api/utils/helpers.py +16 -13
  133. mlrun/api/utils/memory_reports.py +1 -1
  134. mlrun/api/utils/periodic.py +6 -3
  135. mlrun/api/utils/projects/__init__.py +1 -1
  136. mlrun/api/utils/projects/follower.py +33 -33
  137. mlrun/api/utils/projects/leader.py +36 -34
  138. mlrun/api/utils/projects/member.py +27 -27
  139. mlrun/api/utils/projects/remotes/__init__.py +1 -1
  140. mlrun/api/utils/projects/remotes/follower.py +13 -13
  141. mlrun/api/utils/projects/remotes/leader.py +10 -10
  142. mlrun/api/utils/projects/remotes/nop_follower.py +27 -21
  143. mlrun/api/utils/projects/remotes/nop_leader.py +17 -16
  144. mlrun/api/utils/scheduler.py +140 -51
  145. mlrun/api/utils/singletons/__init__.py +1 -1
  146. mlrun/api/utils/singletons/db.py +9 -15
  147. mlrun/api/utils/singletons/k8s.py +677 -5
  148. mlrun/api/utils/singletons/logs_dir.py +1 -1
  149. mlrun/api/utils/singletons/project_member.py +1 -1
  150. mlrun/api/utils/singletons/scheduler.py +1 -1
  151. mlrun/artifacts/__init__.py +2 -2
  152. mlrun/artifacts/base.py +8 -2
  153. mlrun/artifacts/dataset.py +5 -3
  154. mlrun/artifacts/manager.py +7 -1
  155. mlrun/artifacts/model.py +15 -4
  156. mlrun/artifacts/plots.py +1 -1
  157. mlrun/common/__init__.py +1 -1
  158. mlrun/common/constants.py +15 -0
  159. mlrun/common/model_monitoring.py +209 -0
  160. mlrun/common/schemas/__init__.py +167 -0
  161. mlrun/{api → common}/schemas/artifact.py +13 -14
  162. mlrun/{api → common}/schemas/auth.py +10 -8
  163. mlrun/{api → common}/schemas/background_task.py +3 -3
  164. mlrun/{api → common}/schemas/client_spec.py +1 -1
  165. mlrun/{api → common}/schemas/clusterization_spec.py +3 -3
  166. mlrun/{api → common}/schemas/constants.py +21 -8
  167. mlrun/common/schemas/events.py +36 -0
  168. mlrun/{api → common}/schemas/feature_store.py +2 -1
  169. mlrun/{api → common}/schemas/frontend_spec.py +7 -6
  170. mlrun/{api → common}/schemas/function.py +5 -5
  171. mlrun/{api → common}/schemas/http.py +3 -3
  172. mlrun/common/schemas/hub.py +134 -0
  173. mlrun/{api → common}/schemas/k8s.py +3 -3
  174. mlrun/{api → common}/schemas/memory_reports.py +1 -1
  175. mlrun/common/schemas/model_endpoints.py +342 -0
  176. mlrun/common/schemas/notification.py +57 -0
  177. mlrun/{api → common}/schemas/object.py +6 -6
  178. mlrun/{api → common}/schemas/pipeline.py +3 -3
  179. mlrun/{api → common}/schemas/project.py +6 -5
  180. mlrun/common/schemas/regex.py +24 -0
  181. mlrun/common/schemas/runs.py +30 -0
  182. mlrun/{api → common}/schemas/runtime_resource.py +3 -3
  183. mlrun/{api → common}/schemas/schedule.py +19 -7
  184. mlrun/{api → common}/schemas/secret.py +3 -3
  185. mlrun/{api → common}/schemas/tag.py +2 -2
  186. mlrun/common/types.py +25 -0
  187. mlrun/config.py +152 -20
  188. mlrun/data_types/__init__.py +7 -2
  189. mlrun/data_types/data_types.py +4 -2
  190. mlrun/data_types/infer.py +1 -1
  191. mlrun/data_types/spark.py +10 -3
  192. mlrun/datastore/__init__.py +10 -3
  193. mlrun/datastore/azure_blob.py +1 -1
  194. mlrun/datastore/base.py +185 -53
  195. mlrun/datastore/datastore.py +1 -1
  196. mlrun/datastore/filestore.py +1 -1
  197. mlrun/datastore/google_cloud_storage.py +1 -1
  198. mlrun/datastore/inmem.py +4 -1
  199. mlrun/datastore/redis.py +1 -1
  200. mlrun/datastore/s3.py +1 -1
  201. mlrun/datastore/sources.py +192 -70
  202. mlrun/datastore/spark_udf.py +44 -0
  203. mlrun/datastore/store_resources.py +4 -4
  204. mlrun/datastore/targets.py +115 -45
  205. mlrun/datastore/utils.py +127 -5
  206. mlrun/datastore/v3io.py +1 -1
  207. mlrun/datastore/wasbfs/__init__.py +1 -1
  208. mlrun/datastore/wasbfs/fs.py +1 -1
  209. mlrun/db/__init__.py +7 -5
  210. mlrun/db/base.py +112 -68
  211. mlrun/db/httpdb.py +445 -277
  212. mlrun/db/nopdb.py +491 -0
  213. mlrun/db/sqldb.py +112 -65
  214. mlrun/errors.py +6 -1
  215. mlrun/execution.py +44 -22
  216. mlrun/feature_store/__init__.py +1 -1
  217. mlrun/feature_store/api.py +143 -95
  218. mlrun/feature_store/common.py +16 -20
  219. mlrun/feature_store/feature_set.py +42 -12
  220. mlrun/feature_store/feature_vector.py +32 -21
  221. mlrun/feature_store/ingestion.py +9 -12
  222. mlrun/feature_store/retrieval/__init__.py +3 -2
  223. mlrun/feature_store/retrieval/base.py +388 -66
  224. mlrun/feature_store/retrieval/dask_merger.py +63 -151
  225. mlrun/feature_store/retrieval/job.py +30 -12
  226. mlrun/feature_store/retrieval/local_merger.py +40 -133
  227. mlrun/feature_store/retrieval/spark_merger.py +129 -127
  228. mlrun/feature_store/retrieval/storey_merger.py +173 -0
  229. mlrun/feature_store/steps.py +132 -15
  230. mlrun/features.py +8 -3
  231. mlrun/frameworks/__init__.py +1 -1
  232. mlrun/frameworks/_common/__init__.py +1 -1
  233. mlrun/frameworks/_common/artifacts_library.py +1 -1
  234. mlrun/frameworks/_common/mlrun_interface.py +1 -1
  235. mlrun/frameworks/_common/model_handler.py +1 -1
  236. mlrun/frameworks/_common/plan.py +1 -1
  237. mlrun/frameworks/_common/producer.py +1 -1
  238. mlrun/frameworks/_common/utils.py +1 -1
  239. mlrun/frameworks/_dl_common/__init__.py +1 -1
  240. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -1
  241. mlrun/frameworks/_dl_common/loggers/logger.py +1 -1
  242. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +1 -1
  243. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +1 -1
  244. mlrun/frameworks/_dl_common/model_handler.py +1 -1
  245. mlrun/frameworks/_dl_common/utils.py +1 -1
  246. mlrun/frameworks/_ml_common/__init__.py +1 -1
  247. mlrun/frameworks/_ml_common/artifacts_library.py +1 -1
  248. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -1
  249. mlrun/frameworks/_ml_common/loggers/logger.py +1 -1
  250. mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +1 -1
  251. mlrun/frameworks/_ml_common/model_handler.py +1 -1
  252. mlrun/frameworks/_ml_common/pkl_model_server.py +13 -1
  253. mlrun/frameworks/_ml_common/plan.py +1 -1
  254. mlrun/frameworks/_ml_common/plans/__init__.py +1 -1
  255. mlrun/frameworks/_ml_common/plans/calibration_curve_plan.py +1 -6
  256. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +1 -1
  257. mlrun/frameworks/_ml_common/plans/dataset_plan.py +1 -1
  258. mlrun/frameworks/_ml_common/plans/feature_importance_plan.py +1 -1
  259. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +1 -1
  260. mlrun/frameworks/_ml_common/producer.py +1 -1
  261. mlrun/frameworks/_ml_common/utils.py +1 -1
  262. mlrun/frameworks/auto_mlrun/__init__.py +1 -1
  263. mlrun/frameworks/auto_mlrun/auto_mlrun.py +1 -1
  264. mlrun/frameworks/huggingface/__init__.py +1 -1
  265. mlrun/frameworks/huggingface/model_server.py +1 -1
  266. mlrun/frameworks/lgbm/__init__.py +1 -1
  267. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -1
  268. mlrun/frameworks/lgbm/callbacks/callback.py +1 -1
  269. mlrun/frameworks/lgbm/callbacks/logging_callback.py +1 -1
  270. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +1 -1
  271. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -1
  272. mlrun/frameworks/lgbm/mlrun_interfaces/booster_mlrun_interface.py +1 -1
  273. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +1 -1
  274. mlrun/frameworks/lgbm/mlrun_interfaces/model_mlrun_interface.py +1 -1
  275. mlrun/frameworks/lgbm/model_handler.py +1 -1
  276. mlrun/frameworks/lgbm/model_server.py +1 -1
  277. mlrun/frameworks/lgbm/utils.py +1 -1
  278. mlrun/frameworks/onnx/__init__.py +1 -1
  279. mlrun/frameworks/onnx/dataset.py +1 -1
  280. mlrun/frameworks/onnx/mlrun_interface.py +1 -1
  281. mlrun/frameworks/onnx/model_handler.py +1 -1
  282. mlrun/frameworks/onnx/model_server.py +1 -1
  283. mlrun/frameworks/parallel_coordinates.py +1 -1
  284. mlrun/frameworks/pytorch/__init__.py +1 -1
  285. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -1
  286. mlrun/frameworks/pytorch/callbacks/callback.py +1 -1
  287. mlrun/frameworks/pytorch/callbacks/logging_callback.py +1 -1
  288. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +1 -1
  289. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +1 -1
  290. mlrun/frameworks/pytorch/callbacks_handler.py +1 -1
  291. mlrun/frameworks/pytorch/mlrun_interface.py +1 -1
  292. mlrun/frameworks/pytorch/model_handler.py +1 -1
  293. mlrun/frameworks/pytorch/model_server.py +1 -1
  294. mlrun/frameworks/pytorch/utils.py +1 -1
  295. mlrun/frameworks/sklearn/__init__.py +1 -1
  296. mlrun/frameworks/sklearn/estimator.py +1 -1
  297. mlrun/frameworks/sklearn/metric.py +1 -1
  298. mlrun/frameworks/sklearn/metrics_library.py +1 -1
  299. mlrun/frameworks/sklearn/mlrun_interface.py +1 -1
  300. mlrun/frameworks/sklearn/model_handler.py +1 -1
  301. mlrun/frameworks/sklearn/utils.py +1 -1
  302. mlrun/frameworks/tf_keras/__init__.py +1 -1
  303. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -1
  304. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +1 -1
  305. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +1 -1
  306. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +1 -1
  307. mlrun/frameworks/tf_keras/mlrun_interface.py +1 -1
  308. mlrun/frameworks/tf_keras/model_handler.py +1 -1
  309. mlrun/frameworks/tf_keras/model_server.py +1 -1
  310. mlrun/frameworks/tf_keras/utils.py +1 -1
  311. mlrun/frameworks/xgboost/__init__.py +1 -1
  312. mlrun/frameworks/xgboost/mlrun_interface.py +1 -1
  313. mlrun/frameworks/xgboost/model_handler.py +1 -1
  314. mlrun/frameworks/xgboost/utils.py +1 -1
  315. mlrun/k8s_utils.py +14 -765
  316. mlrun/kfpops.py +14 -17
  317. mlrun/launcher/__init__.py +13 -0
  318. mlrun/launcher/base.py +406 -0
  319. mlrun/launcher/client.py +159 -0
  320. mlrun/launcher/factory.py +50 -0
  321. mlrun/launcher/local.py +276 -0
  322. mlrun/launcher/remote.py +178 -0
  323. mlrun/lists.py +10 -2
  324. mlrun/mlutils/__init__.py +1 -1
  325. mlrun/mlutils/data.py +1 -1
  326. mlrun/mlutils/models.py +1 -1
  327. mlrun/mlutils/plots.py +1 -1
  328. mlrun/model.py +252 -14
  329. mlrun/model_monitoring/__init__.py +41 -0
  330. mlrun/model_monitoring/features_drift_table.py +1 -1
  331. mlrun/model_monitoring/helpers.py +123 -38
  332. mlrun/model_monitoring/model_endpoint.py +144 -0
  333. mlrun/model_monitoring/model_monitoring_batch.py +310 -259
  334. mlrun/model_monitoring/stores/__init__.py +106 -0
  335. mlrun/model_monitoring/stores/kv_model_endpoint_store.py +448 -0
  336. mlrun/model_monitoring/stores/model_endpoint_store.py +147 -0
  337. mlrun/model_monitoring/stores/models/__init__.py +23 -0
  338. mlrun/model_monitoring/stores/models/base.py +18 -0
  339. mlrun/model_monitoring/stores/models/mysql.py +100 -0
  340. mlrun/model_monitoring/stores/models/sqlite.py +98 -0
  341. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +370 -0
  342. mlrun/model_monitoring/stream_processing_fs.py +239 -271
  343. mlrun/package/__init__.py +163 -0
  344. mlrun/package/context_handler.py +325 -0
  345. mlrun/package/errors.py +47 -0
  346. mlrun/package/packager.py +298 -0
  347. mlrun/{runtimes/package → package/packagers}/__init__.py +3 -1
  348. mlrun/package/packagers/default_packager.py +422 -0
  349. mlrun/package/packagers/numpy_packagers.py +612 -0
  350. mlrun/package/packagers/pandas_packagers.py +968 -0
  351. mlrun/package/packagers/python_standard_library_packagers.py +616 -0
  352. mlrun/package/packagers_manager.py +786 -0
  353. mlrun/package/utils/__init__.py +53 -0
  354. mlrun/package/utils/_archiver.py +226 -0
  355. mlrun/package/utils/_formatter.py +211 -0
  356. mlrun/package/utils/_pickler.py +234 -0
  357. mlrun/package/utils/_supported_format.py +71 -0
  358. mlrun/package/utils/log_hint_utils.py +93 -0
  359. mlrun/package/utils/type_hint_utils.py +298 -0
  360. mlrun/platforms/__init__.py +1 -1
  361. mlrun/platforms/iguazio.py +34 -2
  362. mlrun/platforms/other.py +1 -1
  363. mlrun/projects/__init__.py +1 -1
  364. mlrun/projects/operations.py +14 -9
  365. mlrun/projects/pipelines.py +31 -13
  366. mlrun/projects/project.py +762 -238
  367. mlrun/render.py +49 -19
  368. mlrun/run.py +57 -326
  369. mlrun/runtimes/__init__.py +3 -9
  370. mlrun/runtimes/base.py +247 -784
  371. mlrun/runtimes/constants.py +1 -1
  372. mlrun/runtimes/daskjob.py +45 -41
  373. mlrun/runtimes/funcdoc.py +43 -7
  374. mlrun/runtimes/function.py +66 -656
  375. mlrun/runtimes/function_reference.py +1 -1
  376. mlrun/runtimes/generators.py +1 -1
  377. mlrun/runtimes/kubejob.py +99 -116
  378. mlrun/runtimes/local.py +59 -66
  379. mlrun/runtimes/mpijob/__init__.py +1 -1
  380. mlrun/runtimes/mpijob/abstract.py +13 -15
  381. mlrun/runtimes/mpijob/v1.py +3 -1
  382. mlrun/runtimes/mpijob/v1alpha1.py +1 -1
  383. mlrun/runtimes/nuclio.py +1 -1
  384. mlrun/runtimes/pod.py +51 -26
  385. mlrun/runtimes/remotesparkjob.py +3 -1
  386. mlrun/runtimes/serving.py +12 -4
  387. mlrun/runtimes/sparkjob/__init__.py +1 -2
  388. mlrun/runtimes/sparkjob/abstract.py +44 -31
  389. mlrun/runtimes/sparkjob/spark3job.py +11 -9
  390. mlrun/runtimes/utils.py +61 -42
  391. mlrun/secrets.py +16 -18
  392. mlrun/serving/__init__.py +3 -2
  393. mlrun/serving/merger.py +1 -1
  394. mlrun/serving/remote.py +1 -1
  395. mlrun/serving/routers.py +39 -42
  396. mlrun/serving/server.py +23 -13
  397. mlrun/serving/serving_wrapper.py +1 -1
  398. mlrun/serving/states.py +172 -39
  399. mlrun/serving/utils.py +1 -1
  400. mlrun/serving/v1_serving.py +1 -1
  401. mlrun/serving/v2_serving.py +29 -21
  402. mlrun/utils/__init__.py +1 -2
  403. mlrun/utils/async_http.py +8 -1
  404. mlrun/utils/azure_vault.py +1 -1
  405. mlrun/utils/clones.py +2 -2
  406. mlrun/utils/condition_evaluator.py +65 -0
  407. mlrun/utils/db.py +52 -0
  408. mlrun/utils/helpers.py +188 -13
  409. mlrun/utils/http.py +89 -54
  410. mlrun/utils/logger.py +48 -8
  411. mlrun/utils/model_monitoring.py +132 -100
  412. mlrun/utils/notifications/__init__.py +1 -1
  413. mlrun/utils/notifications/notification/__init__.py +8 -6
  414. mlrun/utils/notifications/notification/base.py +20 -14
  415. mlrun/utils/notifications/notification/console.py +7 -4
  416. mlrun/utils/notifications/notification/git.py +36 -19
  417. mlrun/utils/notifications/notification/ipython.py +10 -8
  418. mlrun/utils/notifications/notification/slack.py +18 -13
  419. mlrun/utils/notifications/notification_pusher.py +377 -56
  420. mlrun/utils/regex.py +6 -1
  421. mlrun/utils/singleton.py +1 -1
  422. mlrun/utils/v3io_clients.py +1 -1
  423. mlrun/utils/vault.py +270 -269
  424. mlrun/utils/version/__init__.py +1 -1
  425. mlrun/utils/version/version.json +2 -2
  426. mlrun/utils/version/version.py +1 -1
  427. {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/METADATA +16 -10
  428. mlrun-1.4.0.dist-info/RECORD +434 -0
  429. mlrun/api/api/endpoints/marketplace.py +0 -257
  430. mlrun/api/crud/marketplace.py +0 -221
  431. mlrun/api/crud/model_monitoring/model_endpoint_store.py +0 -847
  432. mlrun/api/db/filedb/db.py +0 -518
  433. mlrun/api/schemas/marketplace.py +0 -128
  434. mlrun/api/schemas/model_endpoints.py +0 -185
  435. mlrun/db/filedb.py +0 -891
  436. mlrun/feature_store/retrieval/online.py +0 -92
  437. mlrun/model_monitoring/constants.py +0 -67
  438. mlrun/runtimes/package/context_handler.py +0 -711
  439. mlrun/runtimes/sparkjob/spark2job.py +0 -59
  440. mlrun-1.3.3rc1.dist-info/RECORD +0 -381
  441. {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/LICENSE +0 -0
  442. {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/WHEEL +0 -0
  443. {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/entry_points.txt +0 -0
  444. {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/top_level.txt +0 -0
mlrun/api/api/utils.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Iguazio
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.
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  import collections
16
+ import json
16
17
  import re
17
18
  import traceback
18
19
  import typing
@@ -27,21 +28,21 @@ from fastapi.concurrency import run_in_threadpool
27
28
  from sqlalchemy.orm import Session
28
29
 
29
30
  import mlrun.api.crud
31
+ import mlrun.api.db.base
30
32
  import mlrun.api.utils.auth.verifier
31
33
  import mlrun.api.utils.clients.iguazio
34
+ import mlrun.api.utils.singletons.k8s
35
+ import mlrun.common.schemas
32
36
  import mlrun.errors
33
37
  import mlrun.runtimes.pod
34
38
  import mlrun.utils.helpers
35
- from mlrun.api import schemas
36
39
  from mlrun.api.db.sqldb.db import SQLDB
37
- from mlrun.api.schemas import SecretProviderName, SecurityContextEnrichmentModes
38
40
  from mlrun.api.utils.singletons.db import get_db
39
41
  from mlrun.api.utils.singletons.logs_dir import get_logs_dir
40
42
  from mlrun.api.utils.singletons.scheduler import get_scheduler
41
43
  from mlrun.config import config
42
44
  from mlrun.db.sqldb import SQLDB as SQLRunDB
43
45
  from mlrun.errors import err_to_str
44
- from mlrun.k8s_utils import get_k8s_helper
45
46
  from mlrun.run import import_function, new_function
46
47
  from mlrun.runtimes.utils import enrich_function_from_dict
47
48
  from mlrun.utils import get_in, logger, parse_versioned_object_uri
@@ -98,8 +99,18 @@ def get_obj_path(schema, path, user=""):
98
99
  if not path.startswith(schema_prefix):
99
100
  path = f"{schema_prefix}{path}"
100
101
 
101
- # Check if path is allowed - v3io:// is always allowed, and also the real_path parameter if specified.
102
- # We never allow local files in the allowed paths list. Allowed paths must contain a schema (://)
102
+ allowed_paths_list = get_allowed_path_prefixes_list()
103
+ if not any(path.startswith(allowed_path) for allowed_path in allowed_paths_list):
104
+ raise mlrun.errors.MLRunAccessDeniedError("Unauthorized path")
105
+ return path
106
+
107
+
108
+ def get_allowed_path_prefixes_list() -> typing.List[str]:
109
+ """
110
+ Get list of allowed paths - v3io:// is always allowed, and also the real_path parameter if specified.
111
+ We never allow local files in the allowed paths list. Allowed paths must contain a schema (://).
112
+ """
113
+ real_path = config.httpdb.real_path
103
114
  allowed_file_paths = config.httpdb.allowed_file_paths or ""
104
115
  allowed_paths_list = [
105
116
  path.strip() for path in allowed_file_paths.split(",") if "://" in path
@@ -107,13 +118,12 @@ def get_obj_path(schema, path, user=""):
107
118
  if real_path:
108
119
  allowed_paths_list.append(real_path)
109
120
  allowed_paths_list.append("v3io://")
121
+ return allowed_paths_list
110
122
 
111
- if not any(path.startswith(allowed_path) for allowed_path in allowed_paths_list):
112
- raise mlrun.errors.MLRunAccessDeniedError("Unauthorized path")
113
- return path
114
123
 
115
-
116
- def get_secrets(auth_info: mlrun.api.schemas.AuthInfo):
124
+ def get_secrets(
125
+ auth_info: mlrun.common.schemas.AuthInfo,
126
+ ):
117
127
  return {
118
128
  "V3IO_ACCESS_KEY": auth_info.data_session,
119
129
  }
@@ -146,7 +156,7 @@ def parse_submit_run_body(data):
146
156
 
147
157
 
148
158
  def _generate_function_and_task_from_submit_run_body(
149
- db_session: Session, auth_info: mlrun.api.schemas.AuthInfo, data
159
+ db_session: Session, auth_info: mlrun.common.schemas.AuthInfo, data
150
160
  ):
151
161
  function_dict, function_url, task = parse_submit_run_body(data)
152
162
  # TODO: block exec for function["kind"] in ["", "local] (must be a
@@ -178,20 +188,202 @@ def _generate_function_and_task_from_submit_run_body(
178
188
  function = enrich_function_from_dict(function, function_dict)
179
189
 
180
190
  apply_enrichment_and_validation_on_function(function, auth_info)
191
+ apply_enrichment_and_validation_on_task(task)
181
192
 
182
193
  return function, task
183
194
 
184
195
 
185
- async def submit_run(db_session: Session, auth_info: mlrun.api.schemas.AuthInfo, data):
196
+ async def submit_run(
197
+ db_session: Session, auth_info: mlrun.common.schemas.AuthInfo, data
198
+ ):
186
199
  _, _, _, response = await run_in_threadpool(
187
200
  submit_run_sync, db_session, auth_info, data
188
201
  )
189
202
  return response
190
203
 
191
204
 
205
+ def apply_enrichment_and_validation_on_task(task):
206
+
207
+ # Masking notification config params from the task object
208
+ mask_notification_params_on_task(task)
209
+
210
+
211
+ def mask_notification_params_on_task(task):
212
+ run_uid = get_in(task, "metadata.uid")
213
+ project = get_in(task, "metadata.project")
214
+ notifications = task.get("spec", {}).get("notifications", [])
215
+ masked_notifications = []
216
+ if notifications:
217
+ for notification in notifications:
218
+ notification_object = mlrun.model.Notification.from_dict(notification)
219
+ masked_notifications.append(
220
+ mask_notification_params_with_secret(
221
+ project, run_uid, notification_object
222
+ ).to_dict()
223
+ )
224
+ task.setdefault("spec", {})["notifications"] = masked_notifications
225
+
226
+
227
+ def mask_notification_params_with_secret(
228
+ project: str, parent: str, notification_object: mlrun.model.Notification
229
+ ) -> mlrun.model.Notification:
230
+ if notification_object.params and "secret" not in notification_object.params:
231
+ secret_key = mlrun.api.crud.Secrets().generate_client_project_secret_key(
232
+ mlrun.api.crud.SecretsClientType.notifications,
233
+ parent,
234
+ notification_object.name,
235
+ )
236
+ mlrun.api.crud.Secrets().store_project_secrets(
237
+ project,
238
+ mlrun.common.schemas.SecretsData(
239
+ provider=mlrun.common.schemas.SecretProviderName.kubernetes,
240
+ secrets={secret_key: json.dumps(notification_object.params)},
241
+ ),
242
+ allow_internal_secrets=True,
243
+ )
244
+ notification_object.params = {"secret": secret_key}
245
+
246
+ return notification_object
247
+
248
+
249
+ def unmask_notification_params_secret_on_task(
250
+ db: mlrun.api.db.base.DBInterface,
251
+ db_session: Session,
252
+ run: typing.Union[dict, mlrun.model.RunObject],
253
+ ):
254
+ if isinstance(run, dict):
255
+ run = mlrun.model.RunObject.from_dict(run)
256
+
257
+ notifications = []
258
+ for notification in run.spec.notifications:
259
+ invalid_notifications = []
260
+ try:
261
+ notifications.append(
262
+ unmask_notification_params_secret(run.metadata.project, notification)
263
+ )
264
+ except Exception as exc:
265
+ logger.warning(
266
+ "Failed to unmask notification params, notification will not be sent",
267
+ project=run.metadata.project,
268
+ run_uid=run.metadata.uid,
269
+ notification=notification.name,
270
+ exc=err_to_str(exc),
271
+ )
272
+ # set error status in order to later save the db
273
+ notification.status = mlrun.common.schemas.NotificationStatus.ERROR
274
+ invalid_notifications.append(notification)
275
+
276
+ if invalid_notifications:
277
+ db.store_run_notifications(
278
+ db_session,
279
+ invalid_notifications,
280
+ run.metadata.uid,
281
+ run.metadata.project,
282
+ )
283
+
284
+ run.spec.notifications = notifications
285
+
286
+ return run
287
+
288
+
289
+ def unmask_notification_params_secret(
290
+ project: str, notification_object: mlrun.model.Notification
291
+ ) -> mlrun.model.Notification:
292
+ params = notification_object.params or {}
293
+ params_secret = params.get("secret", "")
294
+ if not params_secret:
295
+ return notification_object
296
+
297
+ k8s = mlrun.api.utils.singletons.k8s.get_k8s_helper()
298
+ if not k8s:
299
+ raise mlrun.errors.MLRunRuntimeError(
300
+ "Not running in k8s environment, cannot load notification params secret"
301
+ )
302
+
303
+ notification_object.params = json.loads(
304
+ mlrun.api.crud.Secrets().get_project_secret(
305
+ project,
306
+ mlrun.common.schemas.SecretProviderName.kubernetes,
307
+ secret_key=params_secret,
308
+ allow_internal_secrets=True,
309
+ allow_secrets_from_k8s=True,
310
+ )
311
+ )
312
+
313
+ return notification_object
314
+
315
+
316
+ def delete_notification_params_secret(
317
+ project: str, notification_object: mlrun.model.Notification
318
+ ) -> None:
319
+ params = notification_object.params or {}
320
+ params_secret = params.get("secret", "")
321
+ if not params_secret:
322
+ return
323
+
324
+ k8s = mlrun.api.utils.singletons.k8s.get_k8s_helper()
325
+ if not k8s:
326
+ raise mlrun.errors.MLRunRuntimeError(
327
+ "Not running in k8s environment, cannot delete notification params secret"
328
+ )
329
+
330
+ mlrun.api.crud.Secrets().delete_project_secret(
331
+ project,
332
+ mlrun.common.schemas.SecretProviderName.kubernetes,
333
+ secret_key=params_secret,
334
+ allow_internal_secrets=True,
335
+ allow_secrets_from_k8s=True,
336
+ )
337
+
338
+
339
+ def validate_and_mask_notification_list(
340
+ notifications: typing.List[
341
+ typing.Union[mlrun.model.Notification, mlrun.common.schemas.Notification, dict]
342
+ ],
343
+ parent: str,
344
+ project: str,
345
+ ) -> typing.List[mlrun.model.Notification]:
346
+ """
347
+ Validates notification schema, uniqueness and masks notification params with secret if needed.
348
+ If at least one of the validation steps fails, the function will raise an exception and cause the API to return
349
+ an error response.
350
+ :param notifications: list of notification objects
351
+ :param parent: parent identifier
352
+ :param project: project name
353
+ :return: list of validated and masked notification objects
354
+ """
355
+ notification_objects = []
356
+
357
+ for notification in notifications:
358
+ if isinstance(notification, dict):
359
+ notification_object = mlrun.model.Notification.from_dict(notification)
360
+ elif isinstance(notification, mlrun.common.schemas.Notification):
361
+ notification_object = mlrun.model.Notification.from_dict(
362
+ notification.dict()
363
+ )
364
+ elif isinstance(notification, mlrun.model.Notification):
365
+ notification_object = notification
366
+ else:
367
+ raise mlrun.errors.MLRunInvalidArgumentError(
368
+ "notification must be a dict or a Notification object"
369
+ )
370
+
371
+ # validate notification schema
372
+ mlrun.common.schemas.Notification(**notification_object.to_dict())
373
+
374
+ notification_objects.append(notification_object)
375
+
376
+ mlrun.model.Notification.validate_notification_uniqueness(notification_objects)
377
+
378
+ return [
379
+ mask_notification_params_with_secret(project, parent, notification_object)
380
+ for notification_object in notification_objects
381
+ ]
382
+
383
+
192
384
  def apply_enrichment_and_validation_on_function(
193
385
  function,
194
- auth_info: mlrun.api.schemas.AuthInfo,
386
+ auth_info: mlrun.common.schemas.AuthInfo,
195
387
  ensure_auth: bool = True,
196
388
  perform_auto_mount: bool = True,
197
389
  validate_service_account: bool = True,
@@ -231,14 +423,14 @@ def apply_enrichment_and_validation_on_function(
231
423
 
232
424
  def ensure_function_auth_and_sensitive_data_is_masked(
233
425
  function,
234
- auth_info: mlrun.api.schemas.AuthInfo,
426
+ auth_info: mlrun.common.schemas.AuthInfo,
235
427
  allow_empty_access_key: bool = False,
236
428
  ):
237
429
  ensure_function_has_auth_set(function, auth_info, allow_empty_access_key)
238
430
  mask_function_sensitive_data(function, auth_info)
239
431
 
240
432
 
241
- def mask_function_sensitive_data(function, auth_info: mlrun.api.schemas.AuthInfo):
433
+ def mask_function_sensitive_data(function, auth_info: mlrun.common.schemas.AuthInfo):
242
434
  if not mlrun.runtimes.RuntimeKinds.is_local_runtime(function.kind):
243
435
  _mask_v3io_access_key_env_var(function, auth_info)
244
436
  _mask_v3io_volume_credentials(function)
@@ -322,8 +514,8 @@ def _mask_v3io_volume_credentials(function: mlrun.runtimes.pod.KubeResource):
322
514
  if not username:
323
515
  continue
324
516
  secret_name = mlrun.api.crud.Secrets().store_auth_secret(
325
- mlrun.api.schemas.AuthSecretData(
326
- provider=mlrun.api.schemas.SecretProviderName.kubernetes,
517
+ mlrun.common.schemas.AuthSecretData(
518
+ provider=mlrun.common.schemas.SecretProviderName.kubernetes,
327
519
  username=username,
328
520
  access_key=access_key,
329
521
  )
@@ -385,7 +577,7 @@ def _resolve_v3io_fuse_volume_access_key_matching_username(
385
577
 
386
578
 
387
579
  def _mask_v3io_access_key_env_var(
388
- function: mlrun.runtimes.pod.KubeResource, auth_info: mlrun.api.schemas.AuthInfo
580
+ function: mlrun.runtimes.pod.KubeResource, auth_info: mlrun.common.schemas.AuthInfo
389
581
  ):
390
582
  v3io_access_key = function.get_env("V3IO_ACCESS_KEY")
391
583
  # if it's already a V1EnvVarSource or dict instance, it's already been masked
@@ -412,14 +604,14 @@ def _mask_v3io_access_key_env_var(
412
604
  )
413
605
  return
414
606
  secret_name = mlrun.api.crud.Secrets().store_auth_secret(
415
- mlrun.api.schemas.AuthSecretData(
416
- provider=mlrun.api.schemas.SecretProviderName.kubernetes,
607
+ mlrun.common.schemas.AuthSecretData(
608
+ provider=mlrun.common.schemas.SecretProviderName.kubernetes,
417
609
  username=username,
418
610
  access_key=v3io_access_key,
419
611
  )
420
612
  )
421
- access_key_secret_key = mlrun.api.schemas.AuthSecretData.get_field_secret_key(
422
- "access_key"
613
+ access_key_secret_key = (
614
+ mlrun.common.schemas.AuthSecretData.get_field_secret_key("access_key")
423
615
  )
424
616
  function.set_env_from_secret(
425
617
  "V3IO_ACCESS_KEY", secret_name, access_key_secret_key
@@ -428,7 +620,7 @@ def _mask_v3io_access_key_env_var(
428
620
 
429
621
  def ensure_function_has_auth_set(
430
622
  function: mlrun.runtimes.BaseRuntime,
431
- auth_info: mlrun.api.schemas.AuthInfo,
623
+ auth_info: mlrun.common.schemas.AuthInfo,
432
624
  allow_empty_access_key: bool = False,
433
625
  ):
434
626
  """
@@ -475,8 +667,8 @@ def ensure_function_has_auth_set(
475
667
  "Username is missing from auth info"
476
668
  )
477
669
  secret_name = mlrun.api.crud.Secrets().store_auth_secret(
478
- mlrun.api.schemas.AuthSecretData(
479
- provider=mlrun.api.schemas.SecretProviderName.kubernetes,
670
+ mlrun.common.schemas.AuthSecretData(
671
+ provider=mlrun.common.schemas.SecretProviderName.kubernetes,
480
672
  username=auth_info.username,
481
673
  access_key=function.metadata.credentials.access_key,
482
674
  )
@@ -489,8 +681,8 @@ def ensure_function_has_auth_set(
489
681
  mlrun.model.Credentials.secret_reference_prefix
490
682
  )
491
683
 
492
- access_key_secret_key = mlrun.api.schemas.AuthSecretData.get_field_secret_key(
493
- "access_key"
684
+ access_key_secret_key = (
685
+ mlrun.common.schemas.AuthSecretData.get_field_secret_key("access_key")
494
686
  )
495
687
  auth_env_vars = {
496
688
  mlrun.runtimes.constants.FunctionEnvironmentVariables.auth_session: (
@@ -502,7 +694,7 @@ def ensure_function_has_auth_set(
502
694
  function.set_env_from_secret(env_key, secret_name, secret_key)
503
695
 
504
696
 
505
- def try_perform_auto_mount(function, auth_info: mlrun.api.schemas.AuthInfo):
697
+ def try_perform_auto_mount(function, auth_info: mlrun.common.schemas.AuthInfo):
506
698
  if (
507
699
  mlrun.runtimes.RuntimeKinds.is_local_runtime(function.kind)
508
700
  or function.spec.disable_auto_mount
@@ -520,7 +712,9 @@ def try_perform_auto_mount(function, auth_info: mlrun.api.schemas.AuthInfo):
520
712
 
521
713
  def process_function_service_account(function):
522
714
  # If we're not running inside k8s, skip this check as it's not relevant.
523
- if not get_k8s_helper(silent=True).is_running_inside_kubernetes_cluster():
715
+ if not mlrun.api.utils.singletons.k8s.get_k8s_helper(
716
+ silent=True
717
+ ).is_running_inside_kubernetes_cluster():
524
718
  return
525
719
 
526
720
  (
@@ -536,7 +730,7 @@ def process_function_service_account(function):
536
730
  def resolve_project_default_service_account(project_name: str):
537
731
  allowed_service_accounts = mlrun.api.crud.secrets.Secrets().get_project_secret(
538
732
  project_name,
539
- SecretProviderName.kubernetes,
733
+ mlrun.common.schemas.SecretProviderName.kubernetes,
540
734
  mlrun.api.crud.secrets.Secrets().generate_client_project_secret_key(
541
735
  mlrun.api.crud.secrets.SecretsClientType.service_accounts, "allowed"
542
736
  ),
@@ -551,7 +745,7 @@ def resolve_project_default_service_account(project_name: str):
551
745
 
552
746
  default_service_account = mlrun.api.crud.secrets.Secrets().get_project_secret(
553
747
  project_name,
554
- SecretProviderName.kubernetes,
748
+ mlrun.common.schemas.SecretProviderName.kubernetes,
555
749
  mlrun.api.crud.secrets.Secrets().generate_client_project_secret_key(
556
750
  mlrun.api.crud.secrets.SecretsClientType.service_accounts, "default"
557
751
  ),
@@ -578,7 +772,9 @@ def resolve_project_default_service_account(project_name: str):
578
772
  return allowed_service_accounts, default_service_account
579
773
 
580
774
 
581
- def ensure_function_security_context(function, auth_info: mlrun.api.schemas.AuthInfo):
775
+ def ensure_function_security_context(
776
+ function, auth_info: mlrun.common.schemas.AuthInfo
777
+ ):
582
778
  """
583
779
  For iguazio we enforce that pods run with user id and group id depending on
584
780
  mlrun.mlconf.function.spec.security_context.enrichment_mode
@@ -589,7 +785,7 @@ def ensure_function_security_context(function, auth_info: mlrun.api.schemas.Auth
589
785
  # security context is not yet supported with spark runtime since it requires spark 3.2+
590
786
  if (
591
787
  mlrun.mlconf.function.spec.security_context.enrichment_mode
592
- == SecurityContextEnrichmentModes.disabled.value
788
+ == mlrun.common.schemas.SecurityContextEnrichmentModes.disabled.value
593
789
  or mlrun.runtimes.RuntimeKinds.is_local_runtime(function.kind)
594
790
  or function.kind == mlrun.runtimes.RuntimeKinds.spark
595
791
  # remote spark image currently requires running with user 1000 or root
@@ -605,7 +801,7 @@ def ensure_function_security_context(function, auth_info: mlrun.api.schemas.Auth
605
801
  # Enrichment with retain enrichment mode should occur on function creation only.
606
802
  if (
607
803
  mlrun.mlconf.function.spec.security_context.enrichment_mode
608
- == SecurityContextEnrichmentModes.retain.value
804
+ == mlrun.common.schemas.SecurityContextEnrichmentModes.retain.value
609
805
  and function.spec.security_context is not None
610
806
  and function.spec.security_context.run_as_user is not None
611
807
  and function.spec.security_context.run_as_group is not None
@@ -618,8 +814,8 @@ def ensure_function_security_context(function, auth_info: mlrun.api.schemas.Auth
618
814
  return
619
815
 
620
816
  if mlrun.mlconf.function.spec.security_context.enrichment_mode in [
621
- SecurityContextEnrichmentModes.override.value,
622
- SecurityContextEnrichmentModes.retain.value,
817
+ mlrun.common.schemas.SecurityContextEnrichmentModes.override.value,
818
+ mlrun.common.schemas.SecurityContextEnrichmentModes.retain.value,
623
819
  ]:
624
820
 
625
821
  # before iguazio 3.6 the user unix id is not passed in the session verification response headers
@@ -675,7 +871,7 @@ def ensure_function_security_context(function, auth_info: mlrun.api.schemas.Auth
675
871
 
676
872
 
677
873
  def submit_run_sync(
678
- db_session: Session, auth_info: mlrun.api.schemas.AuthInfo, data
874
+ db_session: Session, auth_info: mlrun.common.schemas.AuthInfo, data
679
875
  ) -> typing.Tuple[str, str, str, typing.Dict]:
680
876
  """
681
877
  :return: Tuple with:
@@ -705,10 +901,19 @@ def submit_run_sync(
705
901
  if schedule:
706
902
  cron_trigger = schedule
707
903
  if isinstance(cron_trigger, dict):
708
- cron_trigger = schemas.ScheduleCronTrigger(**cron_trigger)
904
+ cron_trigger = mlrun.common.schemas.ScheduleCronTrigger(**cron_trigger)
709
905
  schedule_labels = task["metadata"].get("labels")
710
906
  created = False
711
907
 
908
+ # if the task is pointing to a remote function (hub://), we need to save it to the db
909
+ # and update the task to point to the saved function, so that the scheduler will be able to
910
+ # access the db version of the function, and not the remote one (which can be changed between runs)
911
+ if "://" in task["spec"]["function"]:
912
+ function_uri = fn.save(versioned=True)
913
+ data.pop("function", None)
914
+ data.pop("function_url", None)
915
+ task["spec"]["function"] = function_uri.replace("db://", "")
916
+
712
917
  try:
713
918
  get_scheduler().update_schedule(
714
919
  db_session,
@@ -720,13 +925,17 @@ def submit_run_sync(
720
925
  schedule_labels,
721
926
  )
722
927
  except mlrun.errors.MLRunNotFoundError:
723
- logger.debug("No existing schedule found, creating a new one")
928
+ logger.debug(
929
+ "No existing schedule found, creating a new one",
930
+ project=task["metadata"]["project"],
931
+ name=task["metadata"]["name"],
932
+ )
724
933
  get_scheduler().create_schedule(
725
934
  db_session,
726
935
  auth_info,
727
936
  task["metadata"]["project"],
728
937
  task["metadata"]["name"],
729
- schemas.ScheduleKinds.job,
938
+ mlrun.common.schemas.ScheduleKinds.job,
730
939
  data,
731
940
  cron_trigger,
732
941
  schedule_labels,
@@ -748,7 +957,7 @@ def submit_run_sync(
748
957
  mlrun.api.crud.Secrets()
749
958
  .list_project_secrets(
750
959
  task["metadata"]["project"],
751
- mlrun.api.schemas.SecretProviderName.kubernetes,
960
+ mlrun.common.schemas.SecretProviderName.kubernetes,
752
961
  allow_secrets_from_k8s=True,
753
962
  )
754
963
  .secrets
mlrun/api/constants.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Iguazio
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.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Iguazio
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.
@@ -12,17 +12,20 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
- from .artifacts import Artifacts # noqa: F401
16
- from .client_spec import ClientSpec # noqa: F401
17
- from .clusterization_spec import ClusterizationSpec # noqa: F401
18
- from .feature_store import FeatureStore # noqa: F401
19
- from .functions import Functions # noqa: F401
20
- from .logs import Logs # noqa: F401
21
- from .marketplace import Marketplace # noqa: F401
22
- from .model_monitoring import ModelEndpoints, ModelEndpointStoreType # noqa: F401
23
- from .pipelines import Pipelines # noqa: F401
24
- from .projects import Projects # noqa: F401
25
- from .runs import Runs # noqa: F401
26
- from .runtime_resources import RuntimeResources # noqa: F401
27
- from .secrets import Secrets, SecretsClientType # noqa: F401
28
- from .tags import Tags # noqa: F401
15
+ # flake8: noqa: F401 - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
+
17
+ from .artifacts import Artifacts
18
+ from .client_spec import ClientSpec
19
+ from .clusterization_spec import ClusterizationSpec
20
+ from .feature_store import FeatureStore
21
+ from .functions import Functions
22
+ from .hub import Hub
23
+ from .logs import Logs
24
+ from .model_monitoring import ModelEndpoints
25
+ from .notifications import Notifications
26
+ from .pipelines import Pipelines
27
+ from .projects import Projects
28
+ from .runs import Runs
29
+ from .runtime_resources import RuntimeResources
30
+ from .secrets import Secrets, SecretsClientType
31
+ from .tags import Tags
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Iguazio
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.
@@ -16,14 +16,14 @@ import typing
16
16
 
17
17
  import sqlalchemy.orm
18
18
 
19
- import mlrun.api.schemas
20
19
  import mlrun.api.utils.projects.remotes.follower
21
20
  import mlrun.api.utils.singletons.db
22
21
  import mlrun.api.utils.singletons.project_member
22
+ import mlrun.common.schemas
23
+ import mlrun.common.schemas.artifact
23
24
  import mlrun.config
24
25
  import mlrun.errors
25
26
  import mlrun.utils.singleton
26
- from mlrun.api.schemas.artifact import ArtifactsFormat
27
27
 
28
28
 
29
29
  class Artifacts(
@@ -66,7 +66,7 @@ class Artifacts(
66
66
  tag: str = "latest",
67
67
  iter: int = 0,
68
68
  project: str = mlrun.mlconf.default_project,
69
- format_: ArtifactsFormat = ArtifactsFormat.full,
69
+ format_: mlrun.common.schemas.artifact.ArtifactsFormat = mlrun.common.schemas.artifact.ArtifactsFormat.full,
70
70
  ) -> dict:
71
71
  project = project or mlrun.mlconf.default_project
72
72
  artifact = mlrun.api.utils.singletons.db.get_db().read_artifact(
@@ -76,7 +76,7 @@ class Artifacts(
76
76
  iter,
77
77
  project,
78
78
  )
79
- if format_ == ArtifactsFormat.legacy:
79
+ if format_ == mlrun.common.schemas.artifact.ArtifactsFormat.legacy:
80
80
  return _transform_artifact_struct_to_legacy_format(artifact)
81
81
  return artifact
82
82
 
@@ -90,10 +90,10 @@ class Artifacts(
90
90
  since=None,
91
91
  until=None,
92
92
  kind: typing.Optional[str] = None,
93
- category: typing.Optional[mlrun.api.schemas.ArtifactCategories] = None,
93
+ category: typing.Optional[mlrun.common.schemas.ArtifactCategories] = None,
94
94
  iter: typing.Optional[int] = None,
95
95
  best_iteration: bool = False,
96
- format_: ArtifactsFormat = ArtifactsFormat.full,
96
+ format_: mlrun.common.schemas.artifact.ArtifactsFormat = mlrun.common.schemas.artifact.ArtifactsFormat.full,
97
97
  ) -> typing.List:
98
98
  project = project or mlrun.mlconf.default_project
99
99
  if labels is None:
@@ -111,7 +111,7 @@ class Artifacts(
111
111
  iter,
112
112
  best_iteration,
113
113
  )
114
- if format_ != ArtifactsFormat.legacy:
114
+ if format_ != mlrun.common.schemas.artifact.ArtifactsFormat.legacy:
115
115
  return artifacts
116
116
  return [
117
117
  _transform_artifact_struct_to_legacy_format(artifact)
@@ -122,7 +122,7 @@ class Artifacts(
122
122
  self,
123
123
  db_session: sqlalchemy.orm.Session,
124
124
  project: str = mlrun.mlconf.default_project,
125
- category: mlrun.api.schemas.ArtifactCategories = None,
125
+ category: mlrun.common.schemas.ArtifactCategories = None,
126
126
  ):
127
127
  project = project or mlrun.mlconf.default_project
128
128
  return mlrun.api.utils.singletons.db.get_db().list_artifact_tags(
@@ -148,7 +148,7 @@ class Artifacts(
148
148
  name: str = "",
149
149
  tag: str = "latest",
150
150
  labels: typing.List[str] = None,
151
- auth_info: mlrun.api.schemas.AuthInfo = mlrun.api.schemas.AuthInfo(),
151
+ auth_info: mlrun.common.schemas.AuthInfo = mlrun.common.schemas.AuthInfo(),
152
152
  ):
153
153
  project = project or mlrun.mlconf.default_project
154
154
  mlrun.api.utils.singletons.db.get_db().del_artifacts(
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Iguazio
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.
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
- import mlrun.api.schemas
15
+ import mlrun.common.schemas
16
16
  import mlrun.utils.singleton
17
17
  from mlrun.config import Config, config, default_config
18
18
  from mlrun.runtimes.utils import resolve_mpijob_crd_version, resolve_nuclio_version
@@ -24,8 +24,8 @@ class ClientSpec(
24
24
  def get_client_spec(
25
25
  self, client_version: str = None, client_python_version: str = None
26
26
  ):
27
- mpijob_crd_version = resolve_mpijob_crd_version(api_context=True)
28
- return mlrun.api.schemas.ClientSpec(
27
+ mpijob_crd_version = resolve_mpijob_crd_version()
28
+ return mlrun.common.schemas.ClientSpec(
29
29
  version=config.version,
30
30
  namespace=config.namespace,
31
31
  docker_registry=config.httpdb.builder.docker_registry,
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Iguazio
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.
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  import mlrun
16
- import mlrun.api.schemas
16
+ import mlrun.common.schemas
17
17
  import mlrun.utils.singleton
18
18
 
19
19
 
@@ -23,7 +23,7 @@ class ClusterizationSpec(
23
23
  @staticmethod
24
24
  def get_clusterization_spec():
25
25
  is_chief = mlrun.mlconf.httpdb.clusterization.role == "chief"
26
- return mlrun.api.schemas.ClusterizationSpec(
26
+ return mlrun.common.schemas.ClusterizationSpec(
27
27
  chief_api_state=mlrun.mlconf.httpdb.state if is_chief else None,
28
28
  chief_version=mlrun.mlconf.version if is_chief else None,
29
29
  )