mlrun 1.7.1rc10__py3-none-any.whl → 1.8.0rc8__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 (257) hide show
  1. mlrun/__init__.py +23 -21
  2. mlrun/__main__.py +3 -3
  3. mlrun/alerts/alert.py +148 -14
  4. mlrun/artifacts/__init__.py +1 -2
  5. mlrun/artifacts/base.py +46 -12
  6. mlrun/artifacts/dataset.py +16 -16
  7. mlrun/artifacts/document.py +334 -0
  8. mlrun/artifacts/manager.py +15 -13
  9. mlrun/artifacts/model.py +66 -53
  10. mlrun/common/constants.py +7 -0
  11. mlrun/common/formatters/__init__.py +1 -0
  12. mlrun/common/formatters/feature_set.py +1 -0
  13. mlrun/common/formatters/function.py +1 -0
  14. mlrun/{model_monitoring/db/stores/base/__init__.py → common/formatters/model_endpoint.py} +16 -1
  15. mlrun/common/formatters/pipeline.py +1 -2
  16. mlrun/common/formatters/project.py +9 -0
  17. mlrun/common/model_monitoring/__init__.py +0 -5
  18. mlrun/common/model_monitoring/helpers.py +1 -29
  19. mlrun/common/runtimes/constants.py +1 -2
  20. mlrun/common/schemas/__init__.py +6 -2
  21. mlrun/common/schemas/alert.py +111 -19
  22. mlrun/common/schemas/api_gateway.py +3 -3
  23. mlrun/common/schemas/artifact.py +11 -7
  24. mlrun/common/schemas/auth.py +6 -4
  25. mlrun/common/schemas/background_task.py +7 -7
  26. mlrun/common/schemas/client_spec.py +2 -3
  27. mlrun/common/schemas/clusterization_spec.py +2 -2
  28. mlrun/common/schemas/common.py +53 -3
  29. mlrun/common/schemas/constants.py +15 -0
  30. mlrun/common/schemas/datastore_profile.py +1 -1
  31. mlrun/common/schemas/feature_store.py +9 -9
  32. mlrun/common/schemas/frontend_spec.py +4 -4
  33. mlrun/common/schemas/function.py +10 -10
  34. mlrun/common/schemas/hub.py +1 -1
  35. mlrun/common/schemas/k8s.py +3 -3
  36. mlrun/common/schemas/memory_reports.py +3 -3
  37. mlrun/common/schemas/model_monitoring/__init__.py +2 -1
  38. mlrun/common/schemas/model_monitoring/constants.py +66 -14
  39. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  40. mlrun/common/schemas/model_monitoring/model_endpoints.py +91 -147
  41. mlrun/common/schemas/notification.py +24 -3
  42. mlrun/common/schemas/object.py +1 -1
  43. mlrun/common/schemas/pagination.py +4 -4
  44. mlrun/common/schemas/partition.py +137 -0
  45. mlrun/common/schemas/pipeline.py +2 -2
  46. mlrun/common/schemas/project.py +25 -17
  47. mlrun/common/schemas/runs.py +2 -2
  48. mlrun/common/schemas/runtime_resource.py +5 -5
  49. mlrun/common/schemas/schedule.py +1 -1
  50. mlrun/common/schemas/secret.py +1 -1
  51. mlrun/common/schemas/tag.py +3 -3
  52. mlrun/common/schemas/workflow.py +5 -5
  53. mlrun/config.py +67 -10
  54. mlrun/data_types/__init__.py +0 -2
  55. mlrun/data_types/infer.py +3 -1
  56. mlrun/data_types/spark.py +2 -1
  57. mlrun/datastore/__init__.py +0 -2
  58. mlrun/datastore/alibaba_oss.py +4 -1
  59. mlrun/datastore/azure_blob.py +4 -1
  60. mlrun/datastore/base.py +12 -4
  61. mlrun/datastore/datastore.py +9 -3
  62. mlrun/datastore/datastore_profile.py +79 -20
  63. mlrun/datastore/dbfs_store.py +4 -1
  64. mlrun/datastore/filestore.py +4 -1
  65. mlrun/datastore/google_cloud_storage.py +4 -1
  66. mlrun/datastore/hdfs.py +4 -1
  67. mlrun/datastore/inmem.py +4 -1
  68. mlrun/datastore/redis.py +4 -1
  69. mlrun/datastore/s3.py +4 -1
  70. mlrun/datastore/sources.py +52 -51
  71. mlrun/datastore/store_resources.py +0 -2
  72. mlrun/datastore/targets.py +21 -21
  73. mlrun/datastore/utils.py +2 -2
  74. mlrun/datastore/v3io.py +4 -1
  75. mlrun/datastore/vectorstore.py +194 -0
  76. mlrun/datastore/wasbfs/fs.py +13 -12
  77. mlrun/db/base.py +208 -82
  78. mlrun/db/factory.py +0 -3
  79. mlrun/db/httpdb.py +1237 -386
  80. mlrun/db/nopdb.py +201 -74
  81. mlrun/errors.py +2 -2
  82. mlrun/execution.py +136 -50
  83. mlrun/feature_store/__init__.py +0 -2
  84. mlrun/feature_store/api.py +41 -40
  85. mlrun/feature_store/common.py +9 -9
  86. mlrun/feature_store/feature_set.py +20 -18
  87. mlrun/feature_store/feature_vector.py +27 -24
  88. mlrun/feature_store/retrieval/base.py +14 -9
  89. mlrun/feature_store/retrieval/job.py +2 -1
  90. mlrun/feature_store/steps.py +2 -2
  91. mlrun/features.py +30 -13
  92. mlrun/frameworks/__init__.py +1 -2
  93. mlrun/frameworks/_common/__init__.py +1 -2
  94. mlrun/frameworks/_common/artifacts_library.py +2 -2
  95. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  96. mlrun/frameworks/_common/model_handler.py +29 -27
  97. mlrun/frameworks/_common/producer.py +3 -1
  98. mlrun/frameworks/_dl_common/__init__.py +1 -2
  99. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  100. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  101. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  102. mlrun/frameworks/_ml_common/__init__.py +1 -2
  103. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  104. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  105. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  106. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  107. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  108. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  109. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  110. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  111. mlrun/frameworks/huggingface/__init__.py +1 -2
  112. mlrun/frameworks/huggingface/model_server.py +9 -9
  113. mlrun/frameworks/lgbm/__init__.py +47 -44
  114. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  115. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  116. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  117. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  118. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  119. mlrun/frameworks/lgbm/model_handler.py +15 -11
  120. mlrun/frameworks/lgbm/model_server.py +11 -7
  121. mlrun/frameworks/lgbm/utils.py +2 -2
  122. mlrun/frameworks/onnx/__init__.py +1 -2
  123. mlrun/frameworks/onnx/dataset.py +3 -3
  124. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  125. mlrun/frameworks/onnx/model_handler.py +7 -5
  126. mlrun/frameworks/onnx/model_server.py +8 -6
  127. mlrun/frameworks/parallel_coordinates.py +11 -11
  128. mlrun/frameworks/pytorch/__init__.py +22 -23
  129. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  130. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  131. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  132. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  133. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  134. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  135. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  136. mlrun/frameworks/pytorch/model_handler.py +21 -17
  137. mlrun/frameworks/pytorch/model_server.py +13 -9
  138. mlrun/frameworks/sklearn/__init__.py +19 -18
  139. mlrun/frameworks/sklearn/estimator.py +2 -2
  140. mlrun/frameworks/sklearn/metric.py +3 -3
  141. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  142. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  143. mlrun/frameworks/sklearn/model_handler.py +4 -3
  144. mlrun/frameworks/tf_keras/__init__.py +11 -12
  145. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  146. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  147. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  148. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  149. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  150. mlrun/frameworks/tf_keras/model_server.py +12 -8
  151. mlrun/frameworks/xgboost/__init__.py +19 -18
  152. mlrun/frameworks/xgboost/model_handler.py +13 -9
  153. mlrun/launcher/base.py +3 -4
  154. mlrun/launcher/local.py +1 -1
  155. mlrun/launcher/remote.py +1 -1
  156. mlrun/lists.py +4 -3
  157. mlrun/model.py +117 -46
  158. mlrun/model_monitoring/__init__.py +4 -4
  159. mlrun/model_monitoring/api.py +61 -59
  160. mlrun/model_monitoring/applications/_application_steps.py +17 -17
  161. mlrun/model_monitoring/applications/base.py +165 -6
  162. mlrun/model_monitoring/applications/context.py +88 -37
  163. mlrun/model_monitoring/applications/evidently_base.py +0 -1
  164. mlrun/model_monitoring/applications/histogram_data_drift.py +43 -21
  165. mlrun/model_monitoring/applications/results.py +55 -3
  166. mlrun/model_monitoring/controller.py +207 -239
  167. mlrun/model_monitoring/db/__init__.py +0 -2
  168. mlrun/model_monitoring/db/_schedules.py +156 -0
  169. mlrun/model_monitoring/db/_stats.py +189 -0
  170. mlrun/model_monitoring/db/tsdb/base.py +78 -25
  171. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +61 -6
  172. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  173. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +255 -29
  174. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  175. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +78 -17
  176. mlrun/model_monitoring/helpers.py +152 -49
  177. mlrun/model_monitoring/stream_processing.py +99 -283
  178. mlrun/model_monitoring/tracking_policy.py +10 -3
  179. mlrun/model_monitoring/writer.py +48 -36
  180. mlrun/package/__init__.py +3 -6
  181. mlrun/package/context_handler.py +1 -1
  182. mlrun/package/packager.py +12 -9
  183. mlrun/package/packagers/__init__.py +0 -2
  184. mlrun/package/packagers/default_packager.py +14 -11
  185. mlrun/package/packagers/numpy_packagers.py +16 -7
  186. mlrun/package/packagers/pandas_packagers.py +18 -18
  187. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  188. mlrun/package/packagers_manager.py +31 -14
  189. mlrun/package/utils/__init__.py +0 -3
  190. mlrun/package/utils/_pickler.py +6 -6
  191. mlrun/platforms/__init__.py +47 -16
  192. mlrun/platforms/iguazio.py +4 -1
  193. mlrun/projects/operations.py +27 -27
  194. mlrun/projects/pipelines.py +71 -36
  195. mlrun/projects/project.py +865 -206
  196. mlrun/run.py +53 -10
  197. mlrun/runtimes/__init__.py +1 -3
  198. mlrun/runtimes/base.py +15 -11
  199. mlrun/runtimes/daskjob.py +9 -9
  200. mlrun/runtimes/generators.py +2 -1
  201. mlrun/runtimes/kubejob.py +4 -5
  202. mlrun/runtimes/mounts.py +572 -0
  203. mlrun/runtimes/mpijob/__init__.py +0 -2
  204. mlrun/runtimes/mpijob/abstract.py +7 -6
  205. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  206. mlrun/runtimes/nuclio/application/application.py +11 -11
  207. mlrun/runtimes/nuclio/function.py +19 -17
  208. mlrun/runtimes/nuclio/serving.py +18 -11
  209. mlrun/runtimes/pod.py +154 -45
  210. mlrun/runtimes/remotesparkjob.py +3 -2
  211. mlrun/runtimes/sparkjob/__init__.py +0 -2
  212. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  213. mlrun/runtimes/utils.py +6 -5
  214. mlrun/serving/merger.py +6 -4
  215. mlrun/serving/remote.py +18 -17
  216. mlrun/serving/routers.py +185 -172
  217. mlrun/serving/server.py +7 -1
  218. mlrun/serving/states.py +97 -78
  219. mlrun/serving/utils.py +13 -2
  220. mlrun/serving/v1_serving.py +3 -2
  221. mlrun/serving/v2_serving.py +74 -65
  222. mlrun/track/__init__.py +1 -1
  223. mlrun/track/tracker.py +2 -2
  224. mlrun/track/trackers/mlflow_tracker.py +6 -5
  225. mlrun/utils/async_http.py +1 -1
  226. mlrun/utils/clones.py +1 -1
  227. mlrun/utils/helpers.py +54 -16
  228. mlrun/utils/logger.py +106 -4
  229. mlrun/utils/notifications/notification/__init__.py +22 -19
  230. mlrun/utils/notifications/notification/base.py +33 -14
  231. mlrun/utils/notifications/notification/console.py +6 -6
  232. mlrun/utils/notifications/notification/git.py +11 -11
  233. mlrun/utils/notifications/notification/ipython.py +10 -9
  234. mlrun/utils/notifications/notification/mail.py +176 -0
  235. mlrun/utils/notifications/notification/slack.py +6 -6
  236. mlrun/utils/notifications/notification/webhook.py +6 -6
  237. mlrun/utils/notifications/notification_pusher.py +86 -44
  238. mlrun/utils/regex.py +3 -1
  239. mlrun/utils/version/version.json +2 -2
  240. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/METADATA +21 -16
  241. mlrun-1.8.0rc8.dist-info/RECORD +347 -0
  242. mlrun/model_monitoring/db/stores/__init__.py +0 -136
  243. mlrun/model_monitoring/db/stores/base/store.py +0 -213
  244. mlrun/model_monitoring/db/stores/sqldb/__init__.py +0 -13
  245. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -71
  246. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -190
  247. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -103
  248. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -40
  249. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -659
  250. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +0 -13
  251. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
  252. mlrun/model_monitoring/model_endpoint.py +0 -118
  253. mlrun-1.7.1rc10.dist-info/RECORD +0 -351
  254. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/LICENSE +0 -0
  255. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/WHEEL +0 -0
  256. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/entry_points.txt +0 -0
  257. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/top_level.txt +0 -0
