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.
- mlrun/__init__.py +3 -3
- mlrun/__main__.py +79 -37
- mlrun/api/__init__.py +1 -1
- mlrun/api/api/__init__.py +1 -1
- mlrun/api/api/api.py +4 -4
- mlrun/api/api/deps.py +10 -21
- mlrun/api/api/endpoints/__init__.py +1 -1
- mlrun/api/api/endpoints/artifacts.py +64 -36
- mlrun/api/api/endpoints/auth.py +4 -4
- mlrun/api/api/endpoints/background_tasks.py +11 -11
- mlrun/api/api/endpoints/client_spec.py +5 -5
- mlrun/api/api/endpoints/clusterization_spec.py +6 -4
- mlrun/api/api/endpoints/feature_store.py +124 -115
- mlrun/api/api/endpoints/files.py +22 -14
- mlrun/api/api/endpoints/frontend_spec.py +28 -21
- mlrun/api/api/endpoints/functions.py +142 -87
- mlrun/api/api/endpoints/grafana_proxy.py +89 -442
- mlrun/api/api/endpoints/healthz.py +20 -7
- mlrun/api/api/endpoints/hub.py +320 -0
- mlrun/api/api/endpoints/internal/__init__.py +1 -1
- mlrun/api/api/endpoints/internal/config.py +1 -1
- mlrun/api/api/endpoints/internal/memory_reports.py +9 -9
- mlrun/api/api/endpoints/logs.py +11 -11
- mlrun/api/api/endpoints/model_endpoints.py +74 -70
- mlrun/api/api/endpoints/operations.py +13 -9
- mlrun/api/api/endpoints/pipelines.py +93 -88
- mlrun/api/api/endpoints/projects.py +35 -35
- mlrun/api/api/endpoints/runs.py +69 -27
- mlrun/api/api/endpoints/runtime_resources.py +28 -28
- mlrun/api/api/endpoints/schedules.py +98 -41
- mlrun/api/api/endpoints/secrets.py +37 -32
- mlrun/api/api/endpoints/submit.py +12 -12
- mlrun/api/api/endpoints/tags.py +20 -22
- mlrun/api/api/utils.py +251 -42
- mlrun/api/constants.py +1 -1
- mlrun/api/crud/__init__.py +18 -15
- mlrun/api/crud/artifacts.py +10 -10
- mlrun/api/crud/client_spec.py +4 -4
- mlrun/api/crud/clusterization_spec.py +3 -3
- mlrun/api/crud/feature_store.py +54 -46
- mlrun/api/crud/functions.py +3 -3
- mlrun/api/crud/hub.py +312 -0
- mlrun/api/crud/logs.py +11 -9
- mlrun/api/crud/model_monitoring/__init__.py +3 -3
- mlrun/api/crud/model_monitoring/grafana.py +435 -0
- mlrun/api/crud/model_monitoring/model_endpoints.py +352 -129
- mlrun/api/crud/notifications.py +149 -0
- mlrun/api/crud/pipelines.py +67 -52
- mlrun/api/crud/projects.py +51 -23
- mlrun/api/crud/runs.py +7 -5
- mlrun/api/crud/runtime_resources.py +13 -13
- mlrun/api/{db/filedb → crud/runtimes}/__init__.py +1 -1
- mlrun/api/crud/runtimes/nuclio/__init__.py +14 -0
- mlrun/api/crud/runtimes/nuclio/function.py +505 -0
- mlrun/api/crud/runtimes/nuclio/helpers.py +310 -0
- mlrun/api/crud/secrets.py +88 -46
- mlrun/api/crud/tags.py +5 -5
- mlrun/api/db/__init__.py +1 -1
- mlrun/api/db/base.py +102 -54
- mlrun/api/db/init_db.py +2 -3
- mlrun/api/db/session.py +4 -12
- mlrun/api/db/sqldb/__init__.py +1 -1
- mlrun/api/db/sqldb/db.py +439 -196
- mlrun/api/db/sqldb/helpers.py +1 -1
- mlrun/api/db/sqldb/models/__init__.py +3 -3
- mlrun/api/db/sqldb/models/models_mysql.py +82 -64
- mlrun/api/db/sqldb/models/models_sqlite.py +76 -64
- mlrun/api/db/sqldb/session.py +27 -20
- mlrun/api/initial_data.py +82 -24
- mlrun/api/launcher.py +196 -0
- mlrun/api/main.py +91 -22
- mlrun/api/middlewares.py +6 -5
- mlrun/api/migrations_mysql/env.py +1 -1
- mlrun/api/migrations_mysql/versions/28383af526f3_market_place_to_hub.py +40 -0
- mlrun/api/migrations_mysql/versions/32bae1b0e29c_increase_timestamp_fields_precision.py +1 -1
- mlrun/api/migrations_mysql/versions/4903aef6a91d_tag_foreign_key_and_cascades.py +1 -1
- mlrun/api/migrations_mysql/versions/5f1351c88a19_adding_background_tasks_table.py +1 -1
- mlrun/api/migrations_mysql/versions/88e656800d6a_add_requested_logs_column_and_index_to_.py +1 -1
- mlrun/api/migrations_mysql/versions/9d16de5f03a7_adding_data_versions_table.py +1 -1
- mlrun/api/migrations_mysql/versions/b86f5b53f3d7_adding_name_and_updated_to_runs_table.py +1 -1
- mlrun/api/migrations_mysql/versions/c4af40b0bf61_init.py +1 -1
- mlrun/api/migrations_mysql/versions/c905d15bd91d_notifications.py +72 -0
- mlrun/api/migrations_mysql/versions/ee041e8fdaa0_adding_next_run_time_column_to_schedule_.py +1 -1
- mlrun/api/migrations_sqlite/env.py +1 -1
- mlrun/api/migrations_sqlite/versions/11f8dd2dc9fe_init.py +1 -1
- mlrun/api/migrations_sqlite/versions/1c954f8cb32d_schedule_last_run_uri.py +1 -1
- mlrun/api/migrations_sqlite/versions/2b6d23c715aa_adding_feature_sets.py +1 -1
- mlrun/api/migrations_sqlite/versions/4acd9430b093_market_place_to_hub.py +77 -0
- mlrun/api/migrations_sqlite/versions/6401142f2d7c_adding_next_run_time_column_to_schedule_.py +1 -1
- mlrun/api/migrations_sqlite/versions/64d90a1a69bc_adding_background_tasks_table.py +1 -1
- mlrun/api/migrations_sqlite/versions/803438ecd005_add_requested_logs_column_to_runs.py +1 -1
- mlrun/api/migrations_sqlite/versions/863114f0c659_refactoring_feature_set.py +1 -1
- mlrun/api/migrations_sqlite/versions/959ae00528ad_notifications.py +63 -0
- mlrun/api/migrations_sqlite/versions/accf9fc83d38_adding_data_versions_table.py +1 -1
- mlrun/api/migrations_sqlite/versions/b68e8e897a28_schedule_labels.py +1 -1
- mlrun/api/migrations_sqlite/versions/bcd0c1f9720c_adding_project_labels.py +1 -1
- mlrun/api/migrations_sqlite/versions/cf21882f938e_schedule_id.py +1 -1
- mlrun/api/migrations_sqlite/versions/d781f58f607f_tag_object_name_string.py +1 -1
- mlrun/api/migrations_sqlite/versions/deac06871ace_adding_marketplace_sources_table.py +1 -1
- mlrun/api/migrations_sqlite/versions/e1dd5983c06b_schedule_concurrency_limit.py +1 -1
- mlrun/api/migrations_sqlite/versions/e5594ed3ab53_adding_name_and_updated_to_runs_table.py +1 -1
- mlrun/api/migrations_sqlite/versions/f4249b4ba6fa_adding_feature_vectors.py +1 -1
- mlrun/api/migrations_sqlite/versions/f7b5a1a03629_adding_feature_labels.py +1 -1
- mlrun/api/schemas/__init__.py +216 -138
- mlrun/api/utils/__init__.py +1 -1
- mlrun/api/utils/asyncio.py +1 -1
- mlrun/api/utils/auth/__init__.py +1 -1
- mlrun/api/utils/auth/providers/__init__.py +1 -1
- mlrun/api/utils/auth/providers/base.py +7 -7
- mlrun/api/utils/auth/providers/nop.py +6 -7
- mlrun/api/utils/auth/providers/opa.py +17 -17
- mlrun/api/utils/auth/verifier.py +36 -34
- mlrun/api/utils/background_tasks.py +24 -24
- mlrun/{builder.py → api/utils/builder.py} +216 -123
- mlrun/api/utils/clients/__init__.py +1 -1
- mlrun/api/utils/clients/chief.py +19 -4
- mlrun/api/utils/clients/iguazio.py +106 -60
- mlrun/api/utils/clients/log_collector.py +1 -1
- mlrun/api/utils/clients/nuclio.py +23 -23
- mlrun/api/utils/clients/protocols/grpc.py +2 -2
- mlrun/api/utils/db/__init__.py +1 -1
- mlrun/api/utils/db/alembic.py +1 -1
- mlrun/api/utils/db/backup.py +1 -1
- mlrun/api/utils/db/mysql.py +24 -25
- mlrun/api/utils/db/sql_collation.py +1 -1
- mlrun/api/utils/db/sqlite_migration.py +2 -2
- mlrun/api/utils/events/__init__.py +14 -0
- mlrun/api/utils/events/base.py +57 -0
- mlrun/api/utils/events/events_factory.py +41 -0
- mlrun/api/utils/events/iguazio.py +217 -0
- mlrun/api/utils/events/nop.py +55 -0
- mlrun/api/utils/helpers.py +16 -13
- mlrun/api/utils/memory_reports.py +1 -1
- mlrun/api/utils/periodic.py +6 -3
- mlrun/api/utils/projects/__init__.py +1 -1
- mlrun/api/utils/projects/follower.py +33 -33
- mlrun/api/utils/projects/leader.py +36 -34
- mlrun/api/utils/projects/member.py +27 -27
- mlrun/api/utils/projects/remotes/__init__.py +1 -1
- mlrun/api/utils/projects/remotes/follower.py +13 -13
- mlrun/api/utils/projects/remotes/leader.py +10 -10
- mlrun/api/utils/projects/remotes/nop_follower.py +27 -21
- mlrun/api/utils/projects/remotes/nop_leader.py +17 -16
- mlrun/api/utils/scheduler.py +140 -51
- mlrun/api/utils/singletons/__init__.py +1 -1
- mlrun/api/utils/singletons/db.py +9 -15
- mlrun/api/utils/singletons/k8s.py +677 -5
- mlrun/api/utils/singletons/logs_dir.py +1 -1
- mlrun/api/utils/singletons/project_member.py +1 -1
- mlrun/api/utils/singletons/scheduler.py +1 -1
- mlrun/artifacts/__init__.py +2 -2
- mlrun/artifacts/base.py +8 -2
- mlrun/artifacts/dataset.py +5 -3
- mlrun/artifacts/manager.py +7 -1
- mlrun/artifacts/model.py +15 -4
- mlrun/artifacts/plots.py +1 -1
- mlrun/common/__init__.py +1 -1
- mlrun/common/constants.py +15 -0
- mlrun/common/model_monitoring.py +209 -0
- mlrun/common/schemas/__init__.py +167 -0
- mlrun/{api → common}/schemas/artifact.py +13 -14
- mlrun/{api → common}/schemas/auth.py +10 -8
- mlrun/{api → common}/schemas/background_task.py +3 -3
- mlrun/{api → common}/schemas/client_spec.py +1 -1
- mlrun/{api → common}/schemas/clusterization_spec.py +3 -3
- mlrun/{api → common}/schemas/constants.py +21 -8
- mlrun/common/schemas/events.py +36 -0
- mlrun/{api → common}/schemas/feature_store.py +2 -1
- mlrun/{api → common}/schemas/frontend_spec.py +7 -6
- mlrun/{api → common}/schemas/function.py +5 -5
- mlrun/{api → common}/schemas/http.py +3 -3
- mlrun/common/schemas/hub.py +134 -0
- mlrun/{api → common}/schemas/k8s.py +3 -3
- mlrun/{api → common}/schemas/memory_reports.py +1 -1
- mlrun/common/schemas/model_endpoints.py +342 -0
- mlrun/common/schemas/notification.py +57 -0
- mlrun/{api → common}/schemas/object.py +6 -6
- mlrun/{api → common}/schemas/pipeline.py +3 -3
- mlrun/{api → common}/schemas/project.py +6 -5
- mlrun/common/schemas/regex.py +24 -0
- mlrun/common/schemas/runs.py +30 -0
- mlrun/{api → common}/schemas/runtime_resource.py +3 -3
- mlrun/{api → common}/schemas/schedule.py +19 -7
- mlrun/{api → common}/schemas/secret.py +3 -3
- mlrun/{api → common}/schemas/tag.py +2 -2
- mlrun/common/types.py +25 -0
- mlrun/config.py +152 -20
- mlrun/data_types/__init__.py +7 -2
- mlrun/data_types/data_types.py +4 -2
- mlrun/data_types/infer.py +1 -1
- mlrun/data_types/spark.py +10 -3
- mlrun/datastore/__init__.py +10 -3
- mlrun/datastore/azure_blob.py +1 -1
- mlrun/datastore/base.py +185 -53
- mlrun/datastore/datastore.py +1 -1
- mlrun/datastore/filestore.py +1 -1
- mlrun/datastore/google_cloud_storage.py +1 -1
- mlrun/datastore/inmem.py +4 -1
- mlrun/datastore/redis.py +1 -1
- mlrun/datastore/s3.py +1 -1
- mlrun/datastore/sources.py +192 -70
- mlrun/datastore/spark_udf.py +44 -0
- mlrun/datastore/store_resources.py +4 -4
- mlrun/datastore/targets.py +115 -45
- mlrun/datastore/utils.py +127 -5
- mlrun/datastore/v3io.py +1 -1
- mlrun/datastore/wasbfs/__init__.py +1 -1
- mlrun/datastore/wasbfs/fs.py +1 -1
- mlrun/db/__init__.py +7 -5
- mlrun/db/base.py +112 -68
- mlrun/db/httpdb.py +445 -277
- mlrun/db/nopdb.py +491 -0
- mlrun/db/sqldb.py +112 -65
- mlrun/errors.py +6 -1
- mlrun/execution.py +44 -22
- mlrun/feature_store/__init__.py +1 -1
- mlrun/feature_store/api.py +143 -95
- mlrun/feature_store/common.py +16 -20
- mlrun/feature_store/feature_set.py +42 -12
- mlrun/feature_store/feature_vector.py +32 -21
- mlrun/feature_store/ingestion.py +9 -12
- mlrun/feature_store/retrieval/__init__.py +3 -2
- mlrun/feature_store/retrieval/base.py +388 -66
- mlrun/feature_store/retrieval/dask_merger.py +63 -151
- mlrun/feature_store/retrieval/job.py +30 -12
- mlrun/feature_store/retrieval/local_merger.py +40 -133
- mlrun/feature_store/retrieval/spark_merger.py +129 -127
- mlrun/feature_store/retrieval/storey_merger.py +173 -0
- mlrun/feature_store/steps.py +132 -15
- mlrun/features.py +8 -3
- mlrun/frameworks/__init__.py +1 -1
- mlrun/frameworks/_common/__init__.py +1 -1
- mlrun/frameworks/_common/artifacts_library.py +1 -1
- mlrun/frameworks/_common/mlrun_interface.py +1 -1
- mlrun/frameworks/_common/model_handler.py +1 -1
- mlrun/frameworks/_common/plan.py +1 -1
- mlrun/frameworks/_common/producer.py +1 -1
- mlrun/frameworks/_common/utils.py +1 -1
- mlrun/frameworks/_dl_common/__init__.py +1 -1
- mlrun/frameworks/_dl_common/loggers/__init__.py +1 -1
- mlrun/frameworks/_dl_common/loggers/logger.py +1 -1
- mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +1 -1
- mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +1 -1
- mlrun/frameworks/_dl_common/model_handler.py +1 -1
- mlrun/frameworks/_dl_common/utils.py +1 -1
- mlrun/frameworks/_ml_common/__init__.py +1 -1
- mlrun/frameworks/_ml_common/artifacts_library.py +1 -1
- mlrun/frameworks/_ml_common/loggers/__init__.py +1 -1
- mlrun/frameworks/_ml_common/loggers/logger.py +1 -1
- mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +1 -1
- mlrun/frameworks/_ml_common/model_handler.py +1 -1
- mlrun/frameworks/_ml_common/pkl_model_server.py +13 -1
- mlrun/frameworks/_ml_common/plan.py +1 -1
- mlrun/frameworks/_ml_common/plans/__init__.py +1 -1
- mlrun/frameworks/_ml_common/plans/calibration_curve_plan.py +1 -6
- mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +1 -1
- mlrun/frameworks/_ml_common/plans/dataset_plan.py +1 -1
- mlrun/frameworks/_ml_common/plans/feature_importance_plan.py +1 -1
- mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +1 -1
- mlrun/frameworks/_ml_common/producer.py +1 -1
- mlrun/frameworks/_ml_common/utils.py +1 -1
- mlrun/frameworks/auto_mlrun/__init__.py +1 -1
- mlrun/frameworks/auto_mlrun/auto_mlrun.py +1 -1
- mlrun/frameworks/huggingface/__init__.py +1 -1
- mlrun/frameworks/huggingface/model_server.py +1 -1
- mlrun/frameworks/lgbm/__init__.py +1 -1
- mlrun/frameworks/lgbm/callbacks/__init__.py +1 -1
- mlrun/frameworks/lgbm/callbacks/callback.py +1 -1
- mlrun/frameworks/lgbm/callbacks/logging_callback.py +1 -1
- mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +1 -1
- mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -1
- mlrun/frameworks/lgbm/mlrun_interfaces/booster_mlrun_interface.py +1 -1
- mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +1 -1
- mlrun/frameworks/lgbm/mlrun_interfaces/model_mlrun_interface.py +1 -1
- mlrun/frameworks/lgbm/model_handler.py +1 -1
- mlrun/frameworks/lgbm/model_server.py +1 -1
- mlrun/frameworks/lgbm/utils.py +1 -1
- mlrun/frameworks/onnx/__init__.py +1 -1
- mlrun/frameworks/onnx/dataset.py +1 -1
- mlrun/frameworks/onnx/mlrun_interface.py +1 -1
- mlrun/frameworks/onnx/model_handler.py +1 -1
- mlrun/frameworks/onnx/model_server.py +1 -1
- mlrun/frameworks/parallel_coordinates.py +1 -1
- mlrun/frameworks/pytorch/__init__.py +1 -1
- mlrun/frameworks/pytorch/callbacks/__init__.py +1 -1
- mlrun/frameworks/pytorch/callbacks/callback.py +1 -1
- mlrun/frameworks/pytorch/callbacks/logging_callback.py +1 -1
- mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +1 -1
- mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +1 -1
- mlrun/frameworks/pytorch/callbacks_handler.py +1 -1
- mlrun/frameworks/pytorch/mlrun_interface.py +1 -1
- mlrun/frameworks/pytorch/model_handler.py +1 -1
- mlrun/frameworks/pytorch/model_server.py +1 -1
- mlrun/frameworks/pytorch/utils.py +1 -1
- mlrun/frameworks/sklearn/__init__.py +1 -1
- mlrun/frameworks/sklearn/estimator.py +1 -1
- mlrun/frameworks/sklearn/metric.py +1 -1
- mlrun/frameworks/sklearn/metrics_library.py +1 -1
- mlrun/frameworks/sklearn/mlrun_interface.py +1 -1
- mlrun/frameworks/sklearn/model_handler.py +1 -1
- mlrun/frameworks/sklearn/utils.py +1 -1
- mlrun/frameworks/tf_keras/__init__.py +1 -1
- mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -1
- mlrun/frameworks/tf_keras/callbacks/logging_callback.py +1 -1
- mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +1 -1
- mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +1 -1
- mlrun/frameworks/tf_keras/mlrun_interface.py +1 -1
- mlrun/frameworks/tf_keras/model_handler.py +1 -1
- mlrun/frameworks/tf_keras/model_server.py +1 -1
- mlrun/frameworks/tf_keras/utils.py +1 -1
- mlrun/frameworks/xgboost/__init__.py +1 -1
- mlrun/frameworks/xgboost/mlrun_interface.py +1 -1
- mlrun/frameworks/xgboost/model_handler.py +1 -1
- mlrun/frameworks/xgboost/utils.py +1 -1
- mlrun/k8s_utils.py +14 -765
- mlrun/kfpops.py +14 -17
- mlrun/launcher/__init__.py +13 -0
- mlrun/launcher/base.py +406 -0
- mlrun/launcher/client.py +159 -0
- mlrun/launcher/factory.py +50 -0
- mlrun/launcher/local.py +276 -0
- mlrun/launcher/remote.py +178 -0
- mlrun/lists.py +10 -2
- mlrun/mlutils/__init__.py +1 -1
- mlrun/mlutils/data.py +1 -1
- mlrun/mlutils/models.py +1 -1
- mlrun/mlutils/plots.py +1 -1
- mlrun/model.py +252 -14
- mlrun/model_monitoring/__init__.py +41 -0
- mlrun/model_monitoring/features_drift_table.py +1 -1
- mlrun/model_monitoring/helpers.py +123 -38
- mlrun/model_monitoring/model_endpoint.py +144 -0
- mlrun/model_monitoring/model_monitoring_batch.py +310 -259
- mlrun/model_monitoring/stores/__init__.py +106 -0
- mlrun/model_monitoring/stores/kv_model_endpoint_store.py +448 -0
- mlrun/model_monitoring/stores/model_endpoint_store.py +147 -0
- mlrun/model_monitoring/stores/models/__init__.py +23 -0
- mlrun/model_monitoring/stores/models/base.py +18 -0
- mlrun/model_monitoring/stores/models/mysql.py +100 -0
- mlrun/model_monitoring/stores/models/sqlite.py +98 -0
- mlrun/model_monitoring/stores/sql_model_endpoint_store.py +370 -0
- mlrun/model_monitoring/stream_processing_fs.py +239 -271
- mlrun/package/__init__.py +163 -0
- mlrun/package/context_handler.py +325 -0
- mlrun/package/errors.py +47 -0
- mlrun/package/packager.py +298 -0
- mlrun/{runtimes/package → package/packagers}/__init__.py +3 -1
- mlrun/package/packagers/default_packager.py +422 -0
- mlrun/package/packagers/numpy_packagers.py +612 -0
- mlrun/package/packagers/pandas_packagers.py +968 -0
- mlrun/package/packagers/python_standard_library_packagers.py +616 -0
- mlrun/package/packagers_manager.py +786 -0
- mlrun/package/utils/__init__.py +53 -0
- mlrun/package/utils/_archiver.py +226 -0
- mlrun/package/utils/_formatter.py +211 -0
- mlrun/package/utils/_pickler.py +234 -0
- mlrun/package/utils/_supported_format.py +71 -0
- mlrun/package/utils/log_hint_utils.py +93 -0
- mlrun/package/utils/type_hint_utils.py +298 -0
- mlrun/platforms/__init__.py +1 -1
- mlrun/platforms/iguazio.py +34 -2
- mlrun/platforms/other.py +1 -1
- mlrun/projects/__init__.py +1 -1
- mlrun/projects/operations.py +14 -9
- mlrun/projects/pipelines.py +31 -13
- mlrun/projects/project.py +762 -238
- mlrun/render.py +49 -19
- mlrun/run.py +57 -326
- mlrun/runtimes/__init__.py +3 -9
- mlrun/runtimes/base.py +247 -784
- mlrun/runtimes/constants.py +1 -1
- mlrun/runtimes/daskjob.py +45 -41
- mlrun/runtimes/funcdoc.py +43 -7
- mlrun/runtimes/function.py +66 -656
- mlrun/runtimes/function_reference.py +1 -1
- mlrun/runtimes/generators.py +1 -1
- mlrun/runtimes/kubejob.py +99 -116
- mlrun/runtimes/local.py +59 -66
- mlrun/runtimes/mpijob/__init__.py +1 -1
- mlrun/runtimes/mpijob/abstract.py +13 -15
- mlrun/runtimes/mpijob/v1.py +3 -1
- mlrun/runtimes/mpijob/v1alpha1.py +1 -1
- mlrun/runtimes/nuclio.py +1 -1
- mlrun/runtimes/pod.py +51 -26
- mlrun/runtimes/remotesparkjob.py +3 -1
- mlrun/runtimes/serving.py +12 -4
- mlrun/runtimes/sparkjob/__init__.py +1 -2
- mlrun/runtimes/sparkjob/abstract.py +44 -31
- mlrun/runtimes/sparkjob/spark3job.py +11 -9
- mlrun/runtimes/utils.py +61 -42
- mlrun/secrets.py +16 -18
- mlrun/serving/__init__.py +3 -2
- mlrun/serving/merger.py +1 -1
- mlrun/serving/remote.py +1 -1
- mlrun/serving/routers.py +39 -42
- mlrun/serving/server.py +23 -13
- mlrun/serving/serving_wrapper.py +1 -1
- mlrun/serving/states.py +172 -39
- mlrun/serving/utils.py +1 -1
- mlrun/serving/v1_serving.py +1 -1
- mlrun/serving/v2_serving.py +29 -21
- mlrun/utils/__init__.py +1 -2
- mlrun/utils/async_http.py +8 -1
- mlrun/utils/azure_vault.py +1 -1
- mlrun/utils/clones.py +2 -2
- mlrun/utils/condition_evaluator.py +65 -0
- mlrun/utils/db.py +52 -0
- mlrun/utils/helpers.py +188 -13
- mlrun/utils/http.py +89 -54
- mlrun/utils/logger.py +48 -8
- mlrun/utils/model_monitoring.py +132 -100
- mlrun/utils/notifications/__init__.py +1 -1
- mlrun/utils/notifications/notification/__init__.py +8 -6
- mlrun/utils/notifications/notification/base.py +20 -14
- mlrun/utils/notifications/notification/console.py +7 -4
- mlrun/utils/notifications/notification/git.py +36 -19
- mlrun/utils/notifications/notification/ipython.py +10 -8
- mlrun/utils/notifications/notification/slack.py +18 -13
- mlrun/utils/notifications/notification_pusher.py +377 -56
- mlrun/utils/regex.py +6 -1
- mlrun/utils/singleton.py +1 -1
- mlrun/utils/v3io_clients.py +1 -1
- mlrun/utils/vault.py +270 -269
- mlrun/utils/version/__init__.py +1 -1
- mlrun/utils/version/version.json +2 -2
- mlrun/utils/version/version.py +1 -1
- {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/METADATA +16 -10
- mlrun-1.4.0.dist-info/RECORD +434 -0
- mlrun/api/api/endpoints/marketplace.py +0 -257
- mlrun/api/crud/marketplace.py +0 -221
- mlrun/api/crud/model_monitoring/model_endpoint_store.py +0 -847
- mlrun/api/db/filedb/db.py +0 -518
- mlrun/api/schemas/marketplace.py +0 -128
- mlrun/api/schemas/model_endpoints.py +0 -185
- mlrun/db/filedb.py +0 -891
- mlrun/feature_store/retrieval/online.py +0 -92
- mlrun/model_monitoring/constants.py +0 -67
- mlrun/runtimes/package/context_handler.py +0 -711
- mlrun/runtimes/sparkjob/spark2job.py +0 -59
- mlrun-1.3.3rc1.dist-info/RECORD +0 -381
- {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/LICENSE +0 -0
- {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/WHEEL +0 -0
- {mlrun-1.3.3rc1.dist-info → mlrun-1.4.0.dist-info}/entry_points.txt +0 -0
- {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
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
|
|
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.
|
|
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(
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
326
|
-
provider=mlrun.
|
|
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.
|
|
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.
|
|
416
|
-
provider=mlrun.
|
|
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 =
|
|
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.
|
|
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.
|
|
479
|
-
provider=mlrun.
|
|
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 =
|
|
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.
|
|
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(
|
|
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(
|
|
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.
|
|
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(
|
|
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.
|
|
960
|
+
mlrun.common.schemas.SecretProviderName.kubernetes,
|
|
752
961
|
allow_secrets_from_k8s=True,
|
|
753
962
|
)
|
|
754
963
|
.secrets
|
mlrun/api/constants.py
CHANGED
mlrun/api/crud/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
from .
|
|
18
|
-
from .
|
|
19
|
-
from .
|
|
20
|
-
from .
|
|
21
|
-
from .
|
|
22
|
-
from .
|
|
23
|
-
from .
|
|
24
|
-
from .
|
|
25
|
-
from .
|
|
26
|
-
from .
|
|
27
|
-
from .
|
|
28
|
-
from .
|
|
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
|
mlrun/api/crud/artifacts.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
mlrun/api/crud/client_spec.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
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.
|
|
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(
|
|
28
|
-
return mlrun.
|
|
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
|
|
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.
|
|
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.
|
|
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
|
)
|