mlrun 1.7.0rc14__py3-none-any.whl → 1.7.0rc21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mlrun might be problematic. Click here for more details.

Files changed (152) hide show
  1. mlrun/__init__.py +10 -1
  2. mlrun/__main__.py +23 -111
  3. mlrun/alerts/__init__.py +15 -0
  4. mlrun/alerts/alert.py +144 -0
  5. mlrun/api/schemas/__init__.py +4 -3
  6. mlrun/artifacts/__init__.py +8 -3
  7. mlrun/artifacts/base.py +36 -253
  8. mlrun/artifacts/dataset.py +9 -190
  9. mlrun/artifacts/manager.py +46 -42
  10. mlrun/artifacts/model.py +9 -141
  11. mlrun/artifacts/plots.py +14 -375
  12. mlrun/common/constants.py +65 -3
  13. mlrun/common/formatters/__init__.py +19 -0
  14. mlrun/{runtimes/mpijob/v1alpha1.py → common/formatters/artifact.py} +6 -14
  15. mlrun/common/formatters/base.py +113 -0
  16. mlrun/common/formatters/function.py +46 -0
  17. mlrun/common/formatters/pipeline.py +53 -0
  18. mlrun/common/formatters/project.py +51 -0
  19. mlrun/{runtimes → common/runtimes}/constants.py +32 -4
  20. mlrun/common/schemas/__init__.py +10 -5
  21. mlrun/common/schemas/alert.py +92 -11
  22. mlrun/common/schemas/api_gateway.py +56 -0
  23. mlrun/common/schemas/artifact.py +15 -5
  24. mlrun/common/schemas/auth.py +2 -0
  25. mlrun/common/schemas/client_spec.py +1 -0
  26. mlrun/common/schemas/frontend_spec.py +1 -0
  27. mlrun/common/schemas/function.py +4 -0
  28. mlrun/common/schemas/model_monitoring/__init__.py +15 -3
  29. mlrun/common/schemas/model_monitoring/constants.py +58 -7
  30. mlrun/common/schemas/model_monitoring/grafana.py +9 -5
  31. mlrun/common/schemas/model_monitoring/model_endpoints.py +86 -2
  32. mlrun/common/schemas/pipeline.py +0 -9
  33. mlrun/common/schemas/project.py +5 -11
  34. mlrun/common/types.py +1 -0
  35. mlrun/config.py +27 -9
  36. mlrun/data_types/to_pandas.py +9 -9
  37. mlrun/datastore/base.py +41 -9
  38. mlrun/datastore/datastore.py +6 -2
  39. mlrun/datastore/datastore_profile.py +56 -4
  40. mlrun/datastore/inmem.py +2 -2
  41. mlrun/datastore/redis.py +2 -2
  42. mlrun/datastore/s3.py +5 -0
  43. mlrun/datastore/sources.py +147 -7
  44. mlrun/datastore/store_resources.py +7 -7
  45. mlrun/datastore/targets.py +110 -42
  46. mlrun/datastore/utils.py +42 -0
  47. mlrun/db/base.py +54 -10
  48. mlrun/db/httpdb.py +282 -79
  49. mlrun/db/nopdb.py +52 -10
  50. mlrun/errors.py +11 -0
  51. mlrun/execution.py +24 -9
  52. mlrun/feature_store/__init__.py +0 -2
  53. mlrun/feature_store/api.py +12 -47
  54. mlrun/feature_store/feature_set.py +9 -0
  55. mlrun/feature_store/feature_vector.py +8 -0
  56. mlrun/feature_store/ingestion.py +7 -6
  57. mlrun/feature_store/retrieval/base.py +9 -4
  58. mlrun/feature_store/retrieval/conversion.py +9 -9
  59. mlrun/feature_store/retrieval/dask_merger.py +2 -0
  60. mlrun/feature_store/retrieval/job.py +9 -3
  61. mlrun/feature_store/retrieval/local_merger.py +2 -0
  62. mlrun/feature_store/retrieval/spark_merger.py +16 -0
  63. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +7 -12
  64. mlrun/frameworks/parallel_coordinates.py +2 -1
  65. mlrun/frameworks/tf_keras/__init__.py +4 -1
  66. mlrun/k8s_utils.py +10 -11
  67. mlrun/launcher/base.py +4 -3
  68. mlrun/launcher/client.py +5 -3
  69. mlrun/launcher/local.py +8 -2
  70. mlrun/launcher/remote.py +8 -2
  71. mlrun/lists.py +6 -2
  72. mlrun/model.py +45 -21
  73. mlrun/model_monitoring/__init__.py +1 -1
  74. mlrun/model_monitoring/api.py +41 -18
  75. mlrun/model_monitoring/application.py +5 -305
  76. mlrun/model_monitoring/applications/__init__.py +11 -0
  77. mlrun/model_monitoring/applications/_application_steps.py +157 -0
  78. mlrun/model_monitoring/applications/base.py +280 -0
  79. mlrun/model_monitoring/applications/context.py +214 -0
  80. mlrun/model_monitoring/applications/evidently_base.py +211 -0
  81. mlrun/model_monitoring/applications/histogram_data_drift.py +132 -91
  82. mlrun/model_monitoring/applications/results.py +99 -0
  83. mlrun/model_monitoring/controller.py +3 -1
  84. mlrun/model_monitoring/db/__init__.py +2 -0
  85. mlrun/model_monitoring/db/stores/__init__.py +0 -2
  86. mlrun/model_monitoring/db/stores/base/store.py +22 -37
  87. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +43 -21
  88. mlrun/model_monitoring/db/stores/sqldb/models/base.py +39 -8
  89. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +27 -7
  90. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +5 -0
  91. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +246 -224
  92. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +232 -216
  93. mlrun/model_monitoring/db/tsdb/__init__.py +100 -0
  94. mlrun/model_monitoring/db/tsdb/base.py +329 -0
  95. mlrun/model_monitoring/db/tsdb/helpers.py +30 -0
  96. mlrun/model_monitoring/db/tsdb/tdengine/__init__.py +15 -0
  97. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +240 -0
  98. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +45 -0
  99. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +397 -0
  100. mlrun/model_monitoring/db/tsdb/v3io/__init__.py +15 -0
  101. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +117 -0
  102. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +636 -0
  103. mlrun/model_monitoring/evidently_application.py +6 -118
  104. mlrun/model_monitoring/helpers.py +46 -1
  105. mlrun/model_monitoring/model_endpoint.py +3 -2
  106. mlrun/model_monitoring/stream_processing.py +57 -216
  107. mlrun/model_monitoring/writer.py +134 -124
  108. mlrun/package/utils/_formatter.py +2 -2
  109. mlrun/platforms/__init__.py +10 -9
  110. mlrun/platforms/iguazio.py +21 -202
  111. mlrun/projects/operations.py +19 -12
  112. mlrun/projects/pipelines.py +79 -102
  113. mlrun/projects/project.py +265 -103
  114. mlrun/render.py +15 -14
  115. mlrun/run.py +16 -46
  116. mlrun/runtimes/__init__.py +6 -3
  117. mlrun/runtimes/base.py +8 -7
  118. mlrun/runtimes/databricks_job/databricks_wrapper.py +1 -1
  119. mlrun/runtimes/funcdoc.py +0 -28
  120. mlrun/runtimes/kubejob.py +2 -1
  121. mlrun/runtimes/local.py +5 -2
  122. mlrun/runtimes/mpijob/__init__.py +0 -20
  123. mlrun/runtimes/mpijob/v1.py +1 -1
  124. mlrun/runtimes/nuclio/api_gateway.py +194 -84
  125. mlrun/runtimes/nuclio/application/application.py +170 -8
  126. mlrun/runtimes/nuclio/function.py +39 -49
  127. mlrun/runtimes/pod.py +16 -36
  128. mlrun/runtimes/remotesparkjob.py +9 -3
  129. mlrun/runtimes/sparkjob/spark3job.py +1 -1
  130. mlrun/runtimes/utils.py +6 -45
  131. mlrun/serving/server.py +2 -1
  132. mlrun/serving/v2_serving.py +5 -1
  133. mlrun/track/tracker.py +2 -1
  134. mlrun/utils/async_http.py +25 -5
  135. mlrun/utils/helpers.py +107 -75
  136. mlrun/utils/logger.py +39 -7
  137. mlrun/utils/notifications/notification/__init__.py +14 -9
  138. mlrun/utils/notifications/notification/base.py +1 -1
  139. mlrun/utils/notifications/notification/slack.py +34 -7
  140. mlrun/utils/notifications/notification/webhook.py +1 -1
  141. mlrun/utils/notifications/notification_pusher.py +147 -16
  142. mlrun/utils/regex.py +9 -0
  143. mlrun/utils/v3io_clients.py +0 -1
  144. mlrun/utils/version/version.json +2 -2
  145. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc21.dist-info}/METADATA +14 -6
  146. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc21.dist-info}/RECORD +150 -130
  147. mlrun/kfpops.py +0 -865
  148. mlrun/platforms/other.py +0 -305
  149. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc21.dist-info}/LICENSE +0 -0
  150. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc21.dist-info}/WHEEL +0 -0
  151. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc21.dist-info}/entry_points.txt +0 -0
  152. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc21.dist-info}/top_level.txt +0 -0