@@ -1,213 +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
- import json
16
- import typing
17
- from abc import ABC, abstractmethod
18
-
19
- import mlrun.common.schemas.model_monitoring as mm_schemas
20
-
21
-
22
- class StoreBase(ABC):
23
- type: typing.ClassVar[str]
24
- """
25
- An abstract class to handle the store object in the DB target.
26
- """
27
-
28
- def __init__(self, project: str):
29
- """
30
- Initialize a new store target.
31
-
32
- :param project: The name of the project.
33
- """
34
- self.project = project
35
-
36
- @abstractmethod
37
- def write_model_endpoint(self, endpoint: dict[str, typing.Any]):
38
- """
39
- Create a new endpoint record in the DB table.
40
-
41
- :param endpoint: model endpoint dictionary that will be written into the DB.
42
- """
43
- pass
44
-
45
- @abstractmethod
46
- def update_model_endpoint(
47
- self, endpoint_id: str, attributes: dict[str, typing.Any]
48
- ):
49
- """
50
- Update a model endpoint record with a given attributes.
51
-
52
- :param endpoint_id: The unique id of the model endpoint.
53
- :param attributes: Dictionary of attributes that will be used for update the model endpoint. Note that the keys
54
- of the attributes dictionary should exist in the DB table.
55
-
56
- """
57
- pass
58
-
59
- @abstractmethod
60
- def delete_model_endpoint(self, endpoint_id: str):
61
- """
62
- Deletes the record of a given model endpoint id.
63
-
64
- :param endpoint_id: The unique id of the model endpoint.
65
- """
66
- pass
67
-
68
- @abstractmethod
69
- def delete_model_endpoints_resources(self):
70
- """
71
- Delete all model endpoints resources.
72
-
73
- """
74
- pass
75
-
76
- @abstractmethod
77
- def get_model_endpoint(
78
- self,
79
- endpoint_id: str,
80
- ) -> dict[str, typing.Any]:
81
- """
82
- Get a single model endpoint record.
83
-
84
- :param endpoint_id: The unique id of the model endpoint.
85
-
86
- :return: A model endpoint record as a dictionary.
87
- """
88
- pass
89
-
90
- @abstractmethod
91
- def list_model_endpoints(
92
- self,
93
- model: str = None,
94
- function: str = None,
95
- labels: list[str] = None,
96
- top_level: bool = None,
97
- uids: list = None,
98
- include_stats: bool = None,
99
- ) -> list[dict[str, typing.Any]]:
100
- """
101
- Returns a list of model endpoint dictionaries, supports filtering by model, function, labels or top level.
102
- By default, when no filters are applied, all available model endpoints for the given project will
103
- be listed.
104
-
105
- :param model: The name of the model to filter by.
106
- :param function: The name of the function to filter by.
107
- :param labels: A list of labels to filter by. Label filters work by either filtering a specific value
108
- of a label (i.e. list("key=value")) or by looking for the existence of a given
109
- key (i.e. "key").
110
- :param top_level: If True will return only routers and endpoint that are NOT children of any router.
111
- :param uids: List of model endpoint unique ids to include in the result.
112
- :param include_stats: If True, will include model endpoint statistics in the result.
113
-
114
- :return: A list of model endpoint dictionaries.
115
- """
116
- pass
117
-
118
- @abstractmethod
119
- def write_application_event(
120
- self,
121
- event: dict[str, typing.Any],
122
- kind: mm_schemas.WriterEventKind = mm_schemas.WriterEventKind.RESULT,
123
- ) -> None:
124
- """
125
- Write a new event in the target table.
126
-
127
- :param event: An event dictionary that represents the application result, should be corresponded to the
128
- schema defined in the :py:class:`~mlrun.common.schemas.model_monitoring.constants.WriterEvent`
129
- object.
130
- :param kind: The type of the event, can be either "result" or "metric".
131
- """
132
-
133
- @abstractmethod
134
- def get_last_analyzed(self, endpoint_id: str, application_name: str) -> int:
135
- """
136
- Get the last analyzed time for the provided model endpoint and application.
137
-
138
- :param endpoint_id: The unique id of the model endpoint.
139
- :param application_name: Registered application name.
140
-
141
- :return: Timestamp as a Unix time.
142
- :raise: MLRunNotFoundError if last analyzed value is not found.
143
- """
144
- pass
145
-
146
- @abstractmethod
147
- def update_last_analyzed(
148
- self,
149
- endpoint_id: str,
150
- application_name: str,
151
- last_analyzed: int,
152
- ):
153
- """
154
- Update the last analyzed time for the provided model endpoint and application.
155
-
156
- :param endpoint_id: The unique id of the model endpoint.
157
- :param application_name: Registered application name.
158
- :param last_analyzed: Timestamp as a Unix time that represents the last analyzed time of a certain
159
- application and model endpoint.
160
-
161
- """
162
- pass
163
-
164
- @abstractmethod
165
- def get_model_endpoint_metrics(
166
- self, endpoint_id: str, type: mm_schemas.ModelEndpointMonitoringMetricType
167
- ) -> list[mm_schemas.ModelEndpointMonitoringMetric]:
168
- """
169
- Get the model monitoring results and metrics of the requested model endpoint.
170
-
171
- :param: endpoint_id: The model endpoint identifier.
172
- :param: type: The type of the requested metrics ("result" or "metric").
173
-
174
- :return: A list of the available metrics.
175
- """
176
-
177
- @staticmethod
178
- def _validate_labels(
179
- endpoint_dict: dict,
180
- labels: list,
181
- ) -> bool:
182
- """Validate that the model endpoint dictionary has the provided labels. There are 2 possible cases:
183
- 1 - Labels were provided as a list of key-values pairs (e.g. ['label_1=value_1', 'label_2=value_2']): Validate
184
- that each pair exist in the endpoint dictionary.
185
- 2 - Labels were provided as a list of key labels (e.g. ['label_1', 'label_2']): Validate that each key exist in
186
- the endpoint labels dictionary.
187
-
188
- :param endpoint_dict: Dictionary of the model endpoint records.
189
- :param labels: List of dictionary of required labels.
190
-
191
- :return: True if the labels exist in the endpoint labels dictionary, otherwise False.
192
- """
193
-
194
- # Convert endpoint labels into dictionary
195
- endpoint_labels = json.loads(
196
- endpoint_dict.get(mm_schemas.EventFieldType.LABELS)
197
- )
198
-
199
- for label in labels:
200
- # Case 1 - label is a key=value pair
201
- if "=" in label:
202
- lbl, value = list(map(lambda x: x.strip(), label.split("=")))
203
- if lbl not in endpoint_labels or str(endpoint_labels[lbl]) != value:
204
- return False
205
- # Case 2 - label is just a key
206
- else:
207
- if label not in endpoint_labels:
208
- return False
209
-
210
- return True
211
-
212
- def create_tables(self):
213
- pass
@@ -1,13 +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.
@@ -1,71 +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
- from functools import partial
16
- from typing import Optional, TypeVar, Union
17
-
18
- from .mysql import ApplicationMetricsTable as MySQLApplicationMetricsTable
19
- from .mysql import ApplicationResultTable as MySQLApplicationResultTable
20
- from .mysql import ModelEndpointsTable as MySQLModelEndpointsTable
21
- from .mysql import MonitoringSchedulesTable as MySQLMonitoringSchedulesTable
22
- from .sqlite import ApplicationMetricsTable as SQLiteApplicationMetricsTable
23
- from .sqlite import ApplicationResultTable as SQLiteApplicationResultTable
24
- from .sqlite import ModelEndpointsTable as SQLiteModelEndpointsTable
25
- from .sqlite import MonitoringSchedulesTable as SQLiteMonitoringSchedulesTable
26
-
27
- MySQLTableType = TypeVar("MySQLTableType")
28
- SQLiteTableType = TypeVar("SQLiteTableType")
29
-
30
- _MYSQL_SCHEME = "mysql:"
31
-
32
-
33
- def _get_sql_table(
34
- *,
35
- mysql_table: MySQLTableType,
36
- sqlite_table: SQLiteTableType,
37
- connection_string: Optional[str] = None,
38
- ) -> Union[MySQLTableType, SQLiteTableType]:
39
- """
40
- Return a SQLAlchemy table for MySQL or SQLite according to the connection string.
41
- Note: this function should not be directly used in other modules.
42
- """
43
- if connection_string and _MYSQL_SCHEME in connection_string:
44
- return mysql_table
45
- return sqlite_table
46
-
47
-
48
- _get_model_endpoints_table = partial(
49
- _get_sql_table,
50
- mysql_table=MySQLModelEndpointsTable,
51
- sqlite_table=SQLiteModelEndpointsTable,
52
- )
53
-
54
-
55
- _get_application_result_table = partial(
56
- _get_sql_table,
57
- mysql_table=MySQLApplicationResultTable,
58
- sqlite_table=SQLiteApplicationResultTable,
59
- )
60
-
61
- _get_application_metrics_table = partial(
62
- _get_sql_table,
63
- mysql_table=MySQLApplicationMetricsTable,
64
- sqlite_table=SQLiteApplicationMetricsTable,
65
- )
66
-
67
- _get_monitoring_schedules_table = partial(
68
- _get_sql_table,
69
- mysql_table=MySQLMonitoringSchedulesTable,
70
- sqlite_table=SQLiteMonitoringSchedulesTable,
71
- )
@@ -1,190 +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
- from sqlalchemy import (
16
- DATETIME,
17
- TIMESTAMP, # TODO: migrate to DATETIME, see ML-6921
18
- Boolean,
19
- Column,
20
- Float,
21
- Integer,
22
- String,
23
- Text,
24
- )
25
-
26
- from mlrun.common.schemas.model_monitoring import (
27
- EventFieldType,
28
- FileTargetKind,
29
- MetricData,
30
- ResultData,
31
- SchedulingKeys,
32
- WriterEvent,
33
- )
34
- from mlrun.utils.db import BaseModel
35
-
36
-
37
- class ModelEndpointsBaseTable(BaseModel):
38
- __tablename__ = EventFieldType.MODEL_ENDPOINTS
39
-
40
- uid = Column(
41
- EventFieldType.UID,
42
- String(40),
43
- primary_key=True,
44
- )
45
- state = Column(EventFieldType.STATE, String(10))
46
- project = Column(EventFieldType.PROJECT, String(40))
47
- function_uri = Column(
48
- EventFieldType.FUNCTION_URI,
49
- String(255),
50
- )
51
- model = Column(EventFieldType.MODEL, String(255))
52
- model_class = Column(
53
- EventFieldType.MODEL_CLASS,
54
- String(255),
55
- )
56
- labels = Column(EventFieldType.LABELS, Text)
57
- model_uri = Column(EventFieldType.MODEL_URI, String(255))
58
- stream_path = Column(EventFieldType.STREAM_PATH, Text)
59
- algorithm = Column(
60
- EventFieldType.ALGORITHM,
61
- String(255),
62
- )
63
- active = Column(EventFieldType.ACTIVE, Boolean)
64
- monitoring_mode = Column(
65
- EventFieldType.MONITORING_MODE,
66
- String(10),
67
- )
68
- feature_stats = Column(EventFieldType.FEATURE_STATS, Text)
69
- current_stats = Column(EventFieldType.CURRENT_STATS, Text)
70
- feature_names = Column(EventFieldType.FEATURE_NAMES, Text)
71
- children = Column(EventFieldType.CHILDREN, Text)
72
- label_names = Column(EventFieldType.LABEL_NAMES, Text)
73
- endpoint_type = Column(
74
- EventFieldType.ENDPOINT_TYPE,
75
- String(10),
76
- )
77
- children_uids = Column(EventFieldType.CHILDREN_UIDS, Text)
78
- drift_measures = Column(EventFieldType.DRIFT_MEASURES, Text)
79
- drift_status = Column(
80
- EventFieldType.DRIFT_STATUS,
81
- String(40),
82
- )
83
- monitor_configuration = Column(
84
- EventFieldType.MONITOR_CONFIGURATION,
85
- Text,
86
- )
87
- monitoring_feature_set_uri = Column(
88
- EventFieldType.FEATURE_SET_URI,
89
- String(255),
90
- )
91
- error_count = Column(EventFieldType.ERROR_COUNT, Integer)
92
- metrics = Column(EventFieldType.METRICS, Text)
93
- first_request = Column(
94
- EventFieldType.FIRST_REQUEST,
95
- TIMESTAMP(timezone=True), # TODO: migrate to DATETIME, see ML-6921
96
- )
97
- last_request = Column(
98
- EventFieldType.LAST_REQUEST,
99
- TIMESTAMP(timezone=True), # TODO: migrate to DATETIME, see ML-6921
100
- )
101
-
102
-
103
- class ApplicationResultBaseTable(BaseModel):
104
- __tablename__ = FileTargetKind.APP_RESULTS
105
-
106
- uid = Column(EventFieldType.UID, String(120), primary_key=True)
107
-
108
- application_name = Column(
109
- WriterEvent.APPLICATION_NAME,
110
- String(40),
111
- nullable=True,
112
- )
113
-
114
- endpoint_id = Column(
115
- WriterEvent.ENDPOINT_ID,
116
- String(40),
117
- nullable=True,
118
- )
119
-
120
- result_name = Column(
121
- ResultData.RESULT_NAME,
122
- String(40),
123
- )
124
-
125
- start_infer_time = Column(
126
- WriterEvent.START_INFER_TIME,
127
- DATETIME(timezone=True),
128
- )
129
- end_infer_time = Column(
130
- WriterEvent.END_INFER_TIME,
131
- DATETIME(timezone=True),
132
- )
133
-
134
- result_status = Column(ResultData.RESULT_STATUS, String(10))
135
- result_kind = Column(ResultData.RESULT_KIND, String(40))
136
- result_value = Column(ResultData.RESULT_VALUE, Float)
137
- result_extra_data = Column(ResultData.RESULT_EXTRA_DATA, Text)
138
- current_stats = Column(ResultData.CURRENT_STATS, Text)
139
-
140
-
141
- class ApplicationMetricsBaseTable(BaseModel):
142
- __tablename__ = FileTargetKind.APP_METRICS
143
-
144
- uid = Column(EventFieldType.UID, String(120), primary_key=True)
145
- application_name = Column(
146
- WriterEvent.APPLICATION_NAME,
147
- String(40),
148
- nullable=True,
149
- )
150
- endpoint_id = Column(
151
- WriterEvent.ENDPOINT_ID,
152
- String(40),
153
- nullable=True,
154
- )
155
- start_infer_time = Column(
156
- WriterEvent.START_INFER_TIME,
157
- DATETIME(timezone=True),
158
- )
159
- end_infer_time = Column(
160
- WriterEvent.END_INFER_TIME,
161
- DATETIME(timezone=True),
162
- )
163
- metric_name = Column(
164
- MetricData.METRIC_NAME,
165
- String(40),
166
- )
167
- metric_value = Column(MetricData.METRIC_VALUE, Float)
168
-
169
-
170
- class MonitoringSchedulesBaseTable(BaseModel):
171
- __tablename__ = FileTargetKind.MONITORING_SCHEDULES
172
-
173
- uid = Column(SchedulingKeys.UID, String(32), primary_key=True)
174
-
175
- application_name = Column(
176
- SchedulingKeys.APPLICATION_NAME,
177
- String(40),
178
- nullable=False,
179
- )
180
-
181
- endpoint_id = Column(
182
- SchedulingKeys.ENDPOINT_ID,
183
- String(40),
184
- nullable=False,
185
- )
186
-
187
- last_analyzed = Column(
188
- SchedulingKeys.LAST_ANALYZED,
189
- Integer,
190
- )
@@ -1,103 +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
- import sqlalchemy.dialects.mysql
16
- from sqlalchemy import Column, ForeignKey, String
17
- from sqlalchemy.ext.declarative import declarative_base, declared_attr
18
-
19
- from mlrun.common.schemas.model_monitoring import (
20
- EventFieldType,
21
- ResultData,
22
- WriterEvent,
23
- )
24
-
25
- from .base import (
26
- ApplicationMetricsBaseTable,
27
- ApplicationResultBaseTable,
28
- ModelEndpointsBaseTable,
29
- MonitoringSchedulesBaseTable,
30
- )
31
-
32
- Base = declarative_base()
33
-
34
-
35
- class ModelEndpointsTable(Base, ModelEndpointsBaseTable):
36
- feature_stats = Column(
37
- EventFieldType.FEATURE_STATS, sqlalchemy.dialects.mysql.MEDIUMTEXT
38
- )
39
- current_stats = Column(
40
- EventFieldType.CURRENT_STATS, sqlalchemy.dialects.mysql.MEDIUMTEXT
41
- )
42
- metrics = Column(EventFieldType.METRICS, sqlalchemy.dialects.mysql.MEDIUMTEXT)
43
- first_request = Column(
44
- EventFieldType.FIRST_REQUEST,
45
- # TODO: migrate to DATETIME, see ML-6921
46
- sqlalchemy.dialects.mysql.TIMESTAMP(fsp=3, timezone=True),
47
- )
48
- last_request = Column(
49
- EventFieldType.LAST_REQUEST,
50
- # TODO: migrate to DATETIME, see ML-6921
51
- sqlalchemy.dialects.mysql.TIMESTAMP(fsp=3, timezone=True),
52
- )
53
-
54
-
55
- class _ApplicationResultOrMetric:
56
- """
57
- This class sets common columns of `ApplicationResultTable` and `ApplicationMetricsTable`
58
- to the correct values in MySQL.
59
- Note: This class must come before the base tables in the inheritance order to override
60
- the relevant columns.
61
- """
62
-
63
- start_infer_time = Column(
64
- WriterEvent.START_INFER_TIME,
65
- sqlalchemy.dialects.mysql.DATETIME(fsp=3, timezone=True),
66
- )
67
- end_infer_time = Column(
68
- WriterEvent.END_INFER_TIME,
69
- sqlalchemy.dialects.mysql.DATETIME(fsp=3, timezone=True),
70
- )
71
-
72
- @declared_attr
73
- def endpoint_id(self):
74
- return Column(
75
- String(40),
76
- ForeignKey(f"{EventFieldType.MODEL_ENDPOINTS}.{EventFieldType.UID}"),
77
- )
78
-
79
-
80
- class ApplicationResultTable(
81
- Base, _ApplicationResultOrMetric, ApplicationResultBaseTable
82
- ):
83
- result_extra_data = Column(
84
- ResultData.RESULT_EXTRA_DATA, sqlalchemy.dialects.mysql.MEDIUMTEXT
85
- )
86
- current_stats = Column(
87
- ResultData.CURRENT_STATS, sqlalchemy.dialects.mysql.MEDIUMTEXT
88
- )
89
-
90
-
91
- class ApplicationMetricsTable(
92
- Base, _ApplicationResultOrMetric, ApplicationMetricsBaseTable
93
- ):
94
- pass
95
-
96
-
97
- class MonitoringSchedulesTable(Base, MonitoringSchedulesBaseTable):
98
- @declared_attr
99
- def endpoint_id(self):
100
- return Column(
101
- String(40),
102
- ForeignKey(f"{EventFieldType.MODEL_ENDPOINTS}.{EventFieldType.UID}"),
103
- )
@@ -1,40 +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
- from sqlalchemy.ext.declarative import declarative_base
16
-
17
- from .base import (
18
- ApplicationMetricsBaseTable,
19
- ApplicationResultBaseTable,
20
- ModelEndpointsBaseTable,
21
- MonitoringSchedulesBaseTable,
22
- )
23
-
24
- Base = declarative_base()
25
-
26
-
27
- class ModelEndpointsTable(Base, ModelEndpointsBaseTable):
28
- pass
29
-
30
-
31
- class ApplicationResultTable(Base, ApplicationResultBaseTable):
32
- pass
33
-
34
-
35
- class ApplicationMetricsTable(Base, ApplicationMetricsBaseTable):
36
- pass
37
-
38
-
39
- class MonitoringSchedulesTable(Base, MonitoringSchedulesBaseTable):
40
- pass