mlrun 1.10.0rc18__py3-none-any.whl → 1.11.0rc16__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 +24 -3
- mlrun/__main__.py +0 -4
- mlrun/artifacts/dataset.py +2 -2
- mlrun/artifacts/document.py +6 -1
- mlrun/artifacts/llm_prompt.py +21 -15
- mlrun/artifacts/model.py +3 -3
- mlrun/artifacts/plots.py +1 -1
- mlrun/{model_monitoring/db/tsdb/tdengine → auth}/__init__.py +2 -3
- mlrun/auth/nuclio.py +89 -0
- mlrun/auth/providers.py +429 -0
- mlrun/auth/utils.py +415 -0
- mlrun/common/constants.py +14 -0
- mlrun/common/model_monitoring/helpers.py +123 -0
- mlrun/common/runtimes/constants.py +28 -0
- mlrun/common/schemas/__init__.py +14 -3
- mlrun/common/schemas/alert.py +2 -2
- mlrun/common/schemas/api_gateway.py +3 -0
- mlrun/common/schemas/auth.py +12 -10
- mlrun/common/schemas/client_spec.py +4 -0
- mlrun/common/schemas/constants.py +25 -0
- mlrun/common/schemas/frontend_spec.py +1 -8
- mlrun/common/schemas/function.py +34 -0
- mlrun/common/schemas/hub.py +33 -20
- mlrun/common/schemas/model_monitoring/__init__.py +2 -1
- mlrun/common/schemas/model_monitoring/constants.py +12 -15
- mlrun/common/schemas/model_monitoring/functions.py +13 -4
- mlrun/common/schemas/model_monitoring/model_endpoints.py +11 -0
- mlrun/common/schemas/pipeline.py +1 -1
- mlrun/common/schemas/secret.py +17 -2
- mlrun/common/secrets.py +95 -1
- mlrun/common/types.py +10 -10
- mlrun/config.py +69 -19
- mlrun/data_types/infer.py +2 -2
- mlrun/datastore/__init__.py +12 -5
- mlrun/datastore/azure_blob.py +162 -47
- mlrun/datastore/base.py +274 -10
- mlrun/datastore/datastore.py +7 -2
- mlrun/datastore/datastore_profile.py +84 -22
- mlrun/datastore/model_provider/huggingface_provider.py +225 -41
- mlrun/datastore/model_provider/mock_model_provider.py +87 -0
- mlrun/datastore/model_provider/model_provider.py +206 -74
- mlrun/datastore/model_provider/openai_provider.py +226 -66
- mlrun/datastore/s3.py +39 -18
- mlrun/datastore/sources.py +1 -1
- mlrun/datastore/store_resources.py +4 -4
- mlrun/datastore/storeytargets.py +17 -12
- mlrun/datastore/targets.py +1 -1
- mlrun/datastore/utils.py +25 -6
- mlrun/datastore/v3io.py +1 -1
- mlrun/db/base.py +63 -32
- mlrun/db/httpdb.py +373 -153
- mlrun/db/nopdb.py +54 -21
- mlrun/errors.py +4 -2
- mlrun/execution.py +66 -25
- mlrun/feature_store/api.py +1 -1
- mlrun/feature_store/common.py +1 -1
- mlrun/feature_store/feature_vector_utils.py +1 -1
- mlrun/feature_store/steps.py +8 -6
- mlrun/frameworks/_common/utils.py +3 -3
- mlrun/frameworks/_dl_common/loggers/logger.py +1 -1
- mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +2 -1
- mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +1 -1
- mlrun/frameworks/_ml_common/utils.py +2 -1
- mlrun/frameworks/auto_mlrun/auto_mlrun.py +4 -3
- mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +2 -1
- mlrun/frameworks/onnx/dataset.py +2 -1
- mlrun/frameworks/onnx/mlrun_interface.py +2 -1
- mlrun/frameworks/pytorch/callbacks/logging_callback.py +5 -4
- mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +2 -1
- mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +2 -1
- mlrun/frameworks/pytorch/utils.py +2 -1
- mlrun/frameworks/sklearn/metric.py +2 -1
- mlrun/frameworks/tf_keras/callbacks/logging_callback.py +5 -4
- mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +2 -1
- mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +2 -1
- mlrun/hub/__init__.py +52 -0
- mlrun/hub/base.py +142 -0
- mlrun/hub/module.py +172 -0
- mlrun/hub/step.py +113 -0
- mlrun/k8s_utils.py +105 -16
- mlrun/launcher/base.py +15 -7
- mlrun/launcher/local.py +4 -1
- mlrun/model.py +14 -4
- mlrun/model_monitoring/__init__.py +0 -1
- mlrun/model_monitoring/api.py +65 -28
- mlrun/model_monitoring/applications/__init__.py +1 -1
- mlrun/model_monitoring/applications/base.py +299 -128
- mlrun/model_monitoring/applications/context.py +2 -4
- mlrun/model_monitoring/controller.py +132 -58
- mlrun/model_monitoring/db/_schedules.py +38 -29
- mlrun/model_monitoring/db/_stats.py +6 -16
- mlrun/model_monitoring/db/tsdb/__init__.py +9 -7
- mlrun/model_monitoring/db/tsdb/base.py +29 -9
- mlrun/model_monitoring/db/tsdb/preaggregate.py +234 -0
- mlrun/model_monitoring/db/tsdb/stream_graph_steps.py +63 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/queries/timescaledb_metrics_queries.py +414 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/queries/timescaledb_predictions_queries.py +376 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/queries/timescaledb_results_queries.py +590 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/timescaledb_connection.py +434 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/timescaledb_connector.py +541 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/timescaledb_operations.py +808 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/timescaledb_schema.py +502 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/timescaledb_stream.py +163 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/timescaledb_stream_graph_steps.py +60 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/utils/timescaledb_dataframe_processor.py +141 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/utils/timescaledb_query_builder.py +585 -0
- mlrun/model_monitoring/db/tsdb/timescaledb/writer_graph_steps.py +73 -0
- mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +20 -9
- mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +235 -51
- mlrun/model_monitoring/features_drift_table.py +2 -1
- mlrun/model_monitoring/helpers.py +30 -6
- mlrun/model_monitoring/stream_processing.py +34 -28
- mlrun/model_monitoring/writer.py +224 -4
- mlrun/package/__init__.py +2 -1
- mlrun/platforms/__init__.py +0 -43
- mlrun/platforms/iguazio.py +8 -4
- mlrun/projects/operations.py +17 -11
- mlrun/projects/pipelines.py +2 -2
- mlrun/projects/project.py +187 -123
- mlrun/run.py +95 -21
- mlrun/runtimes/__init__.py +2 -186
- mlrun/runtimes/base.py +103 -25
- mlrun/runtimes/constants.py +225 -0
- mlrun/runtimes/daskjob.py +5 -2
- mlrun/runtimes/databricks_job/databricks_runtime.py +2 -1
- mlrun/runtimes/local.py +5 -2
- mlrun/runtimes/mounts.py +20 -2
- mlrun/runtimes/nuclio/__init__.py +12 -7
- mlrun/runtimes/nuclio/api_gateway.py +36 -6
- mlrun/runtimes/nuclio/application/application.py +339 -40
- mlrun/runtimes/nuclio/function.py +222 -72
- mlrun/runtimes/nuclio/serving.py +132 -42
- mlrun/runtimes/pod.py +213 -21
- mlrun/runtimes/utils.py +49 -9
- mlrun/secrets.py +99 -14
- mlrun/serving/__init__.py +2 -0
- mlrun/serving/remote.py +84 -11
- mlrun/serving/routers.py +26 -44
- mlrun/serving/server.py +138 -51
- mlrun/serving/serving_wrapper.py +6 -2
- mlrun/serving/states.py +997 -283
- mlrun/serving/steps.py +62 -0
- mlrun/serving/system_steps.py +149 -95
- mlrun/serving/v2_serving.py +9 -10
- mlrun/track/trackers/mlflow_tracker.py +29 -31
- mlrun/utils/helpers.py +292 -94
- mlrun/utils/http.py +9 -2
- mlrun/utils/notifications/notification/base.py +18 -0
- mlrun/utils/notifications/notification/git.py +3 -5
- mlrun/utils/notifications/notification/mail.py +39 -16
- mlrun/utils/notifications/notification/slack.py +2 -4
- mlrun/utils/notifications/notification/webhook.py +2 -5
- mlrun/utils/notifications/notification_pusher.py +3 -3
- mlrun/utils/version/version.json +2 -2
- mlrun/utils/version/version.py +3 -4
- {mlrun-1.10.0rc18.dist-info → mlrun-1.11.0rc16.dist-info}/METADATA +63 -74
- {mlrun-1.10.0rc18.dist-info → mlrun-1.11.0rc16.dist-info}/RECORD +161 -143
- mlrun/api/schemas/__init__.py +0 -259
- mlrun/db/auth_utils.py +0 -152
- mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +0 -344
- mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +0 -75
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connection.py +0 -281
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +0 -1266
- {mlrun-1.10.0rc18.dist-info → mlrun-1.11.0rc16.dist-info}/WHEEL +0 -0
- {mlrun-1.10.0rc18.dist-info → mlrun-1.11.0rc16.dist-info}/entry_points.txt +0 -0
- {mlrun-1.10.0rc18.dist-info → mlrun-1.11.0rc16.dist-info}/licenses/LICENSE +0 -0
- {mlrun-1.10.0rc18.dist-info → mlrun-1.11.0rc16.dist-info}/top_level.txt +0 -0
mlrun/api/schemas/__init__.py
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
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
|
-
Schemas were moved to mlrun.common.schemas.
|
|
17
|
-
For backwards compatibility reasons, we have left this folder untouched so that older version of mlrun would
|
|
18
|
-
be able to migrate to newer version without having to upgrade into an intermediate version.
|
|
19
|
-
|
|
20
|
-
The DeprecationHelper class is used to print a deprecation warning when the old import is used, and return the new
|
|
21
|
-
schema.
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
import sys
|
|
25
|
-
import warnings
|
|
26
|
-
|
|
27
|
-
import mlrun.common.formatters
|
|
28
|
-
import mlrun.common.schemas
|
|
29
|
-
import mlrun.common.schemas.artifact as old_artifact
|
|
30
|
-
import mlrun.common.schemas.auth as old_auth
|
|
31
|
-
import mlrun.common.schemas.background_task as old_background_task
|
|
32
|
-
import mlrun.common.schemas.client_spec as old_client_spec
|
|
33
|
-
import mlrun.common.schemas.clusterization_spec as old_clusterization_spec
|
|
34
|
-
import mlrun.common.schemas.constants as old_constants
|
|
35
|
-
import mlrun.common.schemas.feature_store as old_feature_store
|
|
36
|
-
import mlrun.common.schemas.frontend_spec as old_frontend_spec
|
|
37
|
-
import mlrun.common.schemas.function as old_function
|
|
38
|
-
import mlrun.common.schemas.http as old_http
|
|
39
|
-
import mlrun.common.schemas.k8s as old_k8s
|
|
40
|
-
import mlrun.common.schemas.memory_reports as old_memory_reports
|
|
41
|
-
import mlrun.common.schemas.model_monitoring.grafana
|
|
42
|
-
import mlrun.common.schemas.object as old_object
|
|
43
|
-
import mlrun.common.schemas.pipeline as old_pipeline
|
|
44
|
-
import mlrun.common.schemas.project as old_project
|
|
45
|
-
import mlrun.common.schemas.runtime_resource as old_runtime_resource
|
|
46
|
-
import mlrun.common.schemas.schedule as old_schedule
|
|
47
|
-
import mlrun.common.schemas.secret as old_secret
|
|
48
|
-
import mlrun.common.schemas.tag as old_tag
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class DeprecationHelper:
|
|
52
|
-
"""A helper class to deprecate old schemas"""
|
|
53
|
-
|
|
54
|
-
def __init__(self, new_target, version="1.4.0"):
|
|
55
|
-
self._new_target = new_target
|
|
56
|
-
self._version = version
|
|
57
|
-
|
|
58
|
-
def _warn(self):
|
|
59
|
-
warnings.warn(
|
|
60
|
-
f"mlrun.api.schemas.{self._new_target.__name__} is deprecated since version {self._version}, "
|
|
61
|
-
f"Use mlrun.common.schemas.{self._new_target.__name__} instead.",
|
|
62
|
-
FutureWarning,
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
def __call__(self, *args, **kwargs):
|
|
66
|
-
self._warn()
|
|
67
|
-
return self._new_target(*args, **kwargs)
|
|
68
|
-
|
|
69
|
-
def __getattr__(self, attr):
|
|
70
|
-
self._warn()
|
|
71
|
-
return getattr(self._new_target, attr)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# for backwards compatibility, we need to inject the old import path to `sys.modules`
|
|
75
|
-
sys.modules["mlrun.api.schemas.artifact"] = old_artifact
|
|
76
|
-
sys.modules["mlrun.api.schemas.auth"] = old_auth
|
|
77
|
-
sys.modules["mlrun.api.schemas.background_task"] = old_background_task
|
|
78
|
-
sys.modules["mlrun.api.schemas.client_spec"] = old_client_spec
|
|
79
|
-
sys.modules["mlrun.api.schemas.clusterization_spec"] = old_clusterization_spec
|
|
80
|
-
sys.modules["mlrun.api.schemas.constants"] = old_constants
|
|
81
|
-
sys.modules["mlrun.api.schemas.feature_store"] = old_feature_store
|
|
82
|
-
sys.modules["mlrun.api.schemas.frontend_spec"] = old_frontend_spec
|
|
83
|
-
sys.modules["mlrun.api.schemas.function"] = old_function
|
|
84
|
-
sys.modules["mlrun.api.schemas.http"] = old_http
|
|
85
|
-
sys.modules["mlrun.api.schemas.k8s"] = old_k8s
|
|
86
|
-
sys.modules["mlrun.api.schemas.memory_reports"] = old_memory_reports
|
|
87
|
-
sys.modules["mlrun.api.schemas.object"] = old_object
|
|
88
|
-
sys.modules["mlrun.api.schemas.pipeline"] = old_pipeline
|
|
89
|
-
sys.modules["mlrun.api.schemas.project"] = old_project
|
|
90
|
-
sys.modules["mlrun.api.schemas.runtime_resource"] = old_runtime_resource
|
|
91
|
-
sys.modules["mlrun.api.schemas.schedule"] = old_schedule
|
|
92
|
-
sys.modules["mlrun.api.schemas.secret"] = old_secret
|
|
93
|
-
sys.modules["mlrun.api.schemas.tag"] = old_tag
|
|
94
|
-
|
|
95
|
-
# The DeprecationHelper class is used to print a deprecation warning when the old import is used,
|
|
96
|
-
# and return the new schema. This is done for backwards compatibility with mlrun.api.schemas.
|
|
97
|
-
ArtifactCategories = DeprecationHelper(mlrun.common.schemas.ArtifactCategories)
|
|
98
|
-
ArtifactIdentifier = DeprecationHelper(mlrun.common.schemas.ArtifactIdentifier)
|
|
99
|
-
ArtifactsFormat = DeprecationHelper(mlrun.common.formatters.ArtifactFormat)
|
|
100
|
-
AuthInfo = DeprecationHelper(mlrun.common.schemas.AuthInfo)
|
|
101
|
-
AuthorizationAction = DeprecationHelper(mlrun.common.schemas.AuthorizationAction)
|
|
102
|
-
AuthorizationResourceTypes = DeprecationHelper(
|
|
103
|
-
mlrun.common.schemas.AuthorizationResourceTypes
|
|
104
|
-
)
|
|
105
|
-
AuthorizationVerificationInput = DeprecationHelper(
|
|
106
|
-
mlrun.common.schemas.AuthorizationVerificationInput
|
|
107
|
-
)
|
|
108
|
-
Credentials = DeprecationHelper(mlrun.common.schemas.Credentials)
|
|
109
|
-
ProjectsRole = DeprecationHelper(mlrun.common.schemas.ProjectsRole)
|
|
110
|
-
|
|
111
|
-
BackgroundTask = DeprecationHelper(mlrun.common.schemas.BackgroundTask)
|
|
112
|
-
BackgroundTaskMetadata = DeprecationHelper(mlrun.common.schemas.BackgroundTaskMetadata)
|
|
113
|
-
BackgroundTaskSpec = DeprecationHelper(mlrun.common.schemas.BackgroundTaskSpec)
|
|
114
|
-
BackgroundTaskState = DeprecationHelper(mlrun.common.schemas.BackgroundTaskState)
|
|
115
|
-
BackgroundTaskStatus = DeprecationHelper(mlrun.common.schemas.BackgroundTaskStatus)
|
|
116
|
-
ClientSpe = DeprecationHelper(mlrun.common.schemas.ClientSpec)
|
|
117
|
-
ClusterizationSpec = DeprecationHelper(mlrun.common.schemas.ClusterizationSpec)
|
|
118
|
-
WaitForChiefToReachOnlineStateFeatureFlag = DeprecationHelper(
|
|
119
|
-
mlrun.common.schemas.WaitForChiefToReachOnlineStateFeatureFlag
|
|
120
|
-
)
|
|
121
|
-
APIStates = DeprecationHelper(mlrun.common.schemas.APIStates)
|
|
122
|
-
ClusterizationRole = DeprecationHelper(mlrun.common.schemas.ClusterizationRole)
|
|
123
|
-
DeletionStrategy = DeprecationHelper(mlrun.common.schemas.DeletionStrategy)
|
|
124
|
-
FeatureStorePartitionByField = DeprecationHelper(
|
|
125
|
-
mlrun.common.schemas.FeatureStorePartitionByField
|
|
126
|
-
)
|
|
127
|
-
HeaderNames = DeprecationHelper(mlrun.common.schemas.HeaderNames)
|
|
128
|
-
LogsCollectorMode = DeprecationHelper(mlrun.common.schemas.LogsCollectorMode)
|
|
129
|
-
OrderType = DeprecationHelper(mlrun.common.schemas.OrderType)
|
|
130
|
-
PatchMode = DeprecationHelper(mlrun.common.schemas.PatchMode)
|
|
131
|
-
RunPartitionByField = DeprecationHelper(mlrun.common.schemas.RunPartitionByField)
|
|
132
|
-
SortField = DeprecationHelper(mlrun.common.schemas.SortField)
|
|
133
|
-
EntitiesOutput = DeprecationHelper(mlrun.common.schemas.EntitiesOutput)
|
|
134
|
-
Entity = DeprecationHelper(mlrun.common.schemas.Entity)
|
|
135
|
-
EntityListOutput = DeprecationHelper(mlrun.common.schemas.EntityListOutput)
|
|
136
|
-
EntityRecord = DeprecationHelper(mlrun.common.schemas.EntityRecord)
|
|
137
|
-
Feature = DeprecationHelper(mlrun.common.schemas.Feature)
|
|
138
|
-
FeatureListOutput = DeprecationHelper(mlrun.common.schemas.FeatureListOutput)
|
|
139
|
-
FeatureRecord = DeprecationHelper(mlrun.common.schemas.FeatureRecord)
|
|
140
|
-
FeatureSet = DeprecationHelper(mlrun.common.schemas.FeatureSet)
|
|
141
|
-
FeatureSetDigestOutput = DeprecationHelper(mlrun.common.schemas.FeatureSetDigestOutput)
|
|
142
|
-
FeatureSetDigestSpec = DeprecationHelper(mlrun.common.schemas.FeatureSetDigestSpec)
|
|
143
|
-
FeatureSetIngestInput = DeprecationHelper(mlrun.common.schemas.FeatureSetIngestInput)
|
|
144
|
-
FeatureSetIngestOutput = DeprecationHelper(mlrun.common.schemas.FeatureSetIngestOutput)
|
|
145
|
-
FeatureSetRecord = DeprecationHelper(mlrun.common.schemas.FeatureSetRecord)
|
|
146
|
-
FeatureSetsOutput = DeprecationHelper(mlrun.common.schemas.FeatureSetsOutput)
|
|
147
|
-
FeatureSetSpec = DeprecationHelper(mlrun.common.schemas.FeatureSetSpec)
|
|
148
|
-
FeatureSetsTagsOutput = DeprecationHelper(mlrun.common.schemas.FeatureSetsTagsOutput)
|
|
149
|
-
FeaturesOutput = DeprecationHelper(mlrun.common.schemas.FeaturesOutput)
|
|
150
|
-
FeatureVector = DeprecationHelper(mlrun.common.schemas.FeatureVector)
|
|
151
|
-
FeatureVectorRecord = DeprecationHelper(mlrun.common.schemas.FeatureVectorRecord)
|
|
152
|
-
FeatureVectorsOutput = DeprecationHelper(mlrun.common.schemas.FeatureVectorsOutput)
|
|
153
|
-
FeatureVectorsTagsOutput = DeprecationHelper(
|
|
154
|
-
mlrun.common.schemas.FeatureVectorsTagsOutput
|
|
155
|
-
)
|
|
156
|
-
AuthenticationFeatureFlag = DeprecationHelper(
|
|
157
|
-
mlrun.common.schemas.AuthenticationFeatureFlag
|
|
158
|
-
)
|
|
159
|
-
FeatureFlags = DeprecationHelper(mlrun.common.schemas.FeatureFlags)
|
|
160
|
-
FrontendSpec = DeprecationHelper(mlrun.common.schemas.FrontendSpec)
|
|
161
|
-
NuclioStreamsFeatureFlag = DeprecationHelper(
|
|
162
|
-
mlrun.common.schemas.NuclioStreamsFeatureFlag
|
|
163
|
-
)
|
|
164
|
-
PreemptionNodesFeatureFlag = DeprecationHelper(
|
|
165
|
-
mlrun.common.schemas.PreemptionNodesFeatureFlag
|
|
166
|
-
)
|
|
167
|
-
ProjectMembershipFeatureFlag = DeprecationHelper(
|
|
168
|
-
mlrun.common.schemas.ProjectMembershipFeatureFlag
|
|
169
|
-
)
|
|
170
|
-
FunctionState = DeprecationHelper(mlrun.common.schemas.FunctionState)
|
|
171
|
-
PreemptionModes = DeprecationHelper(mlrun.common.schemas.PreemptionModes)
|
|
172
|
-
SecurityContextEnrichmentModes = DeprecationHelper(
|
|
173
|
-
mlrun.common.schemas.SecurityContextEnrichmentModes
|
|
174
|
-
)
|
|
175
|
-
HTTPSessionRetryMode = DeprecationHelper(mlrun.common.schemas.HTTPSessionRetryMode)
|
|
176
|
-
NodeSelectorOperator = DeprecationHelper(mlrun.common.schemas.NodeSelectorOperator)
|
|
177
|
-
Resources = DeprecationHelper(mlrun.common.schemas.Resources)
|
|
178
|
-
ResourceSpec = DeprecationHelper(mlrun.common.schemas.ResourceSpec)
|
|
179
|
-
IndexedHubSource = DeprecationHelper(mlrun.common.schemas.IndexedHubSource)
|
|
180
|
-
HubCatalog = DeprecationHelper(mlrun.common.schemas.HubCatalog)
|
|
181
|
-
HubItem = DeprecationHelper(mlrun.common.schemas.HubItem)
|
|
182
|
-
HubObjectMetadata = DeprecationHelper(mlrun.common.schemas.HubObjectMetadata)
|
|
183
|
-
HubSource = DeprecationHelper(mlrun.common.schemas.HubSource)
|
|
184
|
-
HubSourceSpec = DeprecationHelper(mlrun.common.schemas.HubSourceSpec)
|
|
185
|
-
last_source_index = DeprecationHelper(mlrun.common.schemas.last_source_index)
|
|
186
|
-
MostCommonObjectTypesReport = DeprecationHelper(
|
|
187
|
-
mlrun.common.schemas.MostCommonObjectTypesReport
|
|
188
|
-
)
|
|
189
|
-
ObjectTypeReport = DeprecationHelper(mlrun.common.schemas.ObjectTypeReport)
|
|
190
|
-
Features = DeprecationHelper(mlrun.common.schemas.Features)
|
|
191
|
-
FeatureValues = DeprecationHelper(mlrun.common.schemas.FeatureValues)
|
|
192
|
-
GrafanaColumn = DeprecationHelper(
|
|
193
|
-
mlrun.common.schemas.model_monitoring.grafana.GrafanaColumn
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
GrafanaNumberColumn = DeprecationHelper(
|
|
197
|
-
mlrun.common.schemas.model_monitoring.grafana.GrafanaNumberColumn
|
|
198
|
-
)
|
|
199
|
-
GrafanaStringColumn = DeprecationHelper(
|
|
200
|
-
mlrun.common.schemas.model_monitoring.grafana.GrafanaStringColumn
|
|
201
|
-
)
|
|
202
|
-
GrafanaTable = DeprecationHelper(
|
|
203
|
-
mlrun.common.schemas.model_monitoring.grafana.GrafanaTable
|
|
204
|
-
)
|
|
205
|
-
ModelEndpoint = DeprecationHelper(mlrun.common.schemas.ModelEndpoint)
|
|
206
|
-
ModelEndpointList = DeprecationHelper(mlrun.common.schemas.ModelEndpointList)
|
|
207
|
-
ModelEndpointMetadata = DeprecationHelper(mlrun.common.schemas.ModelEndpointMetadata)
|
|
208
|
-
ModelEndpointSpec = DeprecationHelper(mlrun.common.schemas.ModelEndpointSpec)
|
|
209
|
-
ModelEndpointStatus = DeprecationHelper(mlrun.common.schemas.ModelEndpointStatus)
|
|
210
|
-
NotificationSeverity = DeprecationHelper(mlrun.common.schemas.NotificationSeverity)
|
|
211
|
-
NotificationStatus = DeprecationHelper(mlrun.common.schemas.NotificationStatus)
|
|
212
|
-
ObjectKind = DeprecationHelper(mlrun.common.schemas.ObjectKind)
|
|
213
|
-
ObjectMetadata = DeprecationHelper(mlrun.common.schemas.ObjectMetadata)
|
|
214
|
-
ObjectSpec = DeprecationHelper(mlrun.common.schemas.ObjectSpec)
|
|
215
|
-
ObjectStatus = DeprecationHelper(mlrun.common.schemas.ObjectStatus)
|
|
216
|
-
PipelinesFormat = DeprecationHelper(mlrun.common.formatters.PipelineFormat)
|
|
217
|
-
PipelinesOutput = DeprecationHelper(mlrun.common.schemas.PipelinesOutput)
|
|
218
|
-
PipelinesPagination = DeprecationHelper(mlrun.common.schemas.PipelinesPagination)
|
|
219
|
-
IguazioProject = DeprecationHelper(mlrun.common.schemas.IguazioProject)
|
|
220
|
-
Project = DeprecationHelper(mlrun.common.schemas.Project)
|
|
221
|
-
ProjectDesiredState = DeprecationHelper(mlrun.common.schemas.ProjectDesiredState)
|
|
222
|
-
ProjectMetadata = DeprecationHelper(mlrun.common.schemas.ProjectMetadata)
|
|
223
|
-
ProjectOwner = DeprecationHelper(mlrun.common.schemas.ProjectOwner)
|
|
224
|
-
ProjectsFormat = DeprecationHelper(mlrun.common.formatters.ProjectFormat)
|
|
225
|
-
ProjectsOutput = DeprecationHelper(mlrun.common.schemas.ProjectsOutput)
|
|
226
|
-
ProjectSpec = DeprecationHelper(mlrun.common.schemas.ProjectSpec)
|
|
227
|
-
ProjectState = DeprecationHelper(mlrun.common.schemas.ProjectState)
|
|
228
|
-
ProjectStatus = DeprecationHelper(mlrun.common.schemas.ProjectStatus)
|
|
229
|
-
ProjectSummariesOutput = DeprecationHelper(mlrun.common.schemas.ProjectSummariesOutput)
|
|
230
|
-
ProjectSummary = DeprecationHelper(mlrun.common.schemas.ProjectSummary)
|
|
231
|
-
GroupedByJobRuntimeResourcesOutput = DeprecationHelper(
|
|
232
|
-
mlrun.common.schemas.GroupedByJobRuntimeResourcesOutput
|
|
233
|
-
)
|
|
234
|
-
GroupedByProjectRuntimeResourcesOutput = DeprecationHelper(
|
|
235
|
-
mlrun.common.schemas.GroupedByProjectRuntimeResourcesOutput
|
|
236
|
-
)
|
|
237
|
-
KindRuntimeResources = DeprecationHelper(mlrun.common.schemas.KindRuntimeResources)
|
|
238
|
-
ListRuntimeResourcesGroupByField = DeprecationHelper(
|
|
239
|
-
mlrun.common.schemas.ListRuntimeResourcesGroupByField
|
|
240
|
-
)
|
|
241
|
-
RuntimeResource = DeprecationHelper(mlrun.common.schemas.RuntimeResource)
|
|
242
|
-
RuntimeResources = DeprecationHelper(mlrun.common.schemas.RuntimeResources)
|
|
243
|
-
RuntimeResourcesOutput = DeprecationHelper(mlrun.common.schemas.RuntimeResourcesOutput)
|
|
244
|
-
ScheduleCronTrigger = DeprecationHelper(mlrun.common.schemas.ScheduleCronTrigger)
|
|
245
|
-
ScheduleInput = DeprecationHelper(mlrun.common.schemas.ScheduleInput)
|
|
246
|
-
ScheduleKinds = DeprecationHelper(mlrun.common.schemas.ScheduleKinds)
|
|
247
|
-
ScheduleOutput = DeprecationHelper(mlrun.common.schemas.ScheduleOutput)
|
|
248
|
-
ScheduleRecord = DeprecationHelper(mlrun.common.schemas.ScheduleRecord)
|
|
249
|
-
SchedulesOutput = DeprecationHelper(mlrun.common.schemas.SchedulesOutput)
|
|
250
|
-
ScheduleUpdate = DeprecationHelper(mlrun.common.schemas.ScheduleUpdate)
|
|
251
|
-
AuthSecretData = DeprecationHelper(mlrun.common.schemas.AuthSecretData)
|
|
252
|
-
SecretKeysData = DeprecationHelper(mlrun.common.schemas.SecretKeysData)
|
|
253
|
-
SecretProviderName = DeprecationHelper(mlrun.common.schemas.SecretProviderName)
|
|
254
|
-
SecretsData = DeprecationHelper(mlrun.common.schemas.SecretsData)
|
|
255
|
-
UserSecretCreationRequest = DeprecationHelper(
|
|
256
|
-
mlrun.common.schemas.UserSecretCreationRequest
|
|
257
|
-
)
|
|
258
|
-
Tag = DeprecationHelper(mlrun.common.schemas.Tag)
|
|
259
|
-
TagObjects = DeprecationHelper(mlrun.common.schemas.TagObjects)
|
mlrun/db/auth_utils.py
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
# Copyright 2024 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 abc import ABC, abstractmethod
|
|
16
|
-
from datetime import datetime, timedelta
|
|
17
|
-
|
|
18
|
-
import requests
|
|
19
|
-
|
|
20
|
-
import mlrun.errors
|
|
21
|
-
from mlrun.utils import logger
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class TokenProvider(ABC):
|
|
25
|
-
@abstractmethod
|
|
26
|
-
def get_token(self):
|
|
27
|
-
pass
|
|
28
|
-
|
|
29
|
-
@abstractmethod
|
|
30
|
-
def is_iguazio_session(self):
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class StaticTokenProvider(TokenProvider):
|
|
35
|
-
def __init__(self, token: str):
|
|
36
|
-
self.token = token
|
|
37
|
-
|
|
38
|
-
def get_token(self):
|
|
39
|
-
return self.token
|
|
40
|
-
|
|
41
|
-
def is_iguazio_session(self):
|
|
42
|
-
return mlrun.platforms.iguazio.is_iguazio_session(self.token)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class OAuthClientIDTokenProvider(TokenProvider):
|
|
46
|
-
def __init__(
|
|
47
|
-
self, token_endpoint: str, client_id: str, client_secret: str, timeout=5
|
|
48
|
-
):
|
|
49
|
-
if not token_endpoint or not client_id or not client_secret:
|
|
50
|
-
raise mlrun.errors.MLRunValueError(
|
|
51
|
-
"Invalid client_id configuration for authentication. Must provide token endpoint, client-id and secret"
|
|
52
|
-
)
|
|
53
|
-
self.token_endpoint = token_endpoint
|
|
54
|
-
self.client_id = client_id
|
|
55
|
-
self.client_secret = client_secret
|
|
56
|
-
self.timeout = timeout
|
|
57
|
-
|
|
58
|
-
# Since we're only issuing POST requests, which are actually a disguised GET, then it's ok to allow retries
|
|
59
|
-
# on them.
|
|
60
|
-
self._session = mlrun.utils.HTTPSessionWithRetry(
|
|
61
|
-
retry_on_post=True,
|
|
62
|
-
verbose=True,
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
self._cleanup()
|
|
66
|
-
self._refresh_token_if_needed()
|
|
67
|
-
|
|
68
|
-
def get_token(self):
|
|
69
|
-
self._refresh_token_if_needed()
|
|
70
|
-
return self.token
|
|
71
|
-
|
|
72
|
-
def is_iguazio_session(self):
|
|
73
|
-
return False
|
|
74
|
-
|
|
75
|
-
def _cleanup(self):
|
|
76
|
-
self.token = self.token_expiry_time = self.token_refresh_time = None
|
|
77
|
-
|
|
78
|
-
def _refresh_token_if_needed(self):
|
|
79
|
-
now = datetime.now()
|
|
80
|
-
if self.token:
|
|
81
|
-
if self.token_refresh_time and now <= self.token_refresh_time:
|
|
82
|
-
return self.token
|
|
83
|
-
|
|
84
|
-
# We only cleanup if token was really expired - even if we fail in refreshing the token, we can still
|
|
85
|
-
# use the existing one given that it's not expired.
|
|
86
|
-
if now >= self.token_expiry_time:
|
|
87
|
-
self._cleanup()
|
|
88
|
-
|
|
89
|
-
self._issue_token_request()
|
|
90
|
-
return self.token
|
|
91
|
-
|
|
92
|
-
def _issue_token_request(self, raise_on_error=False):
|
|
93
|
-
try:
|
|
94
|
-
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
|
95
|
-
request_body = {
|
|
96
|
-
"grant_type": "client_credentials",
|
|
97
|
-
"client_id": self.client_id,
|
|
98
|
-
"client_secret": self.client_secret,
|
|
99
|
-
}
|
|
100
|
-
response = self._session.request(
|
|
101
|
-
"POST",
|
|
102
|
-
self.token_endpoint,
|
|
103
|
-
timeout=self.timeout,
|
|
104
|
-
headers=headers,
|
|
105
|
-
data=request_body,
|
|
106
|
-
)
|
|
107
|
-
except requests.RequestException as exc:
|
|
108
|
-
error = f"Retrieving token failed: {mlrun.errors.err_to_str(exc)}"
|
|
109
|
-
if raise_on_error:
|
|
110
|
-
raise mlrun.errors.MLRunRuntimeError(error) from exc
|
|
111
|
-
else:
|
|
112
|
-
logger.warning(error)
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
if not response.ok:
|
|
116
|
-
error = "No error available"
|
|
117
|
-
if response.content:
|
|
118
|
-
try:
|
|
119
|
-
data = response.json()
|
|
120
|
-
error = data.get("error")
|
|
121
|
-
except Exception:
|
|
122
|
-
pass
|
|
123
|
-
logger.warning(
|
|
124
|
-
"Retrieving token failed", status=response.status_code, error=error
|
|
125
|
-
)
|
|
126
|
-
if raise_on_error:
|
|
127
|
-
mlrun.errors.raise_for_status(response)
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
self._parse_response(response.json())
|
|
131
|
-
|
|
132
|
-
def _parse_response(self, data: dict):
|
|
133
|
-
# Response is described in https://datatracker.ietf.org/doc/html/rfc6749#section-4.4.3
|
|
134
|
-
# According to spec, there isn't a refresh token - just the access token and its expiry time (in seconds).
|
|
135
|
-
self.token = data.get("access_token")
|
|
136
|
-
expires_in = data.get("expires_in")
|
|
137
|
-
if not self.token or not expires_in:
|
|
138
|
-
token_str = "****" if self.token else "missing"
|
|
139
|
-
logger.warning(
|
|
140
|
-
"Failed to parse token response", token=token_str, expires_in=expires_in
|
|
141
|
-
)
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
now = datetime.now()
|
|
145
|
-
self.token_expiry_time = now + timedelta(seconds=expires_in)
|
|
146
|
-
self.token_refresh_time = now + timedelta(seconds=expires_in / 2)
|
|
147
|
-
logger.info(
|
|
148
|
-
"Successfully retrieved client-id token",
|
|
149
|
-
expires_in=expires_in,
|
|
150
|
-
expiry=str(self.token_expiry_time),
|
|
151
|
-
refresh=str(self.token_refresh_time),
|
|
152
|
-
)
|