mlrun 1.3.3__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.3.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.3.dist-info/RECORD +0 -381
- {mlrun-1.3.3.dist-info → mlrun-1.4.0.dist-info}/LICENSE +0 -0
- {mlrun-1.3.3.dist-info → mlrun-1.4.0.dist-info}/WHEEL +0 -0
- {mlrun-1.3.3.dist-info → mlrun-1.4.0.dist-info}/entry_points.txt +0 -0
- {mlrun-1.3.3.dist-info → mlrun-1.4.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Copyright 2023 Iguazio
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
# flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
|
|
17
|
+
|
|
18
|
+
import functools
|
|
19
|
+
import inspect
|
|
20
|
+
from collections import OrderedDict
|
|
21
|
+
from typing import Callable, Dict, List, Type, Union
|
|
22
|
+
|
|
23
|
+
from ..config import config
|
|
24
|
+
from .context_handler import ContextHandler
|
|
25
|
+
from .errors import (
|
|
26
|
+
MLRunPackageCollectionError,
|
|
27
|
+
MLRunPackageError,
|
|
28
|
+
MLRunPackagePackingError,
|
|
29
|
+
MLRunPackageUnpackingError,
|
|
30
|
+
)
|
|
31
|
+
from .packager import Packager
|
|
32
|
+
from .packagers import DefaultPackager
|
|
33
|
+
from .packagers_manager import PackagersManager
|
|
34
|
+
from .utils import (
|
|
35
|
+
ArchiveSupportedFormat,
|
|
36
|
+
ArtifactType,
|
|
37
|
+
LogHintKey,
|
|
38
|
+
StructFileSupportedFormat,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def handler(
|
|
43
|
+
labels: Dict[str, str] = None,
|
|
44
|
+
outputs: List[Union[str, Dict[str, str]]] = None,
|
|
45
|
+
inputs: Union[bool, Dict[str, Union[str, Type]]] = True,
|
|
46
|
+
):
|
|
47
|
+
"""
|
|
48
|
+
MLRun's handler is a decorator to wrap a function and enable setting labels, parsing inputs (`mlrun.DataItem`) using
|
|
49
|
+
type hints and log returning outputs using log hints.
|
|
50
|
+
|
|
51
|
+
Notice: this decorator is now appplied automatically with the release of `mlrun.package`. It should not be used
|
|
52
|
+
manually.
|
|
53
|
+
|
|
54
|
+
:param labels: Labels to add to the run. Expecting a dictionary with the labels names as keys. Default: None.
|
|
55
|
+
:param outputs: Log hints (logging configurations) for the function's returned values. Expecting a list of the
|
|
56
|
+
following values:
|
|
57
|
+
|
|
58
|
+
* `str` - A string in the format of '{key}:{artifact_type}'. If a string was given without ':' it
|
|
59
|
+
will indicate the key, and the artifact type will be according to the returned value type's
|
|
60
|
+
default artifact type. The artifact types supported are listed in the relevant type packager.
|
|
61
|
+
* `Dict[str, str]` - A dictionary of logging configuration. the key 'key' is mandatory for the
|
|
62
|
+
logged artifact key.
|
|
63
|
+
* None - Do not log the output.
|
|
64
|
+
|
|
65
|
+
If the list length is not equal to the total amount of returned values from the function, those
|
|
66
|
+
without log hints will be ignored.
|
|
67
|
+
|
|
68
|
+
Default: None - meaning no outputs will be logged.
|
|
69
|
+
|
|
70
|
+
:param inputs: Type hints (parsing configurations) for the arguments passed as inputs via the `run` method of an
|
|
71
|
+
MLRun function. Can be passed as a boolean value or a dictionary:
|
|
72
|
+
|
|
73
|
+
* True - Parse all found inputs to the assigned type hint in the function's signature. If there is no
|
|
74
|
+
type hint assigned, the value will remain an `mlrun.DataItem`.
|
|
75
|
+
* False - Do not parse inputs, leaving the inputs as `mlrun.DataItem`.
|
|
76
|
+
* Dict[str, Union[Type, str]] - A dictionary with argument name as key and the expected type to parse
|
|
77
|
+
the `mlrun.DataItem` to. The expected type can be a string as well, idicating the full module path.
|
|
78
|
+
|
|
79
|
+
Default: True - meaning inputs will be parsed from `DataItem`s as long as they are type hinted.
|
|
80
|
+
|
|
81
|
+
Example::
|
|
82
|
+
|
|
83
|
+
import mlrun
|
|
84
|
+
|
|
85
|
+
@mlrun.handler(
|
|
86
|
+
outputs=[
|
|
87
|
+
"my_string",
|
|
88
|
+
None,
|
|
89
|
+
{"key": "my_array", "artifact_type": "file", "file_format": "npy"},
|
|
90
|
+
"my_multiplier: reuslt"
|
|
91
|
+
]
|
|
92
|
+
)
|
|
93
|
+
def my_handler(array: np.ndarray, m: int):
|
|
94
|
+
m += 1
|
|
95
|
+
array = array * m
|
|
96
|
+
return "I will be logged", "I won't be logged", array, m
|
|
97
|
+
|
|
98
|
+
>>> mlrun_function = mlrun.code_to_function("my_code.py", kind="job")
|
|
99
|
+
>>> run_object = mlrun_function.run(
|
|
100
|
+
... handler="my_handler",
|
|
101
|
+
... inputs={"array": "store://my_array_Artifact"},
|
|
102
|
+
... params={"m": 2}
|
|
103
|
+
... )
|
|
104
|
+
>>> run_object.outputs
|
|
105
|
+
{'my_string': 'I will be logged', 'my_array': 'store://...', 'my_multiplier': 3}
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
def decorator(func: Callable):
|
|
109
|
+
def wrapper(*args: tuple, **kwargs: dict):
|
|
110
|
+
nonlocal labels
|
|
111
|
+
nonlocal outputs
|
|
112
|
+
nonlocal inputs
|
|
113
|
+
|
|
114
|
+
# Set default `inputs` - inspect the full signature and add the user's input on top of it:
|
|
115
|
+
if inputs:
|
|
116
|
+
# Get the available parameters type hints from the function's signature:
|
|
117
|
+
func_signature = inspect.signature(func)
|
|
118
|
+
parameters = OrderedDict(
|
|
119
|
+
{
|
|
120
|
+
parameter.name: parameter.annotation
|
|
121
|
+
for parameter in func_signature.parameters.values()
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
# If user input is given, add it on top of the collected defaults (from signature):
|
|
125
|
+
if isinstance(inputs, dict):
|
|
126
|
+
parameters.update(inputs)
|
|
127
|
+
inputs = parameters
|
|
128
|
+
|
|
129
|
+
# Create a context handler and look for a context:
|
|
130
|
+
cxt_handler = ContextHandler()
|
|
131
|
+
cxt_handler.look_for_context(args=args, kwargs=kwargs)
|
|
132
|
+
|
|
133
|
+
# If an MLRun context is found, parse arguments pre-run (kwargs are parsed inplace):
|
|
134
|
+
if cxt_handler.is_context_available() and inputs:
|
|
135
|
+
args = cxt_handler.parse_inputs(
|
|
136
|
+
args=args, kwargs=kwargs, type_hints=inputs
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Call the original function and get the returning values:
|
|
140
|
+
func_outputs = func(*args, **kwargs)
|
|
141
|
+
|
|
142
|
+
# If an MLRun context is found, set the given labels and log the returning values to MLRun via the context:
|
|
143
|
+
if cxt_handler.is_context_available():
|
|
144
|
+
if labels:
|
|
145
|
+
# TODO: Should deprecate this labels
|
|
146
|
+
cxt_handler.set_labels(labels=labels)
|
|
147
|
+
if outputs:
|
|
148
|
+
cxt_handler.log_outputs(
|
|
149
|
+
outputs=func_outputs
|
|
150
|
+
if type(func_outputs) is tuple
|
|
151
|
+
and not config.packagers.pack_tuples
|
|
152
|
+
else [func_outputs],
|
|
153
|
+
log_hints=outputs,
|
|
154
|
+
)
|
|
155
|
+
return # Do not return any values as the returning values were logged to MLRun.
|
|
156
|
+
return func_outputs
|
|
157
|
+
|
|
158
|
+
# Make sure to pass the wrapped function's signature (argument list, type hints and doc strings) to the wrapper:
|
|
159
|
+
wrapper = functools.wraps(func)(wrapper)
|
|
160
|
+
|
|
161
|
+
return wrapper
|
|
162
|
+
|
|
163
|
+
return decorator
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Copyright 2023 Iguazio
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
import inspect
|
|
16
|
+
import os
|
|
17
|
+
from collections import OrderedDict
|
|
18
|
+
from typing import Dict, List, Union
|
|
19
|
+
|
|
20
|
+
from mlrun.datastore import DataItem
|
|
21
|
+
from mlrun.errors import MLRunInvalidArgumentError
|
|
22
|
+
from mlrun.execution import MLClientCtx
|
|
23
|
+
from mlrun.run import get_or_create_ctx
|
|
24
|
+
|
|
25
|
+
from .errors import MLRunPackageCollectionError, MLRunPackagePackingError
|
|
26
|
+
from .packagers_manager import PackagersManager
|
|
27
|
+
from .utils import ArtifactType, LogHintKey, LogHintUtils, TypeHintUtils
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ContextHandler:
|
|
31
|
+
"""
|
|
32
|
+
A class for handling a MLRun context of a function that is wrapped in MLRun's `handler` decorator.
|
|
33
|
+
|
|
34
|
+
The context handler have 3 duties:
|
|
35
|
+
1. Check if the user used MLRun to run the wrapped function and if so, get the MLRun context.
|
|
36
|
+
2. Parse the user's inputs (MLRun `DataItem`) to the function.
|
|
37
|
+
3. Log the function's outputs to MLRun.
|
|
38
|
+
|
|
39
|
+
The context handler uses a packagers manager to unpack (parse) the inputs and pack (log) the outputs. It sets up a
|
|
40
|
+
manager with all the packagers in the `mlrun.package.packagers` directory. Packagers whom are in charge of modules
|
|
41
|
+
that are in the MLRun requirements are mandatory and additional extensions packagers for non-required modules are
|
|
42
|
+
added if the modules are available in the user's interpreter. Once a context is found, project custom packagers will
|
|
43
|
+
be added as well.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
# Mandatory packagers to be collected at initialization time:
|
|
47
|
+
_MLRUN_REQUIREMENTS_PACKAGERS = [
|
|
48
|
+
"python_standard_library",
|
|
49
|
+
"pandas",
|
|
50
|
+
"numpy",
|
|
51
|
+
]
|
|
52
|
+
# Optional packagers to be collected at initialization time:
|
|
53
|
+
_EXTENDED_PACKAGERS = [] # TODO: Create "matplotlib", "plotly", "bokeh" packagers.
|
|
54
|
+
# Optional packagers from the `mlrun.frameworks` package:
|
|
55
|
+
_MLRUN_FRAMEWORKS_PACKAGERS = [] # TODO: Create frameworks packagers.
|
|
56
|
+
# Default priority values for packagers:
|
|
57
|
+
_BUILTIN_PACKAGERS_DEFAULT_PRIORITY = 5
|
|
58
|
+
_CUSTOM_PACKAGERS_DEFAULT_PRIORITY = 3
|
|
59
|
+
|
|
60
|
+
def __init__(self):
|
|
61
|
+
"""
|
|
62
|
+
Initialize a context handler.
|
|
63
|
+
"""
|
|
64
|
+
# Set up a variable to hold the context:
|
|
65
|
+
self._context: MLClientCtx = None
|
|
66
|
+
|
|
67
|
+
# Initialize a packagers manager:
|
|
68
|
+
self._packagers_manager = PackagersManager()
|
|
69
|
+
|
|
70
|
+
# Prepare the manager (collect the MLRun builtin standard and optional packagers):
|
|
71
|
+
self._collect_mlrun_packagers()
|
|
72
|
+
|
|
73
|
+
def look_for_context(self, args: tuple, kwargs: dict):
|
|
74
|
+
"""
|
|
75
|
+
Look for an MLRun context (`mlrun.MLClientCtx`). The handler will look for a context in the given order:
|
|
76
|
+
1. The given arguments.
|
|
77
|
+
2. The given keyword arguments.
|
|
78
|
+
3. If an MLRun RunTime was used the context will be located via the `mlrun.get_or_create_ctx` method.
|
|
79
|
+
|
|
80
|
+
:param args: The arguments tuple passed to the function.
|
|
81
|
+
:param kwargs: The keyword arguments dictionary passed to the function.
|
|
82
|
+
"""
|
|
83
|
+
# Search in the given arguments:
|
|
84
|
+
for argument in args:
|
|
85
|
+
if isinstance(argument, MLClientCtx):
|
|
86
|
+
self._context = argument
|
|
87
|
+
break
|
|
88
|
+
|
|
89
|
+
# Search in the given keyword arguments:
|
|
90
|
+
if self._context is None:
|
|
91
|
+
for argument_name, argument_value in kwargs.items():
|
|
92
|
+
if isinstance(argument_value, MLClientCtx):
|
|
93
|
+
self._context = argument_value
|
|
94
|
+
break
|
|
95
|
+
|
|
96
|
+
# Search if the function was triggered from an MLRun RunTime object by looking at the call stack:
|
|
97
|
+
# Index 0: the current frame.
|
|
98
|
+
# Index 1: the decorator's frame.
|
|
99
|
+
# Index 2-...: If it is from mlrun.runtimes we can be sure it ran via MLRun, otherwise not.
|
|
100
|
+
if self._context is None:
|
|
101
|
+
for callstack_frame in inspect.getouterframes(inspect.currentframe()):
|
|
102
|
+
if (
|
|
103
|
+
os.path.join("mlrun", "runtimes", "local")
|
|
104
|
+
in callstack_frame.filename
|
|
105
|
+
):
|
|
106
|
+
self._context = get_or_create_ctx("context")
|
|
107
|
+
break
|
|
108
|
+
|
|
109
|
+
# Give the packagers manager custom packagers to collect (if a context is found and a project is available):
|
|
110
|
+
if self._context is not None and self._context.project:
|
|
111
|
+
# Get the custom packagers property from the project's spec:
|
|
112
|
+
project = self._context.get_project_object()
|
|
113
|
+
if project and project.spec.custom_packagers:
|
|
114
|
+
# Add the custom packagers taking into account the mandatory flag:
|
|
115
|
+
for custom_packager, is_mandatory in project.spec.custom_packagers:
|
|
116
|
+
self._collect_packagers(
|
|
117
|
+
packagers=[custom_packager],
|
|
118
|
+
is_mandatory=is_mandatory,
|
|
119
|
+
is_custom_packagers=True,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def is_context_available(self) -> bool:
|
|
123
|
+
"""
|
|
124
|
+
Check if a context was found by the method `look_for_context`.
|
|
125
|
+
|
|
126
|
+
:returns: True if a context was found and False otherwise.
|
|
127
|
+
"""
|
|
128
|
+
return self._context is not None
|
|
129
|
+
|
|
130
|
+
def parse_inputs(
|
|
131
|
+
self,
|
|
132
|
+
args: tuple,
|
|
133
|
+
kwargs: dict,
|
|
134
|
+
type_hints: OrderedDict,
|
|
135
|
+
) -> tuple:
|
|
136
|
+
"""
|
|
137
|
+
Parse the given arguments and keyword arguments data items to the expected types.
|
|
138
|
+
|
|
139
|
+
:param args: The arguments tuple passed to the function.
|
|
140
|
+
:param kwargs: The keyword arguments dictionary passed to the function.
|
|
141
|
+
:param type_hints: An ordered dictionary of the expected types of arguments.
|
|
142
|
+
|
|
143
|
+
:returns: The parsed args (kwargs are parsed inplace).
|
|
144
|
+
"""
|
|
145
|
+
# Parse the type hints (in case some were given as strings):
|
|
146
|
+
type_hints = {
|
|
147
|
+
key: TypeHintUtils.parse_type_hint(type_hint=value)
|
|
148
|
+
for key, value in type_hints.items()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# Parse the arguments:
|
|
152
|
+
parsed_args = []
|
|
153
|
+
type_hints_keys = list(type_hints.keys())
|
|
154
|
+
for i, argument in enumerate(args):
|
|
155
|
+
if (
|
|
156
|
+
isinstance(argument, DataItem)
|
|
157
|
+
and type_hints[type_hints_keys[i]] is not inspect.Parameter.empty
|
|
158
|
+
):
|
|
159
|
+
parsed_args.append(
|
|
160
|
+
self._packagers_manager.unpack(
|
|
161
|
+
data_item=argument,
|
|
162
|
+
type_hint=type_hints[type_hints_keys[i]],
|
|
163
|
+
)
|
|
164
|
+
)
|
|
165
|
+
else:
|
|
166
|
+
parsed_args.append(argument)
|
|
167
|
+
parsed_args = tuple(parsed_args) # `args` is expected to be a tuple.
|
|
168
|
+
|
|
169
|
+
# Parse the keyword arguments:
|
|
170
|
+
for key, value in kwargs.items():
|
|
171
|
+
if (
|
|
172
|
+
isinstance(value, DataItem)
|
|
173
|
+
and type_hints[key] is not inspect.Parameter.empty
|
|
174
|
+
):
|
|
175
|
+
kwargs[key] = self._packagers_manager.unpack(
|
|
176
|
+
data_item=value, type_hint=type_hints[key]
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
return parsed_args
|
|
180
|
+
|
|
181
|
+
def log_outputs(
|
|
182
|
+
self,
|
|
183
|
+
outputs: list,
|
|
184
|
+
log_hints: List[Union[Dict[str, str], str, None]],
|
|
185
|
+
):
|
|
186
|
+
"""
|
|
187
|
+
Log the given outputs as artifacts (or results) with the stored context. Errors raised during the packing will
|
|
188
|
+
be ignored to not fail a run. A warning with the error wil be printed.
|
|
189
|
+
|
|
190
|
+
:param outputs: List of outputs to log.
|
|
191
|
+
:param log_hints: List of log hints (logging configurations) to use.
|
|
192
|
+
"""
|
|
193
|
+
# Verify the outputs and log hints are the same length:
|
|
194
|
+
if len(outputs) != len(log_hints):
|
|
195
|
+
self._context.logger.warn(
|
|
196
|
+
f"The amount of outputs objects returned from the function ({len(outputs)}) does not match the amount "
|
|
197
|
+
f"of provided log hints ({len(log_hints)})."
|
|
198
|
+
)
|
|
199
|
+
if len(outputs) > len(log_hints):
|
|
200
|
+
ignored_outputs = [str(output) for output in outputs[len(log_hints) :]]
|
|
201
|
+
self._context.logger.warn(
|
|
202
|
+
f"The following outputs will not be logged: {', '.join(ignored_outputs)}"
|
|
203
|
+
)
|
|
204
|
+
if len(outputs) < len(log_hints):
|
|
205
|
+
ignored_log_hints = [
|
|
206
|
+
str(log_hint) for log_hint in log_hints[len(outputs) :]
|
|
207
|
+
]
|
|
208
|
+
self._context.logger.warn(
|
|
209
|
+
f"The following log hints will be ignored: {', '.join(ignored_log_hints)}"
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
# Go over the outputs and pack them:
|
|
213
|
+
for obj, log_hint in zip(outputs, log_hints):
|
|
214
|
+
try:
|
|
215
|
+
# Check if needed to log (not None):
|
|
216
|
+
if log_hint is None:
|
|
217
|
+
continue
|
|
218
|
+
# Parse the log hint:
|
|
219
|
+
log_hint = LogHintUtils.parse_log_hint(log_hint=log_hint)
|
|
220
|
+
# Check if the object to log is None (None values are only logged if the artifact type is Result):
|
|
221
|
+
if (
|
|
222
|
+
obj is None
|
|
223
|
+
and log_hint.get(LogHintKey.ARTIFACT_TYPE, ArtifactType.RESULT)
|
|
224
|
+
!= ArtifactType.RESULT
|
|
225
|
+
):
|
|
226
|
+
continue
|
|
227
|
+
# Pack the object (we don't catch the returned package as we log it after we pack all the outputs to
|
|
228
|
+
# enable linking extra data of some artifacts):
|
|
229
|
+
self._packagers_manager.pack(obj=obj, log_hint=log_hint)
|
|
230
|
+
except (MLRunInvalidArgumentError, MLRunPackagePackingError) as error:
|
|
231
|
+
self._context.logger.warn(
|
|
232
|
+
f"Skipping logging an object with the log hint '{log_hint}' due to the following error:\n{error}"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# Link packages:
|
|
236
|
+
self._packagers_manager.link_packages(
|
|
237
|
+
additional_artifacts=self._context.artifacts,
|
|
238
|
+
additional_results=self._context.results,
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
# Log the packed results and artifacts:
|
|
242
|
+
self._context.log_results(results=self._packagers_manager.results)
|
|
243
|
+
for artifact in self._packagers_manager.artifacts:
|
|
244
|
+
self._context.log_artifact(item=artifact)
|
|
245
|
+
|
|
246
|
+
# Clear packagers outputs:
|
|
247
|
+
self._packagers_manager.clear_packagers_outputs()
|
|
248
|
+
|
|
249
|
+
def set_labels(self, labels: Dict[str, str]):
|
|
250
|
+
"""
|
|
251
|
+
Set the given labels with the stored context.
|
|
252
|
+
|
|
253
|
+
:param labels: The labels to set.
|
|
254
|
+
"""
|
|
255
|
+
for key, value in labels.items():
|
|
256
|
+
self._context.set_label(key=key, value=value)
|
|
257
|
+
|
|
258
|
+
def _collect_packagers(
|
|
259
|
+
self, packagers: List[str], is_mandatory: bool, is_custom_packagers: bool
|
|
260
|
+
):
|
|
261
|
+
"""
|
|
262
|
+
Collect packagers with the stored manager. The collection can ignore errors raised by setting the mandatory flag
|
|
263
|
+
to False.
|
|
264
|
+
|
|
265
|
+
:param packagers: The list of packagers to collect.
|
|
266
|
+
:param is_mandatory: Whether the packagers are mandatory for the context run.
|
|
267
|
+
:param is_custom_packagers: Whether the packagers to collect are user's custom or MLRun's builtins.
|
|
268
|
+
"""
|
|
269
|
+
try:
|
|
270
|
+
self._packagers_manager.collect_packagers(
|
|
271
|
+
packagers=packagers,
|
|
272
|
+
default_priority=self._CUSTOM_PACKAGERS_DEFAULT_PRIORITY
|
|
273
|
+
if is_custom_packagers
|
|
274
|
+
else self._BUILTIN_PACKAGERS_DEFAULT_PRIORITY,
|
|
275
|
+
)
|
|
276
|
+
except MLRunPackageCollectionError as error:
|
|
277
|
+
if is_mandatory:
|
|
278
|
+
raise error
|
|
279
|
+
else:
|
|
280
|
+
# If the packagers to collect were added manually by the user, the logger should write the collection
|
|
281
|
+
# issue as a warning. Otherwise - for mlrun builtin packagers, a debug message will do.
|
|
282
|
+
message = (
|
|
283
|
+
f"The given optional packagers '{packagers}' could not be imported due to the following error:\n"
|
|
284
|
+
f"'{error}'"
|
|
285
|
+
)
|
|
286
|
+
if is_custom_packagers:
|
|
287
|
+
self._context.logger.warn(message)
|
|
288
|
+
else:
|
|
289
|
+
self._context.logger.debug(message)
|
|
290
|
+
|
|
291
|
+
def _collect_mlrun_packagers(self):
|
|
292
|
+
"""
|
|
293
|
+
Collect MLRun's builtin packagers. That include all mandatory packagers whom in charge of MLRun's requirements
|
|
294
|
+
libraries, more optional commonly used libraries packagers and more `mlrun.frameworks` packagers. The priority
|
|
295
|
+
will be as follows (from higher to lower priority):
|
|
296
|
+
|
|
297
|
+
1. Optional `mlrun.frameworks` packagers
|
|
298
|
+
2. MLRun's optional packagers
|
|
299
|
+
3. MLRun's mandatory packagers (MLRun's requirements)
|
|
300
|
+
"""
|
|
301
|
+
# Collect MLRun's requirements packagers (mandatory):
|
|
302
|
+
self._collect_packagers(
|
|
303
|
+
packagers=[
|
|
304
|
+
f"mlrun.package.packagers.{module_name}_packagers.*"
|
|
305
|
+
for module_name in self._MLRUN_REQUIREMENTS_PACKAGERS
|
|
306
|
+
],
|
|
307
|
+
is_mandatory=True,
|
|
308
|
+
is_custom_packagers=False,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
# Add extra packagers for optional libraries:
|
|
312
|
+
for module_name in self._EXTENDED_PACKAGERS:
|
|
313
|
+
self._collect_packagers(
|
|
314
|
+
packagers=[f"mlrun.package.packagers.{module_name}_packagers.*"],
|
|
315
|
+
is_mandatory=False,
|
|
316
|
+
is_custom_packagers=False,
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
# Add extra packagers from `mlrun.frameworks` package:
|
|
320
|
+
for module_name in self._MLRUN_FRAMEWORKS_PACKAGERS:
|
|
321
|
+
self._collect_packagers(
|
|
322
|
+
packagers=[f"mlrun.frameworks.{module_name}.packagers.*"],
|
|
323
|
+
is_mandatory=False,
|
|
324
|
+
is_custom_packagers=False,
|
|
325
|
+
)
|
mlrun/package/errors.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright 2023 Iguazio
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
from mlrun.errors import MLRunBaseError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MLRunPackageError(MLRunBaseError):
|
|
19
|
+
"""
|
|
20
|
+
General error from `mlrun.package`.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class MLRunPackageCollectionError(MLRunPackageError):
|
|
27
|
+
"""
|
|
28
|
+
An error that may be raised during the collection of packagers the manager is assigned to do.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class MLRunPackagePackingError(MLRunPackageError):
|
|
35
|
+
"""
|
|
36
|
+
An error that may be raised during a `mlrun.Packager.pack` method.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class MLRunPackageUnpackingError(MLRunPackageError):
|
|
43
|
+
"""
|
|
44
|
+
An error that may be raised during a `mlrun.Packager.unpack` method.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
pass
|