mlrun 1.7.2rc4__py3-none-any.whl → 1.8.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 +26 -22
- mlrun/__main__.py +15 -16
- mlrun/alerts/alert.py +150 -15
- mlrun/api/schemas/__init__.py +1 -9
- mlrun/artifacts/__init__.py +2 -3
- mlrun/artifacts/base.py +62 -19
- mlrun/artifacts/dataset.py +17 -17
- mlrun/artifacts/document.py +454 -0
- mlrun/artifacts/manager.py +28 -18
- mlrun/artifacts/model.py +91 -59
- mlrun/artifacts/plots.py +2 -2
- mlrun/common/constants.py +8 -0
- mlrun/common/formatters/__init__.py +1 -0
- mlrun/common/formatters/artifact.py +1 -1
- mlrun/common/formatters/feature_set.py +2 -0
- mlrun/common/formatters/function.py +1 -0
- mlrun/{model_monitoring/db/stores/v3io_kv/__init__.py → common/formatters/model_endpoint.py} +17 -0
- mlrun/common/formatters/pipeline.py +1 -2
- mlrun/common/formatters/project.py +9 -0
- mlrun/common/model_monitoring/__init__.py +0 -5
- mlrun/common/model_monitoring/helpers.py +12 -62
- mlrun/common/runtimes/constants.py +25 -4
- mlrun/common/schemas/__init__.py +9 -5
- mlrun/common/schemas/alert.py +114 -19
- mlrun/common/schemas/api_gateway.py +3 -3
- mlrun/common/schemas/artifact.py +22 -9
- mlrun/common/schemas/auth.py +8 -4
- mlrun/common/schemas/background_task.py +7 -7
- mlrun/common/schemas/client_spec.py +4 -4
- mlrun/common/schemas/clusterization_spec.py +2 -2
- mlrun/common/schemas/common.py +53 -3
- mlrun/common/schemas/constants.py +15 -0
- mlrun/common/schemas/datastore_profile.py +1 -1
- mlrun/common/schemas/feature_store.py +9 -9
- mlrun/common/schemas/frontend_spec.py +4 -4
- mlrun/common/schemas/function.py +10 -10
- mlrun/common/schemas/hub.py +1 -1
- mlrun/common/schemas/k8s.py +3 -3
- mlrun/common/schemas/memory_reports.py +3 -3
- mlrun/common/schemas/model_monitoring/__init__.py +4 -8
- mlrun/common/schemas/model_monitoring/constants.py +127 -46
- mlrun/common/schemas/model_monitoring/grafana.py +18 -12
- mlrun/common/schemas/model_monitoring/model_endpoints.py +154 -160
- mlrun/common/schemas/notification.py +24 -3
- mlrun/common/schemas/object.py +1 -1
- mlrun/common/schemas/pagination.py +4 -4
- mlrun/common/schemas/partition.py +142 -0
- mlrun/common/schemas/pipeline.py +3 -3
- mlrun/common/schemas/project.py +26 -18
- mlrun/common/schemas/runs.py +3 -3
- mlrun/common/schemas/runtime_resource.py +5 -5
- mlrun/common/schemas/schedule.py +1 -1
- mlrun/common/schemas/secret.py +1 -1
- mlrun/{model_monitoring/db/stores/sqldb/__init__.py → common/schemas/serving.py} +10 -1
- mlrun/common/schemas/tag.py +3 -3
- mlrun/common/schemas/workflow.py +6 -5
- mlrun/common/types.py +1 -0
- mlrun/config.py +157 -89
- mlrun/data_types/__init__.py +5 -3
- mlrun/data_types/infer.py +13 -3
- mlrun/data_types/spark.py +2 -1
- mlrun/datastore/__init__.py +59 -18
- mlrun/datastore/alibaba_oss.py +4 -1
- mlrun/datastore/azure_blob.py +4 -1
- mlrun/datastore/base.py +19 -24
- mlrun/datastore/datastore.py +10 -4
- mlrun/datastore/datastore_profile.py +178 -45
- mlrun/datastore/dbfs_store.py +4 -1
- mlrun/datastore/filestore.py +4 -1
- mlrun/datastore/google_cloud_storage.py +4 -1
- mlrun/datastore/hdfs.py +4 -1
- mlrun/datastore/inmem.py +4 -1
- mlrun/datastore/redis.py +4 -1
- mlrun/datastore/s3.py +14 -3
- mlrun/datastore/sources.py +89 -92
- mlrun/datastore/store_resources.py +7 -4
- mlrun/datastore/storeytargets.py +51 -16
- mlrun/datastore/targets.py +38 -31
- mlrun/datastore/utils.py +87 -4
- mlrun/datastore/v3io.py +4 -1
- mlrun/datastore/vectorstore.py +291 -0
- mlrun/datastore/wasbfs/fs.py +13 -12
- mlrun/db/base.py +286 -100
- mlrun/db/httpdb.py +1562 -490
- mlrun/db/nopdb.py +250 -83
- mlrun/errors.py +6 -2
- mlrun/execution.py +194 -50
- mlrun/feature_store/__init__.py +2 -10
- mlrun/feature_store/api.py +20 -458
- mlrun/feature_store/common.py +9 -9
- mlrun/feature_store/feature_set.py +20 -18
- mlrun/feature_store/feature_vector.py +105 -479
- mlrun/feature_store/feature_vector_utils.py +466 -0
- mlrun/feature_store/retrieval/base.py +15 -11
- mlrun/feature_store/retrieval/job.py +2 -1
- mlrun/feature_store/retrieval/storey_merger.py +1 -1
- mlrun/feature_store/steps.py +3 -3
- mlrun/features.py +30 -13
- mlrun/frameworks/__init__.py +1 -2
- mlrun/frameworks/_common/__init__.py +1 -2
- mlrun/frameworks/_common/artifacts_library.py +2 -2
- mlrun/frameworks/_common/mlrun_interface.py +10 -6
- mlrun/frameworks/_common/model_handler.py +31 -31
- mlrun/frameworks/_common/producer.py +3 -1
- mlrun/frameworks/_dl_common/__init__.py +1 -2
- mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
- mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
- mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
- mlrun/frameworks/_ml_common/__init__.py +1 -2
- mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
- mlrun/frameworks/_ml_common/model_handler.py +21 -21
- mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
- mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
- mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
- mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
- mlrun/frameworks/auto_mlrun/__init__.py +1 -2
- mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
- mlrun/frameworks/huggingface/__init__.py +1 -2
- mlrun/frameworks/huggingface/model_server.py +9 -9
- mlrun/frameworks/lgbm/__init__.py +47 -44
- mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
- mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
- mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
- mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
- mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
- mlrun/frameworks/lgbm/model_handler.py +15 -11
- mlrun/frameworks/lgbm/model_server.py +11 -7
- mlrun/frameworks/lgbm/utils.py +2 -2
- mlrun/frameworks/onnx/__init__.py +1 -2
- mlrun/frameworks/onnx/dataset.py +3 -3
- mlrun/frameworks/onnx/mlrun_interface.py +2 -2
- mlrun/frameworks/onnx/model_handler.py +7 -5
- mlrun/frameworks/onnx/model_server.py +8 -6
- mlrun/frameworks/parallel_coordinates.py +11 -11
- mlrun/frameworks/pytorch/__init__.py +22 -23
- mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
- mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
- mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
- mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
- mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
- mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
- mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
- mlrun/frameworks/pytorch/model_handler.py +21 -17
- mlrun/frameworks/pytorch/model_server.py +13 -9
- mlrun/frameworks/sklearn/__init__.py +19 -18
- mlrun/frameworks/sklearn/estimator.py +2 -2
- mlrun/frameworks/sklearn/metric.py +3 -3
- mlrun/frameworks/sklearn/metrics_library.py +8 -6
- mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
- mlrun/frameworks/sklearn/model_handler.py +4 -3
- mlrun/frameworks/tf_keras/__init__.py +11 -12
- mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
- mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
- mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
- mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
- mlrun/frameworks/tf_keras/model_handler.py +17 -13
- mlrun/frameworks/tf_keras/model_server.py +12 -8
- mlrun/frameworks/xgboost/__init__.py +19 -18
- mlrun/frameworks/xgboost/model_handler.py +13 -9
- mlrun/k8s_utils.py +2 -5
- mlrun/launcher/base.py +3 -4
- mlrun/launcher/client.py +2 -2
- mlrun/launcher/local.py +6 -2
- mlrun/launcher/remote.py +1 -1
- mlrun/lists.py +8 -4
- mlrun/model.py +132 -46
- mlrun/model_monitoring/__init__.py +3 -5
- mlrun/model_monitoring/api.py +113 -98
- mlrun/model_monitoring/applications/__init__.py +0 -5
- mlrun/model_monitoring/applications/_application_steps.py +81 -50
- mlrun/model_monitoring/applications/base.py +467 -14
- mlrun/model_monitoring/applications/context.py +212 -134
- mlrun/model_monitoring/{db/stores/base → applications/evidently}/__init__.py +6 -2
- mlrun/model_monitoring/applications/evidently/base.py +146 -0
- mlrun/model_monitoring/applications/histogram_data_drift.py +89 -56
- mlrun/model_monitoring/applications/results.py +67 -15
- mlrun/model_monitoring/controller.py +701 -315
- mlrun/model_monitoring/db/__init__.py +0 -2
- mlrun/model_monitoring/db/_schedules.py +242 -0
- mlrun/model_monitoring/db/_stats.py +189 -0
- mlrun/model_monitoring/db/tsdb/__init__.py +33 -22
- mlrun/model_monitoring/db/tsdb/base.py +243 -49
- mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +76 -36
- mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connection.py +213 -0
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +534 -88
- mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
- mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +436 -106
- mlrun/model_monitoring/helpers.py +356 -114
- mlrun/model_monitoring/stream_processing.py +190 -345
- mlrun/model_monitoring/tracking_policy.py +11 -4
- mlrun/model_monitoring/writer.py +49 -90
- mlrun/package/__init__.py +3 -6
- mlrun/package/context_handler.py +2 -2
- mlrun/package/packager.py +12 -9
- mlrun/package/packagers/__init__.py +0 -2
- mlrun/package/packagers/default_packager.py +14 -11
- mlrun/package/packagers/numpy_packagers.py +16 -7
- mlrun/package/packagers/pandas_packagers.py +18 -18
- mlrun/package/packagers/python_standard_library_packagers.py +25 -11
- mlrun/package/packagers_manager.py +35 -32
- mlrun/package/utils/__init__.py +0 -3
- mlrun/package/utils/_pickler.py +6 -6
- mlrun/platforms/__init__.py +47 -16
- mlrun/platforms/iguazio.py +4 -1
- mlrun/projects/operations.py +30 -30
- mlrun/projects/pipelines.py +116 -47
- mlrun/projects/project.py +1292 -329
- mlrun/render.py +5 -9
- mlrun/run.py +57 -14
- mlrun/runtimes/__init__.py +1 -3
- mlrun/runtimes/base.py +30 -22
- mlrun/runtimes/daskjob.py +9 -9
- mlrun/runtimes/databricks_job/databricks_runtime.py +6 -5
- mlrun/runtimes/function_reference.py +5 -2
- mlrun/runtimes/generators.py +3 -2
- mlrun/runtimes/kubejob.py +6 -7
- mlrun/runtimes/mounts.py +574 -0
- mlrun/runtimes/mpijob/__init__.py +0 -2
- mlrun/runtimes/mpijob/abstract.py +7 -6
- mlrun/runtimes/nuclio/api_gateway.py +7 -7
- mlrun/runtimes/nuclio/application/application.py +11 -13
- mlrun/runtimes/nuclio/application/reverse_proxy.go +66 -64
- mlrun/runtimes/nuclio/function.py +127 -70
- mlrun/runtimes/nuclio/serving.py +105 -37
- mlrun/runtimes/pod.py +159 -54
- mlrun/runtimes/remotesparkjob.py +3 -2
- mlrun/runtimes/sparkjob/__init__.py +0 -2
- mlrun/runtimes/sparkjob/spark3job.py +22 -12
- mlrun/runtimes/utils.py +7 -6
- mlrun/secrets.py +2 -2
- mlrun/serving/__init__.py +8 -0
- mlrun/serving/merger.py +7 -5
- mlrun/serving/remote.py +35 -22
- mlrun/serving/routers.py +186 -240
- mlrun/serving/server.py +41 -10
- mlrun/serving/states.py +432 -118
- mlrun/serving/utils.py +13 -2
- mlrun/serving/v1_serving.py +3 -2
- mlrun/serving/v2_serving.py +161 -203
- mlrun/track/__init__.py +1 -1
- mlrun/track/tracker.py +2 -2
- mlrun/track/trackers/mlflow_tracker.py +6 -5
- mlrun/utils/async_http.py +35 -22
- mlrun/utils/clones.py +7 -4
- mlrun/utils/helpers.py +511 -58
- mlrun/utils/logger.py +119 -13
- mlrun/utils/notifications/notification/__init__.py +22 -19
- mlrun/utils/notifications/notification/base.py +39 -15
- mlrun/utils/notifications/notification/console.py +6 -6
- mlrun/utils/notifications/notification/git.py +11 -11
- mlrun/utils/notifications/notification/ipython.py +10 -9
- mlrun/utils/notifications/notification/mail.py +176 -0
- mlrun/utils/notifications/notification/slack.py +16 -8
- mlrun/utils/notifications/notification/webhook.py +24 -8
- mlrun/utils/notifications/notification_pusher.py +191 -200
- mlrun/utils/regex.py +12 -2
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/METADATA +69 -54
- mlrun-1.8.0.dist-info/RECORD +351 -0
- {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/WHEEL +1 -1
- mlrun/model_monitoring/applications/evidently_base.py +0 -137
- mlrun/model_monitoring/db/stores/__init__.py +0 -136
- mlrun/model_monitoring/db/stores/base/store.py +0 -213
- mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -71
- mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -190
- mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -103
- mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -40
- mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -659
- mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
- mlrun/model_monitoring/model_endpoint.py +0 -118
- mlrun-1.7.2rc4.dist-info/RECORD +0 -351
- {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info/licenses}/LICENSE +0 -0
- {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/top_level.txt +0 -0
mlrun/runtimes/mounts.py
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
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 os
|
|
16
|
+
import typing
|
|
17
|
+
from collections import namedtuple
|
|
18
|
+
|
|
19
|
+
from mlrun.config import config
|
|
20
|
+
from mlrun.config import config as mlconf
|
|
21
|
+
from mlrun.errors import MLRunInvalidArgumentError
|
|
22
|
+
from mlrun.platforms.iguazio import v3io_to_vol
|
|
23
|
+
from mlrun.utils import logger
|
|
24
|
+
|
|
25
|
+
if typing.TYPE_CHECKING:
|
|
26
|
+
from mlrun.runtimes import KubeResource
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
VolumeMount = namedtuple("Mount", ["path", "sub_path"])
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def v3io_cred(
|
|
33
|
+
api: str = "",
|
|
34
|
+
user: str = "",
|
|
35
|
+
access_key: str = "",
|
|
36
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
37
|
+
"""
|
|
38
|
+
Modifier function to copy local v3io env vars to container
|
|
39
|
+
|
|
40
|
+
Usage::
|
|
41
|
+
|
|
42
|
+
train = train_op(...)
|
|
43
|
+
train.apply(use_v3io_cred())
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def _use_v3io_cred(runtime: "KubeResource"):
|
|
47
|
+
web_api = api or os.environ.get("V3IO_API") or mlconf.v3io_api
|
|
48
|
+
_user = user or os.environ.get("V3IO_USERNAME")
|
|
49
|
+
_access_key = access_key or os.environ.get("V3IO_ACCESS_KEY")
|
|
50
|
+
v3io_framesd = mlconf.v3io_framesd or os.environ.get("V3IO_FRAMESD")
|
|
51
|
+
|
|
52
|
+
runtime.set_envs(
|
|
53
|
+
{
|
|
54
|
+
"V3IO_API": web_api,
|
|
55
|
+
"V3IO_USERNAME": _user,
|
|
56
|
+
"V3IO_ACCESS_KEY": _access_key,
|
|
57
|
+
"V3IO_FRAMESD": v3io_framesd,
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
return runtime
|
|
62
|
+
|
|
63
|
+
return _use_v3io_cred
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def mount_v3io(
|
|
67
|
+
name: str = "v3io",
|
|
68
|
+
remote: str = "",
|
|
69
|
+
access_key: str = "",
|
|
70
|
+
user: str = "",
|
|
71
|
+
secret: typing.Optional[str] = None,
|
|
72
|
+
volume_mounts: typing.Optional[list[VolumeMount]] = None,
|
|
73
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
74
|
+
"""Modifier function to apply to a Container Op to volume mount a v3io path
|
|
75
|
+
|
|
76
|
+
:param name: the volume name
|
|
77
|
+
:param remote: the v3io path to use for the volume (~/ prefix will be replaced with /users/<username>/)
|
|
78
|
+
:param access_key: the access key used to auth against v3io (default: V3IO_ACCESS_KEY env var)
|
|
79
|
+
:param user: the username used to auth against v3io (default: V3IO_USERNAME env var)
|
|
80
|
+
:param secret: k8s secret name for the username and access key
|
|
81
|
+
:param volume_mounts: list of VolumeMount; if empty, defaults to mounting /v3io and /User
|
|
82
|
+
"""
|
|
83
|
+
volume_mounts, user = _enrich_and_validate_v3io_mounts(
|
|
84
|
+
remote=remote,
|
|
85
|
+
volume_mounts=volume_mounts,
|
|
86
|
+
user=user,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def _attach_volume_mounts_and_creds(runtime: "KubeResource"):
|
|
90
|
+
vol = v3io_to_vol(name, remote, access_key, user, secret=secret)
|
|
91
|
+
runtime.spec.with_volumes(vol)
|
|
92
|
+
|
|
93
|
+
for volume_mount in volume_mounts:
|
|
94
|
+
runtime.spec.with_volume_mounts(
|
|
95
|
+
{
|
|
96
|
+
"mountPath": volume_mount.path,
|
|
97
|
+
"name": name,
|
|
98
|
+
"subPath": volume_mount.sub_path,
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if not secret:
|
|
103
|
+
runtime = v3io_cred(access_key=access_key, user=user)(runtime)
|
|
104
|
+
return runtime
|
|
105
|
+
|
|
106
|
+
return _attach_volume_mounts_and_creds
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def mount_spark_conf() -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
110
|
+
"""Modifier function to mount Spark configuration."""
|
|
111
|
+
|
|
112
|
+
def _mount_spark(runtime: "KubeResource"):
|
|
113
|
+
runtime.spec.with_volume_mounts(
|
|
114
|
+
{
|
|
115
|
+
"mountPath": "/etc/config/spark",
|
|
116
|
+
"name": "spark-master-config",
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
return runtime
|
|
120
|
+
|
|
121
|
+
return _mount_spark
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def mount_v3iod(
|
|
125
|
+
namespace: str, v3io_config_configmap: str
|
|
126
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
127
|
+
"""Modifier function to mount v3iod configuration."""
|
|
128
|
+
|
|
129
|
+
def _mount_v3iod(runtime: "KubeResource"):
|
|
130
|
+
def add_vol(name, mount_path, host_path):
|
|
131
|
+
runtime.spec.with_volumes(
|
|
132
|
+
{
|
|
133
|
+
"name": name,
|
|
134
|
+
"hostPath": {
|
|
135
|
+
"path": host_path,
|
|
136
|
+
"type": "",
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
runtime.spec.with_volume_mounts(
|
|
141
|
+
{
|
|
142
|
+
"mountPath": mount_path,
|
|
143
|
+
"name": name,
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
add_vol(
|
|
148
|
+
name="shm",
|
|
149
|
+
mount_path="/dev/shm",
|
|
150
|
+
host_path=f"/var/run/iguazio/dayman-shm/{namespace}",
|
|
151
|
+
)
|
|
152
|
+
add_vol(
|
|
153
|
+
name="v3iod-comm",
|
|
154
|
+
mount_path="/var/run/iguazio/dayman",
|
|
155
|
+
host_path="/var/run/iguazio/dayman/" + namespace,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# Add daemon-health and v3io-config volumes
|
|
159
|
+
runtime.spec.with_volumes(
|
|
160
|
+
[
|
|
161
|
+
{
|
|
162
|
+
"name": "daemon-health",
|
|
163
|
+
"emptyDir": {},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "v3io-config",
|
|
167
|
+
"configMap": {
|
|
168
|
+
"name": v3io_config_configmap,
|
|
169
|
+
"defaultMode": 420,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
]
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# Add volume mounts
|
|
176
|
+
runtime.spec.with_volume_mounts(
|
|
177
|
+
[
|
|
178
|
+
{
|
|
179
|
+
"mountPath": "/var/run/iguazio/daemon_health",
|
|
180
|
+
"name": "daemon-health",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"mountPath": "/etc/config/v3io",
|
|
184
|
+
"name": "v3io-config",
|
|
185
|
+
},
|
|
186
|
+
]
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
# Add environment variables
|
|
190
|
+
runtime.set_envs(
|
|
191
|
+
{
|
|
192
|
+
"CURRENT_NODE_IP": {
|
|
193
|
+
"valueFrom": {
|
|
194
|
+
"fieldRef": {
|
|
195
|
+
"apiVersion": "v1",
|
|
196
|
+
"fieldPath": "status.hostIP",
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
"IGZ_DATA_CONFIG_FILE": "/igz/java/conf/v3io.conf",
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
return runtime
|
|
205
|
+
|
|
206
|
+
return _mount_v3iod
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def mount_s3(
|
|
210
|
+
secret_name: typing.Optional[str] = None,
|
|
211
|
+
aws_access_key: str = "",
|
|
212
|
+
aws_secret_key: str = "",
|
|
213
|
+
endpoint_url: typing.Optional[str] = None,
|
|
214
|
+
prefix: str = "",
|
|
215
|
+
aws_region: typing.Optional[str] = None,
|
|
216
|
+
non_anonymous: bool = False,
|
|
217
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
218
|
+
"""Modifier function to add s3 env vars or secrets to container
|
|
219
|
+
|
|
220
|
+
:param secret_name: Kubernetes secret name for credentials
|
|
221
|
+
:param aws_access_key: AWS_ACCESS_KEY_ID value (default: env variable)
|
|
222
|
+
:param aws_secret_key: AWS_SECRET_ACCESS_KEY value (default: env variable)
|
|
223
|
+
:param endpoint_url: s3 endpoint address (for non-AWS s3)
|
|
224
|
+
:param prefix: prefix to add before the env var name (for multiple s3 data stores)
|
|
225
|
+
:param aws_region: Amazon region
|
|
226
|
+
:param non_anonymous: use non-anonymous connection even if no credentials are provided
|
|
227
|
+
(for authenticating externally, such as through IAM instance-roles)
|
|
228
|
+
|
|
229
|
+
"""
|
|
230
|
+
|
|
231
|
+
if secret_name and (aws_access_key or aws_secret_key):
|
|
232
|
+
raise MLRunInvalidArgumentError(
|
|
233
|
+
"Can use k8s_secret for credentials or specify them (aws_access_key, aws_secret_key) not both."
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
if not secret_name and (
|
|
237
|
+
aws_access_key
|
|
238
|
+
or os.environ.get(prefix + "AWS_ACCESS_KEY_ID")
|
|
239
|
+
or aws_secret_key
|
|
240
|
+
or os.environ.get(prefix + "AWS_SECRET_ACCESS_KEY")
|
|
241
|
+
):
|
|
242
|
+
logger.warning(
|
|
243
|
+
"It is recommended to use k8s secret (specify secret_name), "
|
|
244
|
+
"specifying aws_access_key/aws_secret_key directly is unsafe."
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
def _use_s3_cred(runtime: "KubeResource"):
|
|
248
|
+
_access_key = aws_access_key or os.environ.get(prefix + "AWS_ACCESS_KEY_ID")
|
|
249
|
+
_secret_key = aws_secret_key or os.environ.get(prefix + "AWS_SECRET_ACCESS_KEY")
|
|
250
|
+
_endpoint_url = endpoint_url or os.environ.get(prefix + "S3_ENDPOINT_URL")
|
|
251
|
+
|
|
252
|
+
if _endpoint_url:
|
|
253
|
+
runtime.set_env(prefix + "S3_ENDPOINT_URL", _endpoint_url)
|
|
254
|
+
if aws_region:
|
|
255
|
+
runtime.set_env(prefix + "AWS_REGION", aws_region)
|
|
256
|
+
if non_anonymous:
|
|
257
|
+
runtime.set_env(prefix + "S3_NON_ANONYMOUS", "true")
|
|
258
|
+
|
|
259
|
+
if secret_name:
|
|
260
|
+
runtime.set_envs(
|
|
261
|
+
{
|
|
262
|
+
f"{prefix}AWS_ACCESS_KEY_ID": {
|
|
263
|
+
"valueFrom": {
|
|
264
|
+
"secretKeyRef": {
|
|
265
|
+
"name": secret_name,
|
|
266
|
+
"key": "AWS_ACCESS_KEY_ID",
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
f"{prefix}AWS_SECRET_ACCESS_KEY": {
|
|
271
|
+
"valueFrom": {
|
|
272
|
+
"secretKeyRef": {
|
|
273
|
+
"name": secret_name,
|
|
274
|
+
"key": "AWS_SECRET_ACCESS_KEY",
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
else:
|
|
281
|
+
runtime.set_envs(
|
|
282
|
+
{
|
|
283
|
+
f"{prefix}AWS_ACCESS_KEY_ID": _access_key,
|
|
284
|
+
f"{prefix}AWS_SECRET_ACCESS_KEY": _secret_key,
|
|
285
|
+
},
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
return runtime
|
|
289
|
+
|
|
290
|
+
return _use_s3_cred
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def mount_pvc(
|
|
294
|
+
pvc_name: typing.Optional[str] = None,
|
|
295
|
+
volume_name: str = "pipeline",
|
|
296
|
+
volume_mount_path: str = "/mnt/pipeline",
|
|
297
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
298
|
+
"""
|
|
299
|
+
Modifier function to mount a PVC volume in the container, simplifying volume and volume mount addition.
|
|
300
|
+
|
|
301
|
+
Usage::
|
|
302
|
+
|
|
303
|
+
train = train_op(...)
|
|
304
|
+
train.apply(mount_pvc("claim-name", "pipeline", "/mnt/pipeline"))
|
|
305
|
+
"""
|
|
306
|
+
if not pvc_name:
|
|
307
|
+
# Try to get the PVC mount configuration from the environment variable
|
|
308
|
+
if "MLRUN_PVC_MOUNT" in os.environ:
|
|
309
|
+
mount = os.environ.get("MLRUN_PVC_MOUNT")
|
|
310
|
+
items = mount.split(":")
|
|
311
|
+
if len(items) != 2:
|
|
312
|
+
raise MLRunInvalidArgumentError(
|
|
313
|
+
"MLRUN_PVC_MOUNT should include <pvc-name>:<mount-path>"
|
|
314
|
+
)
|
|
315
|
+
pvc_name = items[0]
|
|
316
|
+
volume_mount_path = items[1]
|
|
317
|
+
|
|
318
|
+
if not pvc_name:
|
|
319
|
+
# The PVC name is still not set, raise an error
|
|
320
|
+
raise MLRunInvalidArgumentError(
|
|
321
|
+
"No PVC name: use the pvc_name parameter or configure the MLRUN_PVC_MOUNT environment variable"
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
def _mount_pvc(runtime: "KubeResource"):
|
|
325
|
+
local_pvc = {"claimName": pvc_name}
|
|
326
|
+
|
|
327
|
+
runtime.spec.with_volumes(
|
|
328
|
+
[
|
|
329
|
+
{
|
|
330
|
+
"name": volume_name,
|
|
331
|
+
"persistentVolumeClaim": local_pvc,
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
)
|
|
335
|
+
runtime.spec.with_volume_mounts(
|
|
336
|
+
{
|
|
337
|
+
"mountPath": volume_mount_path,
|
|
338
|
+
"name": volume_name,
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
return runtime
|
|
343
|
+
|
|
344
|
+
return _mount_pvc
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def auto_mount(
|
|
348
|
+
pvc_name: str = "",
|
|
349
|
+
volume_mount_path: str = "",
|
|
350
|
+
volume_name: typing.Optional[str] = None,
|
|
351
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
352
|
+
"""Choose the mount based on env variables and params
|
|
353
|
+
|
|
354
|
+
Volume will be selected by the following order:
|
|
355
|
+
|
|
356
|
+
- k8s PVC volume when both pvc_name and volume_mount_path are set
|
|
357
|
+
- k8s PVC volume when env var is set: MLRUN_PVC_MOUNT=<pvc-name>:<mount-path>
|
|
358
|
+
- k8s PVC volume if it's configured as the auto mount type
|
|
359
|
+
- iguazio v3io volume when V3IO_ACCESS_KEY and V3IO_USERNAME env vars are set
|
|
360
|
+
|
|
361
|
+
"""
|
|
362
|
+
if pvc_name and volume_mount_path:
|
|
363
|
+
return mount_pvc(
|
|
364
|
+
pvc_name=pvc_name,
|
|
365
|
+
volume_mount_path=volume_mount_path,
|
|
366
|
+
volume_name=volume_name or "shared-persistency",
|
|
367
|
+
)
|
|
368
|
+
if "MLRUN_PVC_MOUNT" in os.environ:
|
|
369
|
+
return mount_pvc(
|
|
370
|
+
volume_name=volume_name or "shared-persistency",
|
|
371
|
+
)
|
|
372
|
+
# In the case of CE when working remotely, no env variables will be defined but auto-mount
|
|
373
|
+
# parameters may still be declared - use them in that case.
|
|
374
|
+
if config.storage.auto_mount_type == "pvc":
|
|
375
|
+
return mount_pvc(**config.get_storage_auto_mount_params())
|
|
376
|
+
if "V3IO_ACCESS_KEY" in os.environ:
|
|
377
|
+
return mount_v3io(name=volume_name or "v3io")
|
|
378
|
+
|
|
379
|
+
raise ValueError("Failed to auto mount, need to set env vars")
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def mount_secret(
|
|
383
|
+
secret_name: str,
|
|
384
|
+
mount_path: str,
|
|
385
|
+
volume_name: str = "secret",
|
|
386
|
+
items: typing.Optional[list[dict]] = None,
|
|
387
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
388
|
+
"""
|
|
389
|
+
Modifier function to mount a Kubernetes secret as file(s).
|
|
390
|
+
|
|
391
|
+
:param secret_name: Kubernetes secret name
|
|
392
|
+
:param mount_path: Path inside the container to mount
|
|
393
|
+
:param volume_name: Unique volume name
|
|
394
|
+
:param items: If unspecified, each key-value pair in the Data field
|
|
395
|
+
of the referenced Secret will be projected into the
|
|
396
|
+
volume as a file whose name is the key and content is
|
|
397
|
+
the value.
|
|
398
|
+
If specified, the listed keys will be projected into
|
|
399
|
+
the specified paths, and unlisted keys will not be
|
|
400
|
+
present."""
|
|
401
|
+
|
|
402
|
+
def _mount_secret(runtime: "KubeResource"):
|
|
403
|
+
# Define the secret volume source
|
|
404
|
+
secret_volume_source = {
|
|
405
|
+
"secretName": secret_name,
|
|
406
|
+
"items": items,
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
# Add the secret volume
|
|
410
|
+
runtime.spec.with_volumes(
|
|
411
|
+
{
|
|
412
|
+
"name": volume_name,
|
|
413
|
+
"secret": secret_volume_source,
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
# Add the volume mount
|
|
418
|
+
runtime.spec.with_volume_mounts(
|
|
419
|
+
{
|
|
420
|
+
"mountPath": mount_path,
|
|
421
|
+
"name": volume_name,
|
|
422
|
+
}
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
return runtime
|
|
426
|
+
|
|
427
|
+
return _mount_secret
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def mount_configmap(
|
|
431
|
+
configmap_name: str,
|
|
432
|
+
mount_path: str,
|
|
433
|
+
volume_name: str = "configmap",
|
|
434
|
+
items: typing.Optional[list[dict]] = None,
|
|
435
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
436
|
+
"""
|
|
437
|
+
Modifier function to mount a Kubernetes ConfigMap as file(s).
|
|
438
|
+
|
|
439
|
+
:param configmap_name: Kubernetes ConfigMap name
|
|
440
|
+
:param mount_path: Path inside the container to mount
|
|
441
|
+
:param volume_name: Unique volume name
|
|
442
|
+
:param items: If unspecified, each key-value pair in the Data field
|
|
443
|
+
of the referenced Configmap will be projected into the
|
|
444
|
+
volume as a file whose name is the key and content is
|
|
445
|
+
the value.
|
|
446
|
+
If specified, the listed keys will be projected into
|
|
447
|
+
the specified paths, and unlisted keys will not be
|
|
448
|
+
present."""
|
|
449
|
+
|
|
450
|
+
def _mount_configmap(runtime: "KubeResource"):
|
|
451
|
+
# Construct the configMap dictionary
|
|
452
|
+
config_map_dict = {
|
|
453
|
+
"name": configmap_name,
|
|
454
|
+
}
|
|
455
|
+
if items is not None:
|
|
456
|
+
config_map_dict["items"] = items
|
|
457
|
+
|
|
458
|
+
vol = {
|
|
459
|
+
"name": volume_name,
|
|
460
|
+
"configMap": config_map_dict,
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
runtime.spec.with_volumes(vol)
|
|
464
|
+
runtime.spec.with_volume_mounts(
|
|
465
|
+
{
|
|
466
|
+
"mountPath": mount_path,
|
|
467
|
+
"name": volume_name,
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
return runtime
|
|
472
|
+
|
|
473
|
+
return _mount_configmap
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def mount_hostpath(
|
|
477
|
+
host_path: str,
|
|
478
|
+
mount_path: str,
|
|
479
|
+
volume_name: str = "hostpath",
|
|
480
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
481
|
+
"""
|
|
482
|
+
Modifier function to mount a host path inside a Kubernetes container.
|
|
483
|
+
|
|
484
|
+
:param host_path: Host path on the node to be mounted.
|
|
485
|
+
:param mount_path: Path inside the container where the volume will be mounted.
|
|
486
|
+
:param volume_name: Unique name for the volume.
|
|
487
|
+
"""
|
|
488
|
+
|
|
489
|
+
def _mount_hostpath(runtime: "KubeResource") -> "KubeResource":
|
|
490
|
+
runtime.spec.with_volumes(
|
|
491
|
+
{
|
|
492
|
+
"name": volume_name,
|
|
493
|
+
"hostPath": {
|
|
494
|
+
"path": host_path,
|
|
495
|
+
"type": "",
|
|
496
|
+
},
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
runtime.spec.with_volume_mounts(
|
|
500
|
+
{
|
|
501
|
+
"mountPath": mount_path,
|
|
502
|
+
"name": volume_name,
|
|
503
|
+
}
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
return runtime
|
|
507
|
+
|
|
508
|
+
return _mount_hostpath
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def set_env_variables(
|
|
512
|
+
env_vars_dict: typing.Optional[dict[str, str]] = None, **kwargs
|
|
513
|
+
) -> typing.Callable[["KubeResource"], "KubeResource"]:
|
|
514
|
+
"""
|
|
515
|
+
Modifier function to apply a set of environment variables to a runtime. Variables may be passed
|
|
516
|
+
as either a dictionary of name-value pairs, or as arguments to the function.
|
|
517
|
+
See `KubeResource.apply` for more information on modifiers.
|
|
518
|
+
|
|
519
|
+
Usage::
|
|
520
|
+
|
|
521
|
+
function.apply(set_env_variables({"ENV1": "value1", "ENV2": "value2"}))
|
|
522
|
+
or
|
|
523
|
+
function.apply(set_env_variables(ENV1=value1, ENV2=value2))
|
|
524
|
+
|
|
525
|
+
:param env_vars_dict: dictionary of environment variables
|
|
526
|
+
:param kwargs: environment variables passed as arguments
|
|
527
|
+
"""
|
|
528
|
+
|
|
529
|
+
env_data = env_vars_dict.copy() if env_vars_dict else {}
|
|
530
|
+
for key, value in kwargs.items():
|
|
531
|
+
env_data[key] = value
|
|
532
|
+
|
|
533
|
+
def _set_env_variables(runtime: "KubeResource"):
|
|
534
|
+
runtime.set_envs(env_data)
|
|
535
|
+
|
|
536
|
+
return runtime
|
|
537
|
+
|
|
538
|
+
return _set_env_variables
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def _enrich_and_validate_v3io_mounts(
|
|
542
|
+
remote: str = "",
|
|
543
|
+
volume_mounts: typing.Optional[list[VolumeMount]] = None,
|
|
544
|
+
user: str = "",
|
|
545
|
+
) -> tuple[list[VolumeMount], str]:
|
|
546
|
+
if volume_mounts is None:
|
|
547
|
+
volume_mounts = []
|
|
548
|
+
if remote and not volume_mounts:
|
|
549
|
+
raise MLRunInvalidArgumentError(
|
|
550
|
+
"volume_mounts must be specified when remote is given"
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
# Empty remote & volume_mounts defaults are volume mounts of /v3io and /User
|
|
554
|
+
if not remote and not volume_mounts:
|
|
555
|
+
user = _resolve_mount_user(user)
|
|
556
|
+
if not user:
|
|
557
|
+
raise MLRunInvalidArgumentError(
|
|
558
|
+
"user name/env must be specified when using empty remote and volume_mounts"
|
|
559
|
+
)
|
|
560
|
+
volume_mounts = [
|
|
561
|
+
VolumeMount(path="/v3io", sub_path=""),
|
|
562
|
+
VolumeMount(path="/User", sub_path="users/" + user),
|
|
563
|
+
]
|
|
564
|
+
|
|
565
|
+
if not isinstance(volume_mounts, list) and any(
|
|
566
|
+
[not isinstance(x, VolumeMount) for x in volume_mounts]
|
|
567
|
+
):
|
|
568
|
+
raise TypeError("mounts should be a list of Mount")
|
|
569
|
+
|
|
570
|
+
return volume_mounts, user
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
def _resolve_mount_user(user: typing.Optional[str] = None):
|
|
574
|
+
return user or os.environ.get("V3IO_USERNAME")
|
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
# flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
|
|
16
|
-
|
|
17
15
|
from dependency_injector import containers, providers
|
|
18
16
|
|
|
19
17
|
from mlrun.config import config
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
import abc
|
|
15
15
|
import os
|
|
16
|
+
from typing import Optional
|
|
16
17
|
|
|
17
18
|
from mlrun.config import config
|
|
18
19
|
from mlrun.runtimes.kubejob import KubejobRuntime
|
|
@@ -117,7 +118,7 @@ class AbstractMPIJobRuntime(KubejobRuntime, abc.ABC):
|
|
|
117
118
|
return {}
|
|
118
119
|
|
|
119
120
|
def with_tracing(
|
|
120
|
-
self, log_file_path: str = None, enable_cycle_markers: bool = False
|
|
121
|
+
self, log_file_path: Optional[str] = None, enable_cycle_markers: bool = False
|
|
121
122
|
):
|
|
122
123
|
"""Add Horovod Timeline activity tracking to the job to analyse
|
|
123
124
|
its performance.
|
|
@@ -149,11 +150,11 @@ class AbstractMPIJobRuntime(KubejobRuntime, abc.ABC):
|
|
|
149
150
|
|
|
150
151
|
def with_autotune(
|
|
151
152
|
self,
|
|
152
|
-
log_file_path: str = None,
|
|
153
|
-
warmup_samples: int = None,
|
|
154
|
-
steps_per_sample: int = None,
|
|
155
|
-
bayes_opt_max_samples: int = None,
|
|
156
|
-
gaussian_process_noise: float = None,
|
|
153
|
+
log_file_path: Optional[str] = None,
|
|
154
|
+
warmup_samples: Optional[int] = None,
|
|
155
|
+
steps_per_sample: Optional[int] = None,
|
|
156
|
+
bayes_opt_max_samples: Optional[int] = None,
|
|
157
|
+
gaussian_process_noise: Optional[float] = None,
|
|
157
158
|
):
|
|
158
159
|
"""Adds an Autotuner to help optimize Horovod's Parameters for better performance.
|
|
159
160
|
|
|
@@ -118,10 +118,10 @@ class APIGatewayMetadata(ModelObj):
|
|
|
118
118
|
def __init__(
|
|
119
119
|
self,
|
|
120
120
|
name: str,
|
|
121
|
-
namespace: str = None,
|
|
122
|
-
labels: dict = None,
|
|
123
|
-
annotations: dict = None,
|
|
124
|
-
creation_timestamp: str = None,
|
|
121
|
+
namespace: Optional[str] = None,
|
|
122
|
+
labels: Optional[dict] = None,
|
|
123
|
+
annotations: Optional[dict] = None,
|
|
124
|
+
creation_timestamp: Optional[str] = None,
|
|
125
125
|
):
|
|
126
126
|
"""
|
|
127
127
|
:param name: The name of the API gateway
|
|
@@ -169,9 +169,9 @@ class APIGatewaySpec(ModelObj):
|
|
|
169
169
|
"mlrun.runtimes.nuclio.serving.ServingRuntime",
|
|
170
170
|
"mlrun.runtimes.nuclio.application.ApplicationRuntime",
|
|
171
171
|
],
|
|
172
|
-
project: str = None,
|
|
172
|
+
project: Optional[str] = None,
|
|
173
173
|
description: str = "",
|
|
174
|
-
host: str = None,
|
|
174
|
+
host: Optional[str] = None,
|
|
175
175
|
path: str = "/",
|
|
176
176
|
authentication: Optional[APIGatewayAuthenticator] = NoneAuth(),
|
|
177
177
|
canary: Optional[list[int]] = None,
|
|
@@ -389,7 +389,7 @@ class APIGateway(ModelObj):
|
|
|
389
389
|
def invoke(
|
|
390
390
|
self,
|
|
391
391
|
method="POST",
|
|
392
|
-
headers: dict = None,
|
|
392
|
+
headers: Optional[dict] = None,
|
|
393
393
|
credentials: Optional[tuple[str, str]] = None,
|
|
394
394
|
path: Optional[str] = None,
|
|
395
395
|
body: Optional[Union[str, bytes, dict]] = None,
|