mlrun/platforms/other.py DELETED
@@ -1,305 +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
- # this file is based on the code from kubeflow pipelines git
16
- import os
17
-
18
- import kfp.dsl
19
-
20
- import mlrun
21
- from mlrun.config import config
22
- from mlrun.errors import MLRunInvalidArgumentError
23
- from mlrun.utils.helpers import logger
24
-
25
- from .iguazio import mount_v3io
26
-
27
-
28
- def mount_pvc(pvc_name=None, volume_name="pipeline", volume_mount_path="/mnt/pipeline"):
29
- """
30
- Modifier function to apply to a Container Op to simplify volume, volume mount addition and
31
- enable better reuse of volumes, volume claims across container ops.
32
-
33
- Usage::
34
-
35
- train = train_op(...)
36
- train.apply(mount_pvc("claim-name", "pipeline", "/mnt/pipeline"))
37
- """
38
- if "MLRUN_PVC_MOUNT" in os.environ:
39
- mount = os.environ.get("MLRUN_PVC_MOUNT")
40
- items = mount.split(":")
41
- if len(items) != 2:
42
- raise MLRunInvalidArgumentError(
43
- "MLRUN_PVC_MOUNT should include <pvc-name>:<mount-path>"
44
- )
45
- pvc_name = items[0]
46
- volume_mount_path = items[1]
47
-
48
- if not pvc_name:
49
- raise MLRunInvalidArgumentError(
50
- "No PVC name: use the pvc_name parameter or configure the MLRUN_PVC_MOUNT environment variable"
51
- )
52
-
53
- def _mount_pvc(task):
54
- from kubernetes import client as k8s_client
55
-
56
- local_pvc = k8s_client.V1PersistentVolumeClaimVolumeSource(claim_name=pvc_name)
57
- return task.add_volume(
58
- k8s_client.V1Volume(name=volume_name, persistent_volume_claim=local_pvc)
59
- ).add_volume_mount(
60
- k8s_client.V1VolumeMount(mount_path=volume_mount_path, name=volume_name)
61
- )
62
-
63
- return _mount_pvc
64
-
65
-
66
- def auto_mount(pvc_name="", volume_mount_path="", volume_name=None):
67
- """choose the mount based on env variables and params
68
-
69
- volume will be selected by the following order:
70
- - k8s PVC volume when both pvc_name and volume_mount_path are set
71
- - k8s PVC volume when env var is set: MLRUN_PVC_MOUNT=<pvc-name>:<mount-path>
72
- - k8s PVC volume if it's configured as the auto mount type
73
- - iguazio v3io volume when V3IO_ACCESS_KEY and V3IO_USERNAME env vars are set
74
- """
75
- if pvc_name and volume_mount_path:
76
- return mount_pvc(
77
- pvc_name=pvc_name,
78
- volume_mount_path=volume_mount_path,
79
- volume_name=volume_name or "shared-persistency",
80
- )
81
- if "MLRUN_PVC_MOUNT" in os.environ:
82
- return mount_pvc(
83
- volume_name=volume_name or "shared-persistency",
84
- )
85
- # In the case of MLRun-kit when working remotely, no env variables will be defined but auto-mount
86
- # parameters may still be declared - use them in that case.
87
- if config.storage.auto_mount_type == "pvc":
88
- return mount_pvc(**config.get_storage_auto_mount_params())
89
- if "V3IO_ACCESS_KEY" in os.environ:
90
- return mount_v3io(name=volume_name or "v3io")
91
-
92
- raise ValueError("failed to auto mount, need to set env vars")
93
-
94
-
95
- def mount_secret(secret_name, mount_path, volume_name="secret", items=None):
96
- """Modifier function to mount kubernetes secret as files(s)
97
-
98
- :param secret_name: k8s secret name
99
- :param mount_path: path to mount inside the container
100
- :param volume_name: unique volume name
101
- :param items: If unspecified, each key-value pair in the Data field
102
- of the referenced Secret will be projected into the
103
- volume as a file whose name is the key and content is
104
- the value.
105
- If specified, the listed keys will be projected into
106
- the specified paths, and unlisted keys will not be
107
- present.
108
- """
109
-
110
- def _mount_secret(task):
111
- from kubernetes import client as k8s_client
112
-
113
- vol = k8s_client.V1SecretVolumeSource(secret_name=secret_name, items=items)
114
- return task.add_volume(
115
- k8s_client.V1Volume(name=volume_name, secret=vol)
116
- ).add_volume_mount(
117
- k8s_client.V1VolumeMount(mount_path=mount_path, name=volume_name)
118
- )
119
-
120
- return _mount_secret
121
-
122
-
123
- def mount_configmap(configmap_name, mount_path, volume_name="configmap", items=None):
124
- """Modifier function to mount kubernetes configmap as files(s)
125
-
126
- :param configmap_name: k8s configmap name
127
- :param mount_path: path to mount inside the container
128
- :param volume_name: unique volume name
129
- :param items: If unspecified, each key-value pair in the Data field
130
- of the referenced Configmap will be projected into the
131
- volume as a file whose name is the key and content is
132
- the value.
133
- If specified, the listed keys will be projected into
134
- the specified paths, and unlisted keys will not be
135
- present.
136
- """
137
-
138
- def _mount_configmap(task):
139
- from kubernetes import client as k8s_client
140
-
141
- vol = k8s_client.V1ConfigMapVolumeSource(name=configmap_name, items=items)
142
- return task.add_volume(
143
- k8s_client.V1Volume(name=volume_name, config_map=vol)
144
- ).add_volume_mount(
145
- k8s_client.V1VolumeMount(mount_path=mount_path, name=volume_name)
146
- )
147
-
148
- return _mount_configmap
149
-
150
-
151
- def mount_hostpath(host_path, mount_path, volume_name="hostpath"):
152
- """Modifier function to mount kubernetes configmap as files(s)
153
-
154
- :param host_path: host path
155
- :param mount_path: path to mount inside the container
156
- :param volume_name: unique volume name
157
- """
158
-
159
- def _mount_hostpath(task):
160
- from kubernetes import client as k8s_client
161
-
162
- return task.add_volume(
163
- k8s_client.V1Volume(
164
- name=volume_name,
165
- host_path=k8s_client.V1HostPathVolumeSource(path=host_path, type=""),
166
- )
167
- ).add_volume_mount(
168
- k8s_client.V1VolumeMount(mount_path=mount_path, name=volume_name)
169
- )
170
-
171
- return _mount_hostpath
172
-
173
-
174
- def mount_s3(
175
- secret_name=None,
176
- aws_access_key="",
177
- aws_secret_key="",
178
- endpoint_url=None,
179
- prefix="",
180
- aws_region=None,
181
- non_anonymous=False,
182
- ):
183
- """Modifier function to add s3 env vars or secrets to container
184
-
185
- **Warning:**
186
- Using this function to configure AWS credentials will expose these credentials in the pod spec of the runtime
187
- created. It is recommended to use the `secret_name` parameter, or set the credentials as project-secrets and avoid
188
- using this function.
189
-
190
- :param secret_name: kubernetes secret name (storing the access/secret keys)
191
- :param aws_access_key: AWS_ACCESS_KEY_ID value. If this parameter is not specified and AWS_ACCESS_KEY_ID env.
192
- variable is defined, the value will be taken from the env. variable
193
- :param aws_secret_key: AWS_SECRET_ACCESS_KEY value. If this parameter is not specified and AWS_SECRET_ACCESS_KEY
194
- env. variable is defined, the value will be taken from the env. variable
195
- :param endpoint_url: s3 endpoint address (for non AWS s3)
196
- :param prefix: string prefix to add before the env var name (for working with multiple s3 data stores)
197
- :param aws_region: amazon region
198
- :param non_anonymous: force the S3 API to use non-anonymous connection, even if no credentials are provided
199
- (for authenticating externally, such as through IAM instance-roles)
200
- """
201
-
202
- if secret_name and (aws_access_key or aws_secret_key):
203
- raise mlrun.errors.MLRunInvalidArgumentError(
204
- "can use k8s_secret for credentials or specify them (aws_access_key, aws_secret_key) not both"
205
- )
206
-
207
- if not secret_name and (
208
- aws_access_key
209
- or os.environ.get(prefix + "AWS_ACCESS_KEY_ID")
210
- or aws_secret_key
211
- or os.environ.get(prefix + "AWS_SECRET_ACCESS_KEY")
212
- ):
213
- logger.warning(
214
- "it is recommended to use k8s secret (specify secret_name), "
215
- "specifying the aws_access_key/aws_secret_key directly is unsafe"
216
- )
217
-
218
- def _use_s3_cred(container_op):
219
- from os import environ
220
-
221
- from kubernetes import client as k8s_client
222
-
223
- _access_key = aws_access_key or environ.get(prefix + "AWS_ACCESS_KEY_ID")
224
- _secret_key = aws_secret_key or environ.get(prefix + "AWS_SECRET_ACCESS_KEY")
225
- _endpoint_url = endpoint_url or environ.get(prefix + "S3_ENDPOINT_URL")
226
-
227
- container = container_op.container
228
- if _endpoint_url:
229
- container.add_env_variable(
230
- k8s_client.V1EnvVar(name=prefix + "S3_ENDPOINT_URL", value=endpoint_url)
231
- )
232
- if aws_region:
233
- container.add_env_variable(
234
- k8s_client.V1EnvVar(name=prefix + "AWS_REGION", value=aws_region)
235
- )
236
- if non_anonymous:
237
- container.add_env_variable(
238
- k8s_client.V1EnvVar(name=prefix + "S3_NON_ANONYMOUS", value="true")
239
- )
240
-
241
- if secret_name:
242
- container.add_env_variable(
243
- k8s_client.V1EnvVar(
244
- name=prefix + "AWS_ACCESS_KEY_ID",
245
- value_from=k8s_client.V1EnvVarSource(
246
- secret_key_ref=k8s_client.V1SecretKeySelector(
247
- name=secret_name, key="AWS_ACCESS_KEY_ID"
248
- )
249
- ),
250
- )
251
- ).add_env_variable(
252
- k8s_client.V1EnvVar(
253
- name=prefix + "AWS_SECRET_ACCESS_KEY",
254
- value_from=k8s_client.V1EnvVarSource(
255
- secret_key_ref=k8s_client.V1SecretKeySelector(
256
- name=secret_name, key="AWS_SECRET_ACCESS_KEY"
257
- )
258
- ),
259
- )
260
- )
261
-
262
- else:
263
- return container_op.add_env_variable(
264
- k8s_client.V1EnvVar(
265
- name=prefix + "AWS_ACCESS_KEY_ID", value=_access_key
266
- )
267
- ).add_env_variable(
268
- k8s_client.V1EnvVar(
269
- name=prefix + "AWS_SECRET_ACCESS_KEY", value=_secret_key
270
- )
271
- )
272
-
273
- return _use_s3_cred
274
-
275
-
276
- def set_env_variables(env_vars_dict: dict[str, str] = None, **kwargs):
277
- """
278
- Modifier function to apply a set of environment variables to a runtime. Variables may be passed
279
- as either a dictionary of name-value pairs, or as arguments to the function.
280
- See `KubeResource.apply` for more information on modifiers.
281
-
282
- Usage::
283
-
284
- function.apply(set_env_variables({"ENV1": "value1", "ENV2": "value2"}))
285
- or
286
- function.apply(set_env_variables(ENV1=value1, ENV2=value2))
287
-
288
- :param env_vars_dict: dictionary of env. variables
289
- :param kwargs: environment variables passed as args
290
- """
291
-
292
- env_data = env_vars_dict.copy() if env_vars_dict else {}
293
- for key, value in kwargs.items():
294
- env_data[key] = value
295
-
296
- def _set_env_variables(container_op: kfp.dsl.ContainerOp):
297
- from kubernetes import client as k8s_client
298
-
299
- for _key, _value in env_data.items():
300
- container_op.container.add_env_variable(
301
- k8s_client.V1EnvVar(name=_key, value=_value)
302
- )
303
- return container_op
304
-
305
- return _set_env_variables