mlrun 1.7.1rc4__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.
- mlrun/__init__.py +23 -21
- mlrun/__main__.py +3 -3
- mlrun/alerts/alert.py +148 -14
- mlrun/artifacts/__init__.py +1 -2
- mlrun/artifacts/base.py +46 -12
- mlrun/artifacts/dataset.py +16 -16
- mlrun/artifacts/document.py +334 -0
- mlrun/artifacts/manager.py +15 -13
- mlrun/artifacts/model.py +66 -53
- mlrun/common/constants.py +7 -0
- mlrun/common/formatters/__init__.py +1 -0
- mlrun/common/formatters/feature_set.py +1 -0
- mlrun/common/formatters/function.py +1 -0
- mlrun/{model_monitoring/db/stores/base/__init__.py → common/formatters/model_endpoint.py} +16 -1
- 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 +1 -29
- mlrun/common/runtimes/constants.py +1 -2
- mlrun/common/schemas/__init__.py +6 -2
- mlrun/common/schemas/alert.py +111 -19
- mlrun/common/schemas/api_gateway.py +3 -3
- mlrun/common/schemas/artifact.py +11 -7
- mlrun/common/schemas/auth.py +6 -4
- mlrun/common/schemas/background_task.py +7 -7
- mlrun/common/schemas/client_spec.py +2 -3
- 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 +2 -1
- mlrun/common/schemas/model_monitoring/constants.py +66 -14
- mlrun/common/schemas/model_monitoring/grafana.py +1 -1
- mlrun/common/schemas/model_monitoring/model_endpoints.py +91 -147
- 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 +137 -0
- mlrun/common/schemas/pipeline.py +2 -2
- mlrun/common/schemas/project.py +25 -17
- mlrun/common/schemas/runs.py +2 -2
- mlrun/common/schemas/runtime_resource.py +5 -5
- mlrun/common/schemas/schedule.py +1 -1
- mlrun/common/schemas/secret.py +1 -1
- mlrun/common/schemas/tag.py +3 -3
- mlrun/common/schemas/workflow.py +5 -5
- mlrun/config.py +67 -10
- mlrun/data_types/__init__.py +0 -2
- mlrun/data_types/infer.py +3 -1
- mlrun/data_types/spark.py +2 -1
- mlrun/datastore/__init__.py +0 -2
- mlrun/datastore/alibaba_oss.py +4 -1
- mlrun/datastore/azure_blob.py +4 -1
- mlrun/datastore/base.py +12 -4
- mlrun/datastore/datastore.py +9 -3
- mlrun/datastore/datastore_profile.py +79 -20
- 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 +4 -1
- mlrun/datastore/sources.py +52 -51
- mlrun/datastore/store_resources.py +0 -2
- mlrun/datastore/targets.py +21 -21
- mlrun/datastore/utils.py +2 -2
- mlrun/datastore/v3io.py +4 -1
- mlrun/datastore/vectorstore.py +194 -0
- mlrun/datastore/wasbfs/fs.py +13 -12
- mlrun/db/base.py +208 -82
- mlrun/db/factory.py +0 -3
- mlrun/db/httpdb.py +1237 -386
- mlrun/db/nopdb.py +201 -74
- mlrun/errors.py +2 -2
- mlrun/execution.py +136 -50
- mlrun/feature_store/__init__.py +0 -2
- mlrun/feature_store/api.py +41 -40
- mlrun/feature_store/common.py +9 -9
- mlrun/feature_store/feature_set.py +20 -18
- mlrun/feature_store/feature_vector.py +27 -24
- mlrun/feature_store/retrieval/base.py +14 -9
- mlrun/feature_store/retrieval/job.py +2 -1
- mlrun/feature_store/steps.py +2 -2
- 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 +29 -27
- 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/launcher/base.py +3 -4
- mlrun/launcher/local.py +1 -1
- mlrun/launcher/remote.py +1 -1
- mlrun/lists.py +4 -3
- mlrun/model.py +117 -46
- mlrun/model_monitoring/__init__.py +4 -4
- mlrun/model_monitoring/api.py +61 -59
- mlrun/model_monitoring/applications/_application_steps.py +17 -17
- mlrun/model_monitoring/applications/base.py +165 -6
- mlrun/model_monitoring/applications/context.py +88 -37
- mlrun/model_monitoring/applications/evidently_base.py +1 -2
- mlrun/model_monitoring/applications/histogram_data_drift.py +43 -21
- mlrun/model_monitoring/applications/results.py +55 -3
- mlrun/model_monitoring/controller.py +207 -239
- mlrun/model_monitoring/db/__init__.py +0 -2
- mlrun/model_monitoring/db/_schedules.py +156 -0
- mlrun/model_monitoring/db/_stats.py +189 -0
- mlrun/model_monitoring/db/tsdb/base.py +78 -25
- mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +90 -16
- mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +279 -59
- mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
- mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +78 -17
- mlrun/model_monitoring/helpers.py +152 -49
- mlrun/model_monitoring/stream_processing.py +99 -283
- mlrun/model_monitoring/tracking_policy.py +10 -3
- mlrun/model_monitoring/writer.py +48 -36
- mlrun/package/__init__.py +3 -6
- mlrun/package/context_handler.py +1 -1
- 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 +31 -14
- 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 +27 -27
- mlrun/projects/pipelines.py +75 -38
- mlrun/projects/project.py +865 -206
- mlrun/run.py +53 -10
- mlrun/runtimes/__init__.py +1 -3
- mlrun/runtimes/base.py +15 -11
- mlrun/runtimes/daskjob.py +9 -9
- mlrun/runtimes/generators.py +2 -1
- mlrun/runtimes/kubejob.py +4 -5
- mlrun/runtimes/mounts.py +572 -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 -11
- mlrun/runtimes/nuclio/function.py +19 -17
- mlrun/runtimes/nuclio/serving.py +18 -11
- mlrun/runtimes/pod.py +154 -45
- mlrun/runtimes/remotesparkjob.py +3 -2
- mlrun/runtimes/sparkjob/__init__.py +0 -2
- mlrun/runtimes/sparkjob/spark3job.py +21 -11
- mlrun/runtimes/utils.py +6 -5
- mlrun/serving/merger.py +6 -4
- mlrun/serving/remote.py +18 -17
- mlrun/serving/routers.py +185 -172
- mlrun/serving/server.py +7 -1
- mlrun/serving/states.py +97 -78
- mlrun/serving/utils.py +13 -2
- mlrun/serving/v1_serving.py +3 -2
- mlrun/serving/v2_serving.py +74 -65
- 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 +1 -1
- mlrun/utils/clones.py +1 -1
- mlrun/utils/helpers.py +66 -18
- mlrun/utils/logger.py +106 -4
- mlrun/utils/notifications/notification/__init__.py +22 -19
- mlrun/utils/notifications/notification/base.py +33 -14
- 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 +6 -6
- mlrun/utils/notifications/notification/webhook.py +6 -6
- mlrun/utils/notifications/notification_pusher.py +86 -44
- mlrun/utils/regex.py +3 -1
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.7.1rc4.dist-info → mlrun-1.8.0rc8.dist-info}/METADATA +191 -186
- mlrun-1.8.0rc8.dist-info/RECORD +347 -0
- {mlrun-1.7.1rc4.dist-info → mlrun-1.8.0rc8.dist-info}/WHEEL +1 -1
- 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/__init__.py +0 -13
- 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/__init__.py +0 -13
- mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
- mlrun/model_monitoring/model_endpoint.py +0 -118
- mlrun-1.7.1rc4.dist-info/RECORD +0 -351
- {mlrun-1.7.1rc4.dist-info → mlrun-1.8.0rc8.dist-info}/LICENSE +0 -0
- {mlrun-1.7.1rc4.dist-info → mlrun-1.8.0rc8.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.1rc4.dist-info → mlrun-1.8.0rc8.dist-info}/top_level.txt +0 -0
|
@@ -26,7 +26,7 @@ _MODEL_MONITORING_DATABASE = "mlrun_model_monitoring"
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class _TDEngineColumnType:
|
|
29
|
-
def __init__(self, data_type: str, length: int = None):
|
|
29
|
+
def __init__(self, data_type: str, length: Optional[int] = None):
|
|
30
30
|
self.data_type = data_type
|
|
31
31
|
self.length = length
|
|
32
32
|
|
|
@@ -46,7 +46,7 @@ class _TDEngineColumn(mlrun.common.types.StrEnum):
|
|
|
46
46
|
INT = _TDEngineColumnType("INT")
|
|
47
47
|
BINARY_40 = _TDEngineColumnType("BINARY", 40)
|
|
48
48
|
BINARY_64 = _TDEngineColumnType("BINARY", 64)
|
|
49
|
-
|
|
49
|
+
BINARY_1000 = _TDEngineColumnType("BINARY", 1000)
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def values_to_column(values, column_type):
|
|
@@ -61,7 +61,7 @@ def values_to_column(values, column_type):
|
|
|
61
61
|
return taosws.binary_to_column(values)
|
|
62
62
|
if column_type == _TDEngineColumn.BINARY_64:
|
|
63
63
|
return taosws.binary_to_column(values)
|
|
64
|
-
if column_type == _TDEngineColumn.
|
|
64
|
+
if column_type == _TDEngineColumn.BINARY_1000:
|
|
65
65
|
return taosws.binary_to_column(values)
|
|
66
66
|
|
|
67
67
|
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
@@ -82,9 +82,10 @@ class TDEngineSchema:
|
|
|
82
82
|
super_table: str,
|
|
83
83
|
columns: dict[str, _TDEngineColumn],
|
|
84
84
|
tags: dict[str, str],
|
|
85
|
+
project: str,
|
|
85
86
|
database: Optional[str] = None,
|
|
86
87
|
):
|
|
87
|
-
self.super_table = super_table
|
|
88
|
+
self.super_table = f"{super_table}_{project.replace('-', '_')}"
|
|
88
89
|
self.columns = columns
|
|
89
90
|
self.tags = tags
|
|
90
91
|
self.database = database or _MODEL_MONITORING_DATABASE
|
|
@@ -148,6 +149,9 @@ class TDEngineSchema:
|
|
|
148
149
|
) -> str:
|
|
149
150
|
return f"DROP TABLE if EXISTS {self.database}.{subtable};"
|
|
150
151
|
|
|
152
|
+
def drop_supertable_query(self) -> str:
|
|
153
|
+
return f"DROP STABLE if EXISTS {self.database}.{self.super_table};"
|
|
154
|
+
|
|
151
155
|
def _get_subtables_query(
|
|
152
156
|
self,
|
|
153
157
|
values: dict[str, Union[str, int, float, datetime.datetime]],
|
|
@@ -166,7 +170,7 @@ class TDEngineSchema:
|
|
|
166
170
|
table: str,
|
|
167
171
|
start: datetime.datetime,
|
|
168
172
|
end: datetime.datetime,
|
|
169
|
-
columns_to_filter: list[str] = None,
|
|
173
|
+
columns_to_filter: Optional[list[str]] = None,
|
|
170
174
|
filter_query: Optional[str] = None,
|
|
171
175
|
interval: Optional[str] = None,
|
|
172
176
|
limit: int = 0,
|
|
@@ -174,6 +178,10 @@ class TDEngineSchema:
|
|
|
174
178
|
sliding_window_step: Optional[str] = None,
|
|
175
179
|
timestamp_column: str = "time",
|
|
176
180
|
database: str = _MODEL_MONITORING_DATABASE,
|
|
181
|
+
group_by: Optional[Union[list[str], str]] = None,
|
|
182
|
+
preform_agg_funcs_columns: Optional[list[str]] = None,
|
|
183
|
+
order_by: Optional[str] = None,
|
|
184
|
+
desc: Optional[bool] = None,
|
|
177
185
|
) -> str:
|
|
178
186
|
if agg_funcs and not columns_to_filter:
|
|
179
187
|
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
@@ -190,15 +198,37 @@ class TDEngineSchema:
|
|
|
190
198
|
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
191
199
|
"`interval` must be provided when using sliding window"
|
|
192
200
|
)
|
|
201
|
+
if group_by and not agg_funcs:
|
|
202
|
+
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
203
|
+
"aggregate functions must be provided when using group by"
|
|
204
|
+
)
|
|
205
|
+
if desc and not order_by:
|
|
206
|
+
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
207
|
+
"`order_by` must be provided when using descending"
|
|
208
|
+
)
|
|
193
209
|
|
|
194
210
|
with StringIO() as query:
|
|
195
211
|
query.write("SELECT ")
|
|
196
212
|
if interval:
|
|
197
213
|
query.write("_wstart, _wend, ")
|
|
198
214
|
if agg_funcs:
|
|
215
|
+
preform_agg_funcs_columns = (
|
|
216
|
+
columns_to_filter
|
|
217
|
+
if preform_agg_funcs_columns is None
|
|
218
|
+
else preform_agg_funcs_columns
|
|
219
|
+
)
|
|
199
220
|
query.write(
|
|
200
221
|
", ".join(
|
|
201
|
-
[
|
|
222
|
+
[
|
|
223
|
+
f"{a}({col})"
|
|
224
|
+
if col.upper()
|
|
225
|
+
in map(
|
|
226
|
+
str.upper, preform_agg_funcs_columns
|
|
227
|
+
) # Case-insensitive check
|
|
228
|
+
else f"{col}"
|
|
229
|
+
for a in agg_funcs
|
|
230
|
+
for col in columns_to_filter
|
|
231
|
+
]
|
|
202
232
|
)
|
|
203
233
|
)
|
|
204
234
|
elif columns_to_filter:
|
|
@@ -215,6 +245,13 @@ class TDEngineSchema:
|
|
|
215
245
|
query.write(f"{timestamp_column} >= '{start}' AND ")
|
|
216
246
|
if end:
|
|
217
247
|
query.write(f"{timestamp_column} <= '{end}'")
|
|
248
|
+
if group_by:
|
|
249
|
+
if isinstance(group_by, list):
|
|
250
|
+
group_by = ", ".join(group_by)
|
|
251
|
+
query.write(f" GROUP BY {group_by}")
|
|
252
|
+
if order_by:
|
|
253
|
+
desc = " DESC" if desc else ""
|
|
254
|
+
query.write(f" ORDER BY {order_by}{desc}")
|
|
218
255
|
if interval:
|
|
219
256
|
query.write(f" INTERVAL({interval})")
|
|
220
257
|
if sliding_window_step:
|
|
@@ -227,27 +264,33 @@ class TDEngineSchema:
|
|
|
227
264
|
|
|
228
265
|
@dataclass
|
|
229
266
|
class AppResultTable(TDEngineSchema):
|
|
230
|
-
def __init__(self, database: Optional[str] = None):
|
|
267
|
+
def __init__(self, project: str, database: Optional[str] = None):
|
|
231
268
|
super_table = mm_schemas.TDEngineSuperTables.APP_RESULTS
|
|
232
269
|
columns = {
|
|
233
270
|
mm_schemas.WriterEvent.END_INFER_TIME: _TDEngineColumn.TIMESTAMP,
|
|
234
271
|
mm_schemas.WriterEvent.START_INFER_TIME: _TDEngineColumn.TIMESTAMP,
|
|
235
272
|
mm_schemas.ResultData.RESULT_VALUE: _TDEngineColumn.FLOAT,
|
|
236
273
|
mm_schemas.ResultData.RESULT_STATUS: _TDEngineColumn.INT,
|
|
274
|
+
mm_schemas.ResultData.RESULT_EXTRA_DATA: _TDEngineColumn.BINARY_1000,
|
|
237
275
|
}
|
|
238
276
|
tags = {
|
|
239
|
-
mm_schemas.EventFieldType.PROJECT: _TDEngineColumn.BINARY_64,
|
|
240
277
|
mm_schemas.WriterEvent.ENDPOINT_ID: _TDEngineColumn.BINARY_64,
|
|
241
278
|
mm_schemas.WriterEvent.APPLICATION_NAME: _TDEngineColumn.BINARY_64,
|
|
242
279
|
mm_schemas.ResultData.RESULT_NAME: _TDEngineColumn.BINARY_64,
|
|
243
280
|
mm_schemas.ResultData.RESULT_KIND: _TDEngineColumn.INT,
|
|
244
281
|
}
|
|
245
|
-
super().__init__(
|
|
282
|
+
super().__init__(
|
|
283
|
+
super_table=super_table,
|
|
284
|
+
columns=columns,
|
|
285
|
+
tags=tags,
|
|
286
|
+
database=database,
|
|
287
|
+
project=project,
|
|
288
|
+
)
|
|
246
289
|
|
|
247
290
|
|
|
248
291
|
@dataclass
|
|
249
292
|
class Metrics(TDEngineSchema):
|
|
250
|
-
def __init__(self, database: Optional[str] = None):
|
|
293
|
+
def __init__(self, project: str, database: Optional[str] = None):
|
|
251
294
|
super_table = mm_schemas.TDEngineSuperTables.METRICS
|
|
252
295
|
columns = {
|
|
253
296
|
mm_schemas.WriterEvent.END_INFER_TIME: _TDEngineColumn.TIMESTAMP,
|
|
@@ -255,25 +298,56 @@ class Metrics(TDEngineSchema):
|
|
|
255
298
|
mm_schemas.MetricData.METRIC_VALUE: _TDEngineColumn.FLOAT,
|
|
256
299
|
}
|
|
257
300
|
tags = {
|
|
258
|
-
mm_schemas.EventFieldType.PROJECT: _TDEngineColumn.BINARY_64,
|
|
259
301
|
mm_schemas.WriterEvent.ENDPOINT_ID: _TDEngineColumn.BINARY_64,
|
|
260
302
|
mm_schemas.WriterEvent.APPLICATION_NAME: _TDEngineColumn.BINARY_64,
|
|
261
303
|
mm_schemas.MetricData.METRIC_NAME: _TDEngineColumn.BINARY_64,
|
|
262
304
|
}
|
|
263
|
-
super().__init__(
|
|
305
|
+
super().__init__(
|
|
306
|
+
super_table=super_table,
|
|
307
|
+
columns=columns,
|
|
308
|
+
tags=tags,
|
|
309
|
+
database=database,
|
|
310
|
+
project=project,
|
|
311
|
+
)
|
|
264
312
|
|
|
265
313
|
|
|
266
314
|
@dataclass
|
|
267
315
|
class Predictions(TDEngineSchema):
|
|
268
|
-
def __init__(self, database: Optional[str] = None):
|
|
316
|
+
def __init__(self, project: str, database: Optional[str] = None):
|
|
269
317
|
super_table = mm_schemas.TDEngineSuperTables.PREDICTIONS
|
|
270
318
|
columns = {
|
|
271
319
|
mm_schemas.EventFieldType.TIME: _TDEngineColumn.TIMESTAMP,
|
|
272
320
|
mm_schemas.EventFieldType.LATENCY: _TDEngineColumn.FLOAT,
|
|
273
|
-
mm_schemas.EventKeyMetrics.CUSTOM_METRICS: _TDEngineColumn.
|
|
321
|
+
mm_schemas.EventKeyMetrics.CUSTOM_METRICS: _TDEngineColumn.BINARY_1000,
|
|
274
322
|
}
|
|
275
323
|
tags = {
|
|
276
|
-
mm_schemas.EventFieldType.PROJECT: _TDEngineColumn.BINARY_64,
|
|
277
324
|
mm_schemas.WriterEvent.ENDPOINT_ID: _TDEngineColumn.BINARY_64,
|
|
278
325
|
}
|
|
279
|
-
super().__init__(
|
|
326
|
+
super().__init__(
|
|
327
|
+
super_table=super_table,
|
|
328
|
+
columns=columns,
|
|
329
|
+
tags=tags,
|
|
330
|
+
database=database,
|
|
331
|
+
project=project,
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
@dataclass
|
|
336
|
+
class Errors(TDEngineSchema):
|
|
337
|
+
def __init__(self, project: str, database: Optional[str] = None):
|
|
338
|
+
super_table = mm_schemas.TDEngineSuperTables.ERRORS
|
|
339
|
+
columns = {
|
|
340
|
+
mm_schemas.EventFieldType.TIME: _TDEngineColumn.TIMESTAMP,
|
|
341
|
+
mm_schemas.EventFieldType.MODEL_ERROR: _TDEngineColumn.BINARY_1000,
|
|
342
|
+
}
|
|
343
|
+
tags = {
|
|
344
|
+
mm_schemas.WriterEvent.ENDPOINT_ID: _TDEngineColumn.BINARY_64,
|
|
345
|
+
mm_schemas.EventFieldType.ERROR_TYPE: _TDEngineColumn.BINARY_64,
|
|
346
|
+
}
|
|
347
|
+
super().__init__(
|
|
348
|
+
super_table=super_table,
|
|
349
|
+
columns=columns,
|
|
350
|
+
tags=tags,
|
|
351
|
+
database=database,
|
|
352
|
+
project=project,
|
|
353
|
+
)
|
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import json
|
|
16
|
+
from datetime import datetime
|
|
16
17
|
|
|
17
18
|
import mlrun.feature_store.steps
|
|
18
19
|
from mlrun.common.schemas.model_monitoring import (
|
|
19
20
|
EventFieldType,
|
|
20
21
|
EventKeyMetrics,
|
|
21
22
|
)
|
|
23
|
+
from mlrun.utils import logger
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
class ProcessBeforeTDEngine(mlrun.feature_store.steps.MapClass):
|
|
@@ -40,3 +42,34 @@ class ProcessBeforeTDEngine(mlrun.feature_store.steps.MapClass):
|
|
|
40
42
|
event[EventFieldType.TABLE_COLUMN] = "_" + event.get(EventFieldType.ENDPOINT_ID)
|
|
41
43
|
|
|
42
44
|
return event
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ErrorExtractor(mlrun.feature_store.steps.MapClass):
|
|
48
|
+
def __init__(self, **kwargs):
|
|
49
|
+
"""
|
|
50
|
+
Prepare the event for insertion into the TDEngine error table
|
|
51
|
+
"""
|
|
52
|
+
super().__init__(**kwargs)
|
|
53
|
+
|
|
54
|
+
def do(self, event):
|
|
55
|
+
error = str(event.get("error"))
|
|
56
|
+
if len(error) > 1000:
|
|
57
|
+
error = error[-1000:]
|
|
58
|
+
logger.warning(
|
|
59
|
+
f"Error message exceeds 1000 chars: The error message writen to TSDB will be it last "
|
|
60
|
+
f"1000 chars, Error: {error}",
|
|
61
|
+
event=event,
|
|
62
|
+
)
|
|
63
|
+
timestamp = datetime.fromisoformat(event.get("when"))
|
|
64
|
+
endpoint_id = event[EventFieldType.ENDPOINT_ID]
|
|
65
|
+
event = {
|
|
66
|
+
EventFieldType.MODEL_ERROR: error,
|
|
67
|
+
EventFieldType.ERROR_TYPE: EventFieldType.INFER_ERROR,
|
|
68
|
+
EventFieldType.ENDPOINT_ID: endpoint_id,
|
|
69
|
+
EventFieldType.TIME: timestamp,
|
|
70
|
+
EventFieldType.PROJECT: event[EventFieldType.FUNCTION_URI].split("/")[0],
|
|
71
|
+
EventFieldType.TABLE_COLUMN: "_err_"
|
|
72
|
+
+ event.get(EventFieldType.ENDPOINT_ID),
|
|
73
|
+
}
|
|
74
|
+
logger.info("Write error to errors TSDB table", event=event)
|
|
75
|
+
return event
|