mlrun 1.7.1rc10__py3-none-any.whl → 1.8.0rc11__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 +2 -3
- mlrun/artifacts/base.py +55 -12
- mlrun/artifacts/dataset.py +16 -16
- mlrun/artifacts/document.py +378 -0
- mlrun/artifacts/manager.py +26 -17
- mlrun/artifacts/model.py +66 -53
- mlrun/common/constants.py +8 -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 +67 -14
- mlrun/common/schemas/model_monitoring/grafana.py +1 -1
- mlrun/common/schemas/model_monitoring/model_endpoints.py +92 -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 +68 -10
- mlrun/data_types/__init__.py +0 -2
- mlrun/data_types/data_types.py +1 -0
- mlrun/data_types/infer.py +3 -1
- mlrun/data_types/spark.py +5 -3
- mlrun/data_types/to_pandas.py +11 -2
- mlrun/datastore/__init__.py +2 -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 +7 -4
- mlrun/datastore/targets.py +23 -22
- mlrun/datastore/utils.py +2 -2
- mlrun/datastore/v3io.py +4 -1
- mlrun/datastore/vectorstore.py +229 -0
- mlrun/datastore/wasbfs/fs.py +13 -12
- mlrun/db/base.py +213 -83
- mlrun/db/factory.py +0 -3
- mlrun/db/httpdb.py +1265 -387
- mlrun/db/nopdb.py +205 -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 +72 -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 +0 -1
- 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 +61 -6
- mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +255 -29
- 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 +151 -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 +71 -36
- mlrun/projects/project.py +890 -220
- 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 -13
- 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 +105 -72
- 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 +63 -19
- 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 +11 -2
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/METADATA +29 -24
- mlrun-1.8.0rc11.dist-info/RECORD +347 -0
- 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.1rc10.dist-info/RECORD +0 -351
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/LICENSE +0 -0
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/WHEEL +0 -0
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/top_level.txt +0 -0
mlrun/model_monitoring/writer.py
CHANGED
|
@@ -13,23 +13,29 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import json
|
|
16
|
-
from
|
|
16
|
+
from datetime import datetime, timezone
|
|
17
|
+
from typing import Any, Callable, NewType, Optional
|
|
17
18
|
|
|
18
19
|
import mlrun.common.model_monitoring
|
|
19
20
|
import mlrun.common.schemas
|
|
20
21
|
import mlrun.common.schemas.alert as alert_objects
|
|
21
22
|
import mlrun.model_monitoring
|
|
22
23
|
from mlrun.common.schemas.model_monitoring.constants import (
|
|
23
|
-
EventFieldType,
|
|
24
24
|
HistogramDataDriftApplicationConstants,
|
|
25
25
|
MetricData,
|
|
26
26
|
ResultData,
|
|
27
27
|
ResultKindApp,
|
|
28
28
|
ResultStatusApp,
|
|
29
|
+
StatsData,
|
|
30
|
+
StatsKind,
|
|
29
31
|
WriterEvent,
|
|
30
32
|
WriterEventKind,
|
|
31
33
|
)
|
|
32
34
|
from mlrun.common.schemas.notification import NotificationKind, NotificationSeverity
|
|
35
|
+
from mlrun.model_monitoring.db._stats import (
|
|
36
|
+
ModelMonitoringCurrentStatsFile,
|
|
37
|
+
ModelMonitoringDriftMeasuresFile,
|
|
38
|
+
)
|
|
33
39
|
from mlrun.model_monitoring.helpers import get_result_instance_fqn
|
|
34
40
|
from mlrun.serving.utils import StepToDict
|
|
35
41
|
from mlrun.utils import logger
|
|
@@ -105,7 +111,7 @@ class ModelMonitoringWriter(StepToDict):
|
|
|
105
111
|
def __init__(
|
|
106
112
|
self,
|
|
107
113
|
project: str,
|
|
108
|
-
secret_provider: Callable = None,
|
|
114
|
+
secret_provider: Optional[Callable] = None,
|
|
109
115
|
) -> None:
|
|
110
116
|
self.project = project
|
|
111
117
|
self.name = project # required for the deployment process
|
|
@@ -114,9 +120,6 @@ class ModelMonitoringWriter(StepToDict):
|
|
|
114
120
|
notification_types=[NotificationKind.slack]
|
|
115
121
|
)
|
|
116
122
|
|
|
117
|
-
self._app_result_store = mlrun.model_monitoring.get_store_object(
|
|
118
|
-
project=self.project, secret_provider=secret_provider
|
|
119
|
-
)
|
|
120
123
|
self._tsdb_connector = mlrun.model_monitoring.get_tsdb_connector(
|
|
121
124
|
project=self.project, secret_provider=secret_provider
|
|
122
125
|
)
|
|
@@ -190,6 +193,8 @@ class ModelMonitoringWriter(StepToDict):
|
|
|
190
193
|
expected_keys.extend(MetricData.list())
|
|
191
194
|
elif kind == WriterEventKind.RESULT:
|
|
192
195
|
expected_keys.extend(ResultData.list())
|
|
196
|
+
elif kind == WriterEventKind.STATS:
|
|
197
|
+
expected_keys.extend(StatsData.list())
|
|
193
198
|
else:
|
|
194
199
|
raise _WriterEventValueError(
|
|
195
200
|
f"Unknown event kind: {kind}, expected one of: {WriterEventKind.list()}"
|
|
@@ -198,16 +203,50 @@ class ModelMonitoringWriter(StepToDict):
|
|
|
198
203
|
if missing_keys:
|
|
199
204
|
raise _WriterEventValueError(
|
|
200
205
|
f"The received event misses some keys compared to the expected "
|
|
201
|
-
f"monitoring application event schema: {missing_keys}"
|
|
206
|
+
f"monitoring application event schema: {missing_keys} for event kind {kind}"
|
|
202
207
|
)
|
|
203
208
|
|
|
204
209
|
return result_event, kind
|
|
205
210
|
|
|
211
|
+
def write_stats(self, event: _AppResultEvent) -> None:
|
|
212
|
+
"""
|
|
213
|
+
Write to file the application stats event
|
|
214
|
+
:param event: application stats event
|
|
215
|
+
"""
|
|
216
|
+
endpoint_id = event[WriterEvent.ENDPOINT_ID]
|
|
217
|
+
logger.debug(
|
|
218
|
+
"Updating the model endpoint with stats",
|
|
219
|
+
endpoint_id=endpoint_id,
|
|
220
|
+
)
|
|
221
|
+
stat_kind = event.get(StatsData.STATS_NAME)
|
|
222
|
+
data, timestamp_str = event.get(StatsData.STATS), event.get(StatsData.TIMESTAMP)
|
|
223
|
+
timestamp = datetime.fromisoformat(timestamp_str).astimezone(tz=timezone.utc)
|
|
224
|
+
if stat_kind == StatsKind.CURRENT_STATS.value:
|
|
225
|
+
ModelMonitoringCurrentStatsFile(self.project, endpoint_id).write(
|
|
226
|
+
data, timestamp
|
|
227
|
+
)
|
|
228
|
+
elif stat_kind == StatsKind.DRIFT_MEASURES.value:
|
|
229
|
+
ModelMonitoringDriftMeasuresFile(self.project, endpoint_id).write(
|
|
230
|
+
data, timestamp
|
|
231
|
+
)
|
|
232
|
+
logger.info(
|
|
233
|
+
"Updating the model endpoint statistics",
|
|
234
|
+
endpoint_id=endpoint_id,
|
|
235
|
+
stats_kind=stat_kind,
|
|
236
|
+
)
|
|
237
|
+
|
|
206
238
|
def do(self, event: _RawEvent) -> None:
|
|
207
239
|
event, kind = self._reconstruct_event(event)
|
|
208
240
|
logger.info("Starting to write event", event=event)
|
|
241
|
+
if (
|
|
242
|
+
kind == WriterEventKind.STATS
|
|
243
|
+
and event[WriterEvent.APPLICATION_NAME]
|
|
244
|
+
== HistogramDataDriftApplicationConstants.NAME
|
|
245
|
+
):
|
|
246
|
+
self.write_stats(event)
|
|
247
|
+
logger.info("Model monitoring writer finished handling event")
|
|
248
|
+
return
|
|
209
249
|
self._tsdb_connector.write_application_event(event=event.copy(), kind=kind)
|
|
210
|
-
self._app_result_store.write_application_event(event=event.copy(), kind=kind)
|
|
211
250
|
|
|
212
251
|
logger.info("Completed event DB writes")
|
|
213
252
|
|
|
@@ -223,14 +262,9 @@ class ModelMonitoringWriter(StepToDict):
|
|
|
223
262
|
== ResultStatusApp.potential_detection.value
|
|
224
263
|
)
|
|
225
264
|
):
|
|
226
|
-
endpoint_id = event[WriterEvent.ENDPOINT_ID]
|
|
227
|
-
endpoint_record = self._endpoints_records.setdefault(
|
|
228
|
-
endpoint_id,
|
|
229
|
-
self._app_result_store.get_model_endpoint(endpoint_id=endpoint_id),
|
|
230
|
-
)
|
|
231
265
|
event_value = {
|
|
232
266
|
"app_name": event[WriterEvent.APPLICATION_NAME],
|
|
233
|
-
"model":
|
|
267
|
+
"model": event[WriterEvent.ENDPOINT_NAME],
|
|
234
268
|
"model_endpoint_id": event[WriterEvent.ENDPOINT_ID],
|
|
235
269
|
"result_name": event[ResultData.RESULT_NAME],
|
|
236
270
|
"result_value": event[ResultData.RESULT_VALUE],
|
|
@@ -247,26 +281,4 @@ class ModelMonitoringWriter(StepToDict):
|
|
|
247
281
|
result_kind=event[ResultData.RESULT_KIND],
|
|
248
282
|
)
|
|
249
283
|
|
|
250
|
-
if (
|
|
251
|
-
kind == WriterEventKind.RESULT
|
|
252
|
-
and event[WriterEvent.APPLICATION_NAME]
|
|
253
|
-
== HistogramDataDriftApplicationConstants.NAME
|
|
254
|
-
and event[ResultData.RESULT_NAME]
|
|
255
|
-
== HistogramDataDriftApplicationConstants.GENERAL_RESULT_NAME
|
|
256
|
-
):
|
|
257
|
-
endpoint_id = event[WriterEvent.ENDPOINT_ID]
|
|
258
|
-
logger.info(
|
|
259
|
-
"Updating the model endpoint with metadata specific to the histogram "
|
|
260
|
-
"data drift app",
|
|
261
|
-
endpoint_id=endpoint_id,
|
|
262
|
-
)
|
|
263
|
-
attributes = json.loads(event[ResultData.RESULT_EXTRA_DATA])
|
|
264
|
-
attributes[EventFieldType.DRIFT_STATUS] = str(
|
|
265
|
-
attributes[EventFieldType.DRIFT_STATUS]
|
|
266
|
-
)
|
|
267
|
-
self._app_result_store.update_model_endpoint(
|
|
268
|
-
endpoint_id=endpoint_id,
|
|
269
|
-
attributes=attributes,
|
|
270
|
-
)
|
|
271
|
-
|
|
272
284
|
logger.info("Model monitoring writer finished handling event")
|
mlrun/package/__init__.py
CHANGED
|
@@ -11,14 +11,11 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
# flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
|
|
17
14
|
|
|
18
15
|
import functools
|
|
19
16
|
import inspect
|
|
20
17
|
from collections import OrderedDict
|
|
21
|
-
from typing import Callable, Union
|
|
18
|
+
from typing import Callable, Optional, Union
|
|
22
19
|
|
|
23
20
|
from ..config import config
|
|
24
21
|
from .context_handler import ContextHandler
|
|
@@ -40,8 +37,8 @@ from .utils import (
|
|
|
40
37
|
|
|
41
38
|
|
|
42
39
|
def handler(
|
|
43
|
-
labels: dict[str, str] = None,
|
|
44
|
-
outputs: list[Union[str, dict[str, str]]] = None,
|
|
40
|
+
labels: Optional[dict[str, str]] = None,
|
|
41
|
+
outputs: Optional[list[Union[str, dict[str, str]]]] = None,
|
|
45
42
|
inputs: Union[bool, dict[str, Union[str, type]]] = True,
|
|
46
43
|
):
|
|
47
44
|
"""
|
mlrun/package/context_handler.py
CHANGED
|
@@ -216,7 +216,7 @@ class ContextHandler:
|
|
|
216
216
|
)
|
|
217
217
|
# Link packages:
|
|
218
218
|
self._packagers_manager.link_packages(
|
|
219
|
-
|
|
219
|
+
additional_artifact_uris=self._context.artifact_uris,
|
|
220
220
|
additional_results=self._context.results,
|
|
221
221
|
)
|
|
222
222
|
# Log the packed results and artifacts:
|
mlrun/package/packager.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
#
|
|
15
15
|
from abc import ABC, abstractmethod
|
|
16
16
|
from pathlib import Path
|
|
17
|
-
from typing import Any, Union
|
|
17
|
+
from typing import Any, Optional, Union
|
|
18
18
|
|
|
19
19
|
from mlrun.artifacts import Artifact
|
|
20
20
|
from mlrun.datastore import DataItem
|
|
@@ -144,9 +144,9 @@ class Packager(ABC):
|
|
|
144
144
|
def pack(
|
|
145
145
|
self,
|
|
146
146
|
obj: Any,
|
|
147
|
-
key: str = None,
|
|
148
|
-
artifact_type: str = None,
|
|
149
|
-
configurations: dict = None,
|
|
147
|
+
key: Optional[str] = None,
|
|
148
|
+
artifact_type: Optional[str] = None,
|
|
149
|
+
configurations: Optional[dict] = None,
|
|
150
150
|
) -> Union[tuple[Artifact, dict], dict]:
|
|
151
151
|
"""
|
|
152
152
|
Pack an object as the given artifact type using the provided configurations.
|
|
@@ -165,8 +165,8 @@ class Packager(ABC):
|
|
|
165
165
|
def unpack(
|
|
166
166
|
self,
|
|
167
167
|
data_item: DataItem,
|
|
168
|
-
artifact_type: str = None,
|
|
169
|
-
instructions: dict = None,
|
|
168
|
+
artifact_type: Optional[str] = None,
|
|
169
|
+
instructions: Optional[dict] = None,
|
|
170
170
|
) -> Any:
|
|
171
171
|
"""
|
|
172
172
|
Unpack the data item's artifact by the provided type using the given instructions.
|
|
@@ -180,7 +180,10 @@ class Packager(ABC):
|
|
|
180
180
|
pass
|
|
181
181
|
|
|
182
182
|
def is_packable(
|
|
183
|
-
self,
|
|
183
|
+
self,
|
|
184
|
+
obj: Any,
|
|
185
|
+
artifact_type: Optional[str] = None,
|
|
186
|
+
configurations: Optional[dict] = None,
|
|
184
187
|
) -> bool:
|
|
185
188
|
"""
|
|
186
189
|
Check if this packager can pack an object of the provided type as the provided artifact type.
|
|
@@ -212,7 +215,7 @@ class Packager(ABC):
|
|
|
212
215
|
return True
|
|
213
216
|
|
|
214
217
|
def is_unpackable(
|
|
215
|
-
self, data_item: DataItem, type_hint: type, artifact_type: str = None
|
|
218
|
+
self, data_item: DataItem, type_hint: type, artifact_type: Optional[str] = None
|
|
216
219
|
) -> bool:
|
|
217
220
|
"""
|
|
218
221
|
Check if this packager can unpack an input according to the user-given type hint and the provided artifact type.
|
|
@@ -315,7 +318,7 @@ class Packager(ABC):
|
|
|
315
318
|
)
|
|
316
319
|
|
|
317
320
|
def get_data_item_local_path(
|
|
318
|
-
self, data_item: DataItem, add_to_future_clearing_path: bool = None
|
|
321
|
+
self, data_item: DataItem, add_to_future_clearing_path: Optional[bool] = None
|
|
319
322
|
) -> str:
|
|
320
323
|
"""
|
|
321
324
|
Get the local path to the item handled by the data item provided. The local path can be the same as the data
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
#
|
|
15
14
|
|
|
16
|
-
# flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
|
|
17
15
|
from .default_packager import DefaultPackager
|
|
18
16
|
from .numpy_packagers import NumPySupportedFormat
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import inspect
|
|
16
16
|
from abc import ABCMeta
|
|
17
17
|
from types import MethodType
|
|
18
|
-
from typing import Any, Union
|
|
18
|
+
from typing import Any, Optional, Union
|
|
19
19
|
|
|
20
20
|
import docstring_parser
|
|
21
21
|
|
|
@@ -323,9 +323,9 @@ class DefaultPackager(Packager, metaclass=_DefaultPackagerMeta):
|
|
|
323
323
|
def pack(
|
|
324
324
|
self,
|
|
325
325
|
obj: Any,
|
|
326
|
-
key: str = None,
|
|
327
|
-
artifact_type: str = None,
|
|
328
|
-
configurations: dict = None,
|
|
326
|
+
key: Optional[str] = None,
|
|
327
|
+
artifact_type: Optional[str] = None,
|
|
328
|
+
configurations: Optional[dict] = None,
|
|
329
329
|
) -> Union[tuple[Artifact, dict], dict]:
|
|
330
330
|
"""
|
|
331
331
|
Pack an object as the given artifact type using the provided configurations.
|
|
@@ -361,8 +361,8 @@ class DefaultPackager(Packager, metaclass=_DefaultPackagerMeta):
|
|
|
361
361
|
def unpack(
|
|
362
362
|
self,
|
|
363
363
|
data_item: DataItem,
|
|
364
|
-
artifact_type: str = None,
|
|
365
|
-
instructions: dict = None,
|
|
364
|
+
artifact_type: Optional[str] = None,
|
|
365
|
+
instructions: Optional[dict] = None,
|
|
366
366
|
) -> Any:
|
|
367
367
|
"""
|
|
368
368
|
Unpack the data item's artifact by the provided type using the given instructions.
|
|
@@ -399,7 +399,10 @@ class DefaultPackager(Packager, metaclass=_DefaultPackagerMeta):
|
|
|
399
399
|
return unpack_method(data_item, **instructions)
|
|
400
400
|
|
|
401
401
|
def is_packable(
|
|
402
|
-
self,
|
|
402
|
+
self,
|
|
403
|
+
obj: Any,
|
|
404
|
+
artifact_type: Optional[str] = None,
|
|
405
|
+
configurations: Optional[dict] = None,
|
|
403
406
|
) -> bool:
|
|
404
407
|
"""
|
|
405
408
|
Check if this packager can pack an object of the provided type as the provided artifact type.
|
|
@@ -480,10 +483,10 @@ class DefaultPackager(Packager, metaclass=_DefaultPackagerMeta):
|
|
|
480
483
|
self,
|
|
481
484
|
data_item: DataItem,
|
|
482
485
|
pickle_module_name: str = DEFAULT_PICKLE_MODULE,
|
|
483
|
-
object_module_name: str = None,
|
|
484
|
-
python_version: str = None,
|
|
485
|
-
pickle_module_version: str = None,
|
|
486
|
-
object_module_version: str = None,
|
|
486
|
+
object_module_name: Optional[str] = None,
|
|
487
|
+
python_version: Optional[str] = None,
|
|
488
|
+
pickle_module_version: Optional[str] = None,
|
|
489
|
+
object_module_version: Optional[str] = None,
|
|
487
490
|
) -> Any:
|
|
488
491
|
"""
|
|
489
492
|
Unpack the data item's object, unpickle it using the instructions, and return.
|
|
@@ -16,7 +16,7 @@ import os
|
|
|
16
16
|
import pathlib
|
|
17
17
|
import tempfile
|
|
18
18
|
from abc import ABC, abstractmethod
|
|
19
|
-
from typing import Any, Union
|
|
19
|
+
from typing import Any, Optional, Union
|
|
20
20
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
import pandas as pd
|
|
@@ -371,7 +371,10 @@ class NumPyNDArrayPackager(DefaultPackager):
|
|
|
371
371
|
return artifact, {}
|
|
372
372
|
|
|
373
373
|
def unpack_file(
|
|
374
|
-
self,
|
|
374
|
+
self,
|
|
375
|
+
data_item: DataItem,
|
|
376
|
+
file_format: Optional[str] = None,
|
|
377
|
+
allow_pickle: bool = False,
|
|
375
378
|
) -> np.ndarray:
|
|
376
379
|
"""
|
|
377
380
|
Unpack a numppy array from file.
|
|
@@ -474,7 +477,7 @@ class _NumPyNDArrayCollectionPackager(DefaultPackager):
|
|
|
474
477
|
def unpack_file(
|
|
475
478
|
self,
|
|
476
479
|
data_item: DataItem,
|
|
477
|
-
file_format: str = None,
|
|
480
|
+
file_format: Optional[str] = None,
|
|
478
481
|
allow_pickle: bool = False,
|
|
479
482
|
) -> dict[str, np.ndarray]:
|
|
480
483
|
"""
|
|
@@ -548,7 +551,10 @@ class NumPyNDArrayDictPackager(_NumPyNDArrayCollectionPackager):
|
|
|
548
551
|
PACKABLE_OBJECT_TYPE = dict[str, np.ndarray]
|
|
549
552
|
|
|
550
553
|
def is_packable(
|
|
551
|
-
self,
|
|
554
|
+
self,
|
|
555
|
+
obj: Any,
|
|
556
|
+
artifact_type: Optional[str] = None,
|
|
557
|
+
configurations: Optional[dict] = None,
|
|
552
558
|
) -> bool:
|
|
553
559
|
"""
|
|
554
560
|
Check if the object provided is a dictionary of numpy arrays.
|
|
@@ -602,7 +608,7 @@ class NumPyNDArrayDictPackager(_NumPyNDArrayCollectionPackager):
|
|
|
602
608
|
def unpack_file(
|
|
603
609
|
self,
|
|
604
610
|
data_item: DataItem,
|
|
605
|
-
file_format: str = None,
|
|
611
|
+
file_format: Optional[str] = None,
|
|
606
612
|
allow_pickle: bool = False,
|
|
607
613
|
) -> dict[str, np.ndarray]:
|
|
608
614
|
"""
|
|
@@ -633,7 +639,10 @@ class NumPyNDArrayListPackager(_NumPyNDArrayCollectionPackager):
|
|
|
633
639
|
PACKABLE_OBJECT_TYPE = list[np.ndarray]
|
|
634
640
|
|
|
635
641
|
def is_packable(
|
|
636
|
-
self,
|
|
642
|
+
self,
|
|
643
|
+
obj: Any,
|
|
644
|
+
artifact_type: Optional[str] = None,
|
|
645
|
+
configurations: Optional[dict] = None,
|
|
637
646
|
) -> bool:
|
|
638
647
|
"""
|
|
639
648
|
Check if the object provided is a list of numpy arrays.
|
|
@@ -679,7 +688,7 @@ class NumPyNDArrayListPackager(_NumPyNDArrayCollectionPackager):
|
|
|
679
688
|
def unpack_file(
|
|
680
689
|
self,
|
|
681
690
|
data_item: DataItem,
|
|
682
|
-
file_format: str = None,
|
|
691
|
+
file_format: Optional[str] = None,
|
|
683
692
|
allow_pickle: bool = False,
|
|
684
693
|
) -> list[np.ndarray]:
|
|
685
694
|
"""
|
|
@@ -17,7 +17,7 @@ import os
|
|
|
17
17
|
import pathlib
|
|
18
18
|
import tempfile
|
|
19
19
|
from abc import ABC, abstractmethod
|
|
20
|
-
from typing import Any, Union
|
|
20
|
+
from typing import Any, Optional, Union
|
|
21
21
|
|
|
22
22
|
import pandas as pd
|
|
23
23
|
|
|
@@ -56,7 +56,7 @@ class _Formatter(ABC):
|
|
|
56
56
|
@classmethod
|
|
57
57
|
@abstractmethod
|
|
58
58
|
def read(
|
|
59
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
59
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
60
60
|
) -> pd.DataFrame:
|
|
61
61
|
"""
|
|
62
62
|
Read the dataframe from the given file path.
|
|
@@ -173,7 +173,7 @@ class _ParquetFormatter(_Formatter):
|
|
|
173
173
|
|
|
174
174
|
@classmethod
|
|
175
175
|
def read(
|
|
176
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
176
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
177
177
|
) -> pd.DataFrame:
|
|
178
178
|
"""
|
|
179
179
|
Read the dataframe from the given parquet file path.
|
|
@@ -221,7 +221,7 @@ class _CSVFormatter(_Formatter):
|
|
|
221
221
|
|
|
222
222
|
@classmethod
|
|
223
223
|
def read(
|
|
224
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
224
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
225
225
|
) -> pd.DataFrame:
|
|
226
226
|
"""
|
|
227
227
|
Read the dataframe from the given csv file path.
|
|
@@ -275,7 +275,7 @@ class _H5Formatter(_Formatter):
|
|
|
275
275
|
|
|
276
276
|
@classmethod
|
|
277
277
|
def read(
|
|
278
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
278
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
279
279
|
) -> pd.DataFrame:
|
|
280
280
|
"""
|
|
281
281
|
Read the dataframe from the given h5 file path.
|
|
@@ -332,7 +332,7 @@ class _XMLFormatter(_Formatter):
|
|
|
332
332
|
|
|
333
333
|
@classmethod
|
|
334
334
|
def read(
|
|
335
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
335
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
336
336
|
) -> pd.DataFrame:
|
|
337
337
|
"""
|
|
338
338
|
Read the dataframe from the given xml file path.
|
|
@@ -391,7 +391,7 @@ class _XLSXFormatter(_Formatter):
|
|
|
391
391
|
|
|
392
392
|
@classmethod
|
|
393
393
|
def read(
|
|
394
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
394
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
395
395
|
) -> pd.DataFrame:
|
|
396
396
|
"""
|
|
397
397
|
Read the dataframe from the given xlsx file path.
|
|
@@ -449,7 +449,7 @@ class _HTMLFormatter(_Formatter):
|
|
|
449
449
|
|
|
450
450
|
@classmethod
|
|
451
451
|
def read(
|
|
452
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
452
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
453
453
|
) -> pd.DataFrame:
|
|
454
454
|
"""
|
|
455
455
|
Read dataframes from the given html file path.
|
|
@@ -510,7 +510,7 @@ class _JSONFormatter(_Formatter):
|
|
|
510
510
|
|
|
511
511
|
@classmethod
|
|
512
512
|
def read(
|
|
513
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
513
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
514
514
|
) -> pd.DataFrame:
|
|
515
515
|
"""
|
|
516
516
|
Read dataframes from the given json file path.
|
|
@@ -565,7 +565,7 @@ class _FeatherFormatter(_Formatter):
|
|
|
565
565
|
|
|
566
566
|
@classmethod
|
|
567
567
|
def read(
|
|
568
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
568
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
569
569
|
) -> pd.DataFrame:
|
|
570
570
|
"""
|
|
571
571
|
Read dataframes from the given feather file path.
|
|
@@ -620,7 +620,7 @@ class _ORCFormatter(_Formatter):
|
|
|
620
620
|
|
|
621
621
|
@classmethod
|
|
622
622
|
def read(
|
|
623
|
-
cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
|
|
623
|
+
cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
|
|
624
624
|
) -> pd.DataFrame:
|
|
625
625
|
"""
|
|
626
626
|
Read dataframes from the given orc file path.
|
|
@@ -730,7 +730,7 @@ class PandasDataFramePackager(DefaultPackager):
|
|
|
730
730
|
self,
|
|
731
731
|
obj: pd.DataFrame,
|
|
732
732
|
key: str,
|
|
733
|
-
file_format: str = None,
|
|
733
|
+
file_format: Optional[str] = None,
|
|
734
734
|
flatten: bool = True,
|
|
735
735
|
**to_kwargs,
|
|
736
736
|
) -> tuple[Artifact, dict]:
|
|
@@ -785,8 +785,8 @@ class PandasDataFramePackager(DefaultPackager):
|
|
|
785
785
|
def unpack_file(
|
|
786
786
|
self,
|
|
787
787
|
data_item: DataItem,
|
|
788
|
-
file_format: str = None,
|
|
789
|
-
read_kwargs: dict = None,
|
|
788
|
+
file_format: Optional[str] = None,
|
|
789
|
+
read_kwargs: Optional[dict] = None,
|
|
790
790
|
) -> pd.DataFrame:
|
|
791
791
|
"""
|
|
792
792
|
Unpack a pandas dataframe from file.
|
|
@@ -883,7 +883,7 @@ class PandasSeriesPackager(PandasDataFramePackager):
|
|
|
883
883
|
self,
|
|
884
884
|
obj: pd.Series,
|
|
885
885
|
key: str,
|
|
886
|
-
file_format: str = None,
|
|
886
|
+
file_format: Optional[str] = None,
|
|
887
887
|
flatten: bool = True,
|
|
888
888
|
**to_kwargs,
|
|
889
889
|
) -> tuple[Artifact, dict]:
|
|
@@ -919,9 +919,9 @@ class PandasSeriesPackager(PandasDataFramePackager):
|
|
|
919
919
|
def unpack_file(
|
|
920
920
|
self,
|
|
921
921
|
data_item: DataItem,
|
|
922
|
-
file_format: str = None,
|
|
923
|
-
read_kwargs: dict = None,
|
|
924
|
-
column_name: Union[str, int] = None,
|
|
922
|
+
file_format: Optional[str] = None,
|
|
923
|
+
read_kwargs: Optional[dict] = None,
|
|
924
|
+
column_name: Optional[Union[str, int]] = None,
|
|
925
925
|
) -> pd.Series:
|
|
926
926
|
"""
|
|
927
927
|
Unpack a pandas series from file.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import os
|
|
16
16
|
import pathlib
|
|
17
17
|
import tempfile
|
|
18
|
-
from typing import Union
|
|
18
|
+
from typing import Optional, Union
|
|
19
19
|
|
|
20
20
|
from mlrun.artifacts import Artifact
|
|
21
21
|
from mlrun.datastore import DataItem
|
|
@@ -140,7 +140,7 @@ class StrPackager(DefaultPackager):
|
|
|
140
140
|
self,
|
|
141
141
|
data_item: DataItem,
|
|
142
142
|
is_directory: bool = False,
|
|
143
|
-
archive_format: str = None,
|
|
143
|
+
archive_format: Optional[str] = None,
|
|
144
144
|
) -> str:
|
|
145
145
|
"""
|
|
146
146
|
Unpack a data item representing a path string. If the path is of a file, the file is downloaded to a local
|
|
@@ -222,7 +222,7 @@ class _BuiltinCollectionPackager(DefaultPackager):
|
|
|
222
222
|
return artifact, instructions
|
|
223
223
|
|
|
224
224
|
def unpack_file(
|
|
225
|
-
self, data_item: DataItem, file_format: str = None
|
|
225
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
226
226
|
) -> Union[dict, list]:
|
|
227
227
|
"""
|
|
228
228
|
Unpack a builtin collection from file.
|
|
@@ -259,7 +259,9 @@ class DictPackager(_BuiltinCollectionPackager):
|
|
|
259
259
|
|
|
260
260
|
PACKABLE_OBJECT_TYPE = dict
|
|
261
261
|
|
|
262
|
-
def unpack_file(
|
|
262
|
+
def unpack_file(
|
|
263
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
264
|
+
) -> dict:
|
|
263
265
|
"""
|
|
264
266
|
Unpack a dictionary from file.
|
|
265
267
|
|
|
@@ -285,7 +287,9 @@ class ListPackager(_BuiltinCollectionPackager):
|
|
|
285
287
|
|
|
286
288
|
PACKABLE_OBJECT_TYPE = list
|
|
287
289
|
|
|
288
|
-
def unpack_file(
|
|
290
|
+
def unpack_file(
|
|
291
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
292
|
+
) -> list:
|
|
289
293
|
"""
|
|
290
294
|
Unpack a list from file.
|
|
291
295
|
|
|
@@ -355,7 +359,9 @@ class TuplePackager(ListPackager):
|
|
|
355
359
|
"""
|
|
356
360
|
return super().pack_file(obj=list(obj), key=key, file_format=file_format)
|
|
357
361
|
|
|
358
|
-
def unpack_file(
|
|
362
|
+
def unpack_file(
|
|
363
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
364
|
+
) -> tuple:
|
|
359
365
|
"""
|
|
360
366
|
Unpack a tuple from file.
|
|
361
367
|
|
|
@@ -400,7 +406,9 @@ class SetPackager(ListPackager):
|
|
|
400
406
|
"""
|
|
401
407
|
return super().pack_file(obj=list(obj), key=key, file_format=file_format)
|
|
402
408
|
|
|
403
|
-
def unpack_file(
|
|
409
|
+
def unpack_file(
|
|
410
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
411
|
+
) -> set:
|
|
404
412
|
"""
|
|
405
413
|
Unpack a set from file.
|
|
406
414
|
|
|
@@ -434,7 +442,9 @@ class FrozensetPackager(SetPackager):
|
|
|
434
442
|
"""
|
|
435
443
|
return super().pack_file(obj=set(obj), key=key, file_format=file_format)
|
|
436
444
|
|
|
437
|
-
def unpack_file(
|
|
445
|
+
def unpack_file(
|
|
446
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
447
|
+
) -> frozenset:
|
|
438
448
|
"""
|
|
439
449
|
Unpack a frozenset from file.
|
|
440
450
|
|
|
@@ -481,7 +491,9 @@ class BytesPackager(ListPackager):
|
|
|
481
491
|
"""
|
|
482
492
|
return super().pack_file(obj=list(obj), key=key, file_format=file_format)
|
|
483
493
|
|
|
484
|
-
def unpack_file(
|
|
494
|
+
def unpack_file(
|
|
495
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
496
|
+
) -> bytes:
|
|
485
497
|
"""
|
|
486
498
|
Unpack a bytes from file.
|
|
487
499
|
|
|
@@ -526,7 +538,9 @@ class BytearrayPackager(BytesPackager):
|
|
|
526
538
|
"""
|
|
527
539
|
return super().pack_file(obj=bytes(obj), key=key, file_format=file_format)
|
|
528
540
|
|
|
529
|
-
def unpack_file(
|
|
541
|
+
def unpack_file(
|
|
542
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
543
|
+
) -> bytearray:
|
|
530
544
|
"""
|
|
531
545
|
Unpack a bytearray from file.
|
|
532
546
|
|
|
@@ -585,7 +599,7 @@ class PathPackager(StrPackager):
|
|
|
585
599
|
self,
|
|
586
600
|
data_item: DataItem,
|
|
587
601
|
is_directory: bool = False,
|
|
588
|
-
archive_format: str = None,
|
|
602
|
+
archive_format: Optional[str] = None,
|
|
589
603
|
) -> pathlib.Path:
|
|
590
604
|
"""
|
|
591
605
|
Unpack a data item representing a `Path`. If the path is of a file, the file is downloaded to a local
|