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.
- 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 +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 +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 +71 -36
- 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 +54 -16
- 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.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/METADATA +21 -16
- mlrun-1.8.0rc8.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.0rc8.dist-info}/LICENSE +0 -0
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/WHEEL +0 -0
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/top_level.txt +0 -0
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
#
|
|
15
|
-
from typing import Union
|
|
15
|
+
from typing import Optional, Union
|
|
16
16
|
|
|
17
17
|
from torch import Tensor
|
|
18
18
|
from torch.nn import Module
|
|
@@ -116,7 +116,7 @@ class CallbacksHandler:
|
|
|
116
116
|
optimizer: Optimizer,
|
|
117
117
|
metric_functions: list[PyTorchTypes.MetricFunctionType],
|
|
118
118
|
scheduler,
|
|
119
|
-
callbacks: list[str] = None,
|
|
119
|
+
callbacks: Optional[list[str]] = None,
|
|
120
120
|
) -> bool:
|
|
121
121
|
"""
|
|
122
122
|
Call the 'on_setup' method of every callback in the callbacks list. If the list is 'None' (not given), all
|
|
@@ -145,7 +145,7 @@ class CallbacksHandler:
|
|
|
145
145
|
scheduler=scheduler,
|
|
146
146
|
)
|
|
147
147
|
|
|
148
|
-
def on_run_begin(self, callbacks: list[str] = None) -> bool:
|
|
148
|
+
def on_run_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
149
149
|
"""
|
|
150
150
|
Call the 'on_run_begin' method of every callback in the callbacks list. If the list is 'None' (not given), all
|
|
151
151
|
callbacks will be called.
|
|
@@ -159,7 +159,7 @@ class CallbacksHandler:
|
|
|
159
159
|
callbacks=self._parse_names(names=callbacks),
|
|
160
160
|
)
|
|
161
161
|
|
|
162
|
-
def on_run_end(self, callbacks: list[str] = None) -> bool:
|
|
162
|
+
def on_run_end(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
163
163
|
"""
|
|
164
164
|
Call the 'on_run_end' method of every callback in the callbacks list. If the list is 'None' (not given), all
|
|
165
165
|
callbacks will be called.
|
|
@@ -173,7 +173,7 @@ class CallbacksHandler:
|
|
|
173
173
|
callbacks=self._parse_names(names=callbacks),
|
|
174
174
|
)
|
|
175
175
|
|
|
176
|
-
def on_epoch_begin(self, epoch: int, callbacks: list[str] = None) -> bool:
|
|
176
|
+
def on_epoch_begin(self, epoch: int, callbacks: Optional[list[str]] = None) -> bool:
|
|
177
177
|
"""
|
|
178
178
|
Call the 'on_epoch_begin' method of every callback in the callbacks list. If the list is 'None' (not given), all
|
|
179
179
|
callbacks will be called.
|
|
@@ -189,7 +189,7 @@ class CallbacksHandler:
|
|
|
189
189
|
epoch=epoch,
|
|
190
190
|
)
|
|
191
191
|
|
|
192
|
-
def on_epoch_end(self, epoch: int, callbacks: list[str] = None) -> bool:
|
|
192
|
+
def on_epoch_end(self, epoch: int, callbacks: Optional[list[str]] = None) -> bool:
|
|
193
193
|
"""
|
|
194
194
|
Call the 'on_epoch_end' method of every callback in the callbacks list. If the list is 'None' (not given), all
|
|
195
195
|
callbacks will be called.
|
|
@@ -205,7 +205,7 @@ class CallbacksHandler:
|
|
|
205
205
|
epoch=epoch,
|
|
206
206
|
)
|
|
207
207
|
|
|
208
|
-
def on_train_begin(self, callbacks: list[str] = None) -> bool:
|
|
208
|
+
def on_train_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
209
209
|
"""
|
|
210
210
|
Call the 'on_train_begin' method of every callback in the callbacks list. If the list is 'None' (not given), all
|
|
211
211
|
callbacks will be called.
|
|
@@ -219,7 +219,7 @@ class CallbacksHandler:
|
|
|
219
219
|
callbacks=self._parse_names(names=callbacks),
|
|
220
220
|
)
|
|
221
221
|
|
|
222
|
-
def on_train_end(self, callbacks: list[str] = None) -> bool:
|
|
222
|
+
def on_train_end(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
223
223
|
"""
|
|
224
224
|
Call the 'on_train_end' method of every callback in the callbacks list. If the list is 'None' (not given), all
|
|
225
225
|
callbacks will be called.
|
|
@@ -233,7 +233,7 @@ class CallbacksHandler:
|
|
|
233
233
|
callbacks=self._parse_names(names=callbacks),
|
|
234
234
|
)
|
|
235
235
|
|
|
236
|
-
def on_validation_begin(self, callbacks: list[str] = None) -> bool:
|
|
236
|
+
def on_validation_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
237
237
|
"""
|
|
238
238
|
Call the 'on_validation_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
239
239
|
(not given), all callbacks will be called.
|
|
@@ -251,7 +251,7 @@ class CallbacksHandler:
|
|
|
251
251
|
self,
|
|
252
252
|
loss_value: PyTorchTypes.MetricValueType,
|
|
253
253
|
metric_values: list[float],
|
|
254
|
-
callbacks: list[str] = None,
|
|
254
|
+
callbacks: Optional[list[str]] = None,
|
|
255
255
|
) -> bool:
|
|
256
256
|
"""
|
|
257
257
|
Call the 'on_validation_end' method of every callback in the callbacks list. If the list is 'None' (not given),
|
|
@@ -271,7 +271,7 @@ class CallbacksHandler:
|
|
|
271
271
|
)
|
|
272
272
|
|
|
273
273
|
def on_train_batch_begin(
|
|
274
|
-
self, batch: int, x, y_true: Tensor, callbacks: list[str] = None
|
|
274
|
+
self, batch: int, x, y_true: Tensor, callbacks: Optional[list[str]] = None
|
|
275
275
|
) -> bool:
|
|
276
276
|
"""
|
|
277
277
|
Call the 'on_train_batch_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
@@ -298,7 +298,7 @@ class CallbacksHandler:
|
|
|
298
298
|
x,
|
|
299
299
|
y_pred: Tensor,
|
|
300
300
|
y_true: Tensor,
|
|
301
|
-
callbacks: list[str] = None,
|
|
301
|
+
callbacks: Optional[list[str]] = None,
|
|
302
302
|
) -> bool:
|
|
303
303
|
"""
|
|
304
304
|
Call the 'on_train_batch_end' method of every callback in the callbacks list. If the list is 'None' (not given),
|
|
@@ -322,7 +322,7 @@ class CallbacksHandler:
|
|
|
322
322
|
)
|
|
323
323
|
|
|
324
324
|
def on_validation_batch_begin(
|
|
325
|
-
self, batch: int, x, y_true: Tensor, callbacks: list[str] = None
|
|
325
|
+
self, batch: int, x, y_true: Tensor, callbacks: Optional[list[str]] = None
|
|
326
326
|
) -> bool:
|
|
327
327
|
"""
|
|
328
328
|
Call the 'on_validation_batch_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
@@ -349,7 +349,7 @@ class CallbacksHandler:
|
|
|
349
349
|
x,
|
|
350
350
|
y_pred: Tensor,
|
|
351
351
|
y_true: Tensor,
|
|
352
|
-
callbacks: list[str] = None,
|
|
352
|
+
callbacks: Optional[list[str]] = None,
|
|
353
353
|
) -> bool:
|
|
354
354
|
"""
|
|
355
355
|
Call the 'on_validation_batch_end' method of every callback in the callbacks list. If the list is 'None'
|
|
@@ -375,7 +375,7 @@ class CallbacksHandler:
|
|
|
375
375
|
def on_inference_begin(
|
|
376
376
|
self,
|
|
377
377
|
x,
|
|
378
|
-
callbacks: list[str] = None,
|
|
378
|
+
callbacks: Optional[list[str]] = None,
|
|
379
379
|
) -> bool:
|
|
380
380
|
"""
|
|
381
381
|
Call the 'on_inference_begin' method of every callback in the callbacks list. If the list is 'None' (not given),
|
|
@@ -396,7 +396,7 @@ class CallbacksHandler:
|
|
|
396
396
|
self,
|
|
397
397
|
y_pred: Tensor,
|
|
398
398
|
y_true: Tensor,
|
|
399
|
-
callbacks: list[str] = None,
|
|
399
|
+
callbacks: Optional[list[str]] = None,
|
|
400
400
|
) -> bool:
|
|
401
401
|
"""
|
|
402
402
|
Call the 'on_inference_end' method of every callback in the callbacks list. If the list is 'None' (not given),
|
|
@@ -415,7 +415,7 @@ class CallbacksHandler:
|
|
|
415
415
|
y_true=y_true,
|
|
416
416
|
)
|
|
417
417
|
|
|
418
|
-
def on_train_loss_begin(self, callbacks: list[str] = None) -> bool:
|
|
418
|
+
def on_train_loss_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
419
419
|
"""
|
|
420
420
|
Call the 'on_train_loss_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
421
421
|
(not given), all callbacks will be called.
|
|
@@ -430,7 +430,9 @@ class CallbacksHandler:
|
|
|
430
430
|
)
|
|
431
431
|
|
|
432
432
|
def on_train_loss_end(
|
|
433
|
-
self,
|
|
433
|
+
self,
|
|
434
|
+
loss_value: PyTorchTypes.MetricValueType,
|
|
435
|
+
callbacks: Optional[list[str]] = None,
|
|
434
436
|
) -> bool:
|
|
435
437
|
"""
|
|
436
438
|
Call the 'on_train_loss_end' method of every callback in the callbacks list. If the list is 'None' (not given),
|
|
@@ -447,7 +449,7 @@ class CallbacksHandler:
|
|
|
447
449
|
loss_value=loss_value,
|
|
448
450
|
)
|
|
449
451
|
|
|
450
|
-
def on_validation_loss_begin(self, callbacks: list[str] = None) -> bool:
|
|
452
|
+
def on_validation_loss_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
451
453
|
"""
|
|
452
454
|
Call the 'on_validation_loss_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
453
455
|
(not given), all callbacks will be called.
|
|
@@ -462,7 +464,9 @@ class CallbacksHandler:
|
|
|
462
464
|
)
|
|
463
465
|
|
|
464
466
|
def on_validation_loss_end(
|
|
465
|
-
self,
|
|
467
|
+
self,
|
|
468
|
+
loss_value: PyTorchTypes.MetricValueType,
|
|
469
|
+
callbacks: Optional[list[str]] = None,
|
|
466
470
|
) -> bool:
|
|
467
471
|
"""
|
|
468
472
|
Call the 'on_validation_loss_end' method of every callback in the callbacks list. If the list is 'None'
|
|
@@ -479,7 +483,7 @@ class CallbacksHandler:
|
|
|
479
483
|
loss_value=loss_value,
|
|
480
484
|
)
|
|
481
485
|
|
|
482
|
-
def on_train_metrics_begin(self, callbacks: list[str] = None) -> bool:
|
|
486
|
+
def on_train_metrics_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
483
487
|
"""
|
|
484
488
|
Call the 'on_train_metrics_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
485
489
|
(not given), all callbacks will be called.
|
|
@@ -496,7 +500,7 @@ class CallbacksHandler:
|
|
|
496
500
|
def on_train_metrics_end(
|
|
497
501
|
self,
|
|
498
502
|
metric_values: list[PyTorchTypes.MetricValueType],
|
|
499
|
-
callbacks: list[str] = None,
|
|
503
|
+
callbacks: Optional[list[str]] = None,
|
|
500
504
|
) -> bool:
|
|
501
505
|
"""
|
|
502
506
|
Call the 'on_train_metrics_end' method of every callback in the callbacks list. If the list is 'None'
|
|
@@ -513,7 +517,9 @@ class CallbacksHandler:
|
|
|
513
517
|
metric_values=metric_values,
|
|
514
518
|
)
|
|
515
519
|
|
|
516
|
-
def on_validation_metrics_begin(
|
|
520
|
+
def on_validation_metrics_begin(
|
|
521
|
+
self, callbacks: Optional[list[str]] = None
|
|
522
|
+
) -> bool:
|
|
517
523
|
"""
|
|
518
524
|
Call the 'on_validation_metrics_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
519
525
|
(not given), all callbacks will be called.
|
|
@@ -530,7 +536,7 @@ class CallbacksHandler:
|
|
|
530
536
|
def on_validation_metrics_end(
|
|
531
537
|
self,
|
|
532
538
|
metric_values: list[PyTorchTypes.MetricValueType],
|
|
533
|
-
callbacks: list[str] = None,
|
|
539
|
+
callbacks: Optional[list[str]] = None,
|
|
534
540
|
) -> bool:
|
|
535
541
|
"""
|
|
536
542
|
Call the 'on_validation_metrics_end' method of every callback in the callbacks list. If the list is 'None'
|
|
@@ -547,7 +553,7 @@ class CallbacksHandler:
|
|
|
547
553
|
metric_values=metric_values,
|
|
548
554
|
)
|
|
549
555
|
|
|
550
|
-
def on_backward_begin(self, callbacks: list[str] = None) -> bool:
|
|
556
|
+
def on_backward_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
551
557
|
"""
|
|
552
558
|
Call the 'on_backward_begin' method of every callback in the callbacks list. If the list is 'None' (not given),
|
|
553
559
|
all callbacks will be called.
|
|
@@ -561,7 +567,7 @@ class CallbacksHandler:
|
|
|
561
567
|
callbacks=self._parse_names(names=callbacks),
|
|
562
568
|
)
|
|
563
569
|
|
|
564
|
-
def on_backward_end(self, callbacks: list[str] = None) -> bool:
|
|
570
|
+
def on_backward_end(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
565
571
|
"""
|
|
566
572
|
Call the 'on_backward_end' method of every callback in the callbacks list. If the list is 'None' (not given),
|
|
567
573
|
all callbacks will be called.
|
|
@@ -575,7 +581,7 @@ class CallbacksHandler:
|
|
|
575
581
|
callbacks=self._parse_names(names=callbacks),
|
|
576
582
|
)
|
|
577
583
|
|
|
578
|
-
def on_optimizer_step_begin(self, callbacks: list[str] = None) -> bool:
|
|
584
|
+
def on_optimizer_step_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
579
585
|
"""
|
|
580
586
|
Call the 'on_optimizer_step_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
581
587
|
(not given), all callbacks will be called.
|
|
@@ -589,7 +595,7 @@ class CallbacksHandler:
|
|
|
589
595
|
callbacks=self._parse_names(names=callbacks),
|
|
590
596
|
)
|
|
591
597
|
|
|
592
|
-
def on_optimizer_step_end(self, callbacks: list[str] = None) -> bool:
|
|
598
|
+
def on_optimizer_step_end(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
593
599
|
"""
|
|
594
600
|
Call the 'on_optimizer_step_end' method of every callback in the callbacks list. If the list is 'None'
|
|
595
601
|
(not given), all callbacks will be called.
|
|
@@ -603,7 +609,7 @@ class CallbacksHandler:
|
|
|
603
609
|
callbacks=self._parse_names(names=callbacks),
|
|
604
610
|
)
|
|
605
611
|
|
|
606
|
-
def on_scheduler_step_begin(self, callbacks: list[str] = None) -> bool:
|
|
612
|
+
def on_scheduler_step_begin(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
607
613
|
"""
|
|
608
614
|
Call the 'on_scheduler_step_begin' method of every callback in the callbacks list. If the list is 'None'
|
|
609
615
|
(not given), all callbacks will be called.
|
|
@@ -617,7 +623,7 @@ class CallbacksHandler:
|
|
|
617
623
|
callbacks=self._parse_names(names=callbacks),
|
|
618
624
|
)
|
|
619
625
|
|
|
620
|
-
def on_scheduler_step_end(self, callbacks: list[str] = None) -> bool:
|
|
626
|
+
def on_scheduler_step_end(self, callbacks: Optional[list[str]] = None) -> bool:
|
|
621
627
|
"""
|
|
622
628
|
Call the 'on_scheduler_step_end' method of every callback in the callbacks list. If the list is 'None'
|
|
623
629
|
(not given), all callbacks will be called.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
#
|
|
15
15
|
import importlib
|
|
16
16
|
import sys
|
|
17
|
-
from typing import Any, Union
|
|
17
|
+
from typing import Any, Optional, Union
|
|
18
18
|
|
|
19
19
|
import torch
|
|
20
20
|
import torch.multiprocessing as mp
|
|
@@ -109,15 +109,15 @@ class PyTorchMLRunInterface:
|
|
|
109
109
|
loss_function: Module,
|
|
110
110
|
optimizer: Optimizer,
|
|
111
111
|
validation_set: DataLoader = None,
|
|
112
|
-
metric_functions: list[PyTorchTypes.MetricFunctionType] = None,
|
|
112
|
+
metric_functions: Optional[list[PyTorchTypes.MetricFunctionType]] = None,
|
|
113
113
|
scheduler=None,
|
|
114
114
|
scheduler_step_frequency: Union[int, float, str] = "epoch",
|
|
115
115
|
epochs: int = 1,
|
|
116
|
-
training_iterations: int = None,
|
|
117
|
-
validation_iterations: int = None,
|
|
118
|
-
callbacks: list[Callback] = None,
|
|
116
|
+
training_iterations: Optional[int] = None,
|
|
117
|
+
validation_iterations: Optional[int] = None,
|
|
118
|
+
callbacks: Optional[list[Callback]] = None,
|
|
119
119
|
use_cuda: bool = True,
|
|
120
|
-
use_horovod: bool = None,
|
|
120
|
+
use_horovod: Optional[bool] = None,
|
|
121
121
|
):
|
|
122
122
|
"""
|
|
123
123
|
Initiate a training process on this interface configuration.
|
|
@@ -221,11 +221,11 @@ class PyTorchMLRunInterface:
|
|
|
221
221
|
self,
|
|
222
222
|
dataset: DataLoader,
|
|
223
223
|
loss_function: Module = None,
|
|
224
|
-
metric_functions: list[PyTorchTypes.MetricFunctionType] = None,
|
|
225
|
-
iterations: int = None,
|
|
226
|
-
callbacks: list[Callback] = None,
|
|
224
|
+
metric_functions: Optional[list[PyTorchTypes.MetricFunctionType]] = None,
|
|
225
|
+
iterations: Optional[int] = None,
|
|
226
|
+
callbacks: Optional[list[Callback]] = None,
|
|
227
227
|
use_cuda: bool = True,
|
|
228
|
-
use_horovod: bool = None,
|
|
228
|
+
use_horovod: Optional[bool] = None,
|
|
229
229
|
) -> list[PyTorchTypes.MetricValueType]:
|
|
230
230
|
"""
|
|
231
231
|
Initiate an evaluation process on this interface configuration.
|
|
@@ -303,9 +303,9 @@ class PyTorchMLRunInterface:
|
|
|
303
303
|
def add_auto_logging_callbacks(
|
|
304
304
|
self,
|
|
305
305
|
add_mlrun_logger: bool = True,
|
|
306
|
-
mlrun_callback_kwargs: dict[str, Any] = None,
|
|
306
|
+
mlrun_callback_kwargs: Optional[dict[str, Any]] = None,
|
|
307
307
|
add_tensorboard_logger: bool = True,
|
|
308
|
-
tensorboard_callback_kwargs: dict[str, Any] = None,
|
|
308
|
+
tensorboard_callback_kwargs: Optional[dict[str, Any]] = None,
|
|
309
309
|
):
|
|
310
310
|
"""
|
|
311
311
|
Get automatic logging callbacks to both MLRun's context and Tensorboard. For further features of logging to both
|
|
@@ -402,15 +402,15 @@ class PyTorchMLRunInterface:
|
|
|
402
402
|
loss_function: Module = None,
|
|
403
403
|
optimizer: Optimizer = None,
|
|
404
404
|
validation_set: DataLoader = None,
|
|
405
|
-
metric_functions: list[PyTorchTypes.MetricFunctionType] = None,
|
|
405
|
+
metric_functions: Optional[list[PyTorchTypes.MetricFunctionType]] = None,
|
|
406
406
|
scheduler=None,
|
|
407
407
|
scheduler_step_frequency: Union[int, float, str] = "epoch",
|
|
408
408
|
epochs: int = 1,
|
|
409
|
-
training_iterations: int = None,
|
|
410
|
-
validation_iterations: int = None,
|
|
411
|
-
callbacks: list[Callback] = None,
|
|
409
|
+
training_iterations: Optional[int] = None,
|
|
410
|
+
validation_iterations: Optional[int] = None,
|
|
411
|
+
callbacks: Optional[list[Callback]] = None,
|
|
412
412
|
use_cuda: bool = True,
|
|
413
|
-
use_horovod: bool = None,
|
|
413
|
+
use_horovod: Optional[bool] = None,
|
|
414
414
|
):
|
|
415
415
|
"""
|
|
416
416
|
Parse and store the given input so the interface can starting training / evaluating.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
#
|
|
15
15
|
import os
|
|
16
|
-
from typing import Union
|
|
16
|
+
from typing import Optional, Union
|
|
17
17
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
import torch
|
|
@@ -48,12 +48,16 @@ class PyTorchModelHandler(DLModelHandler):
|
|
|
48
48
|
def __init__(
|
|
49
49
|
self,
|
|
50
50
|
model: Module = None,
|
|
51
|
-
model_path: str = None,
|
|
52
|
-
model_name: str = None,
|
|
53
|
-
model_class: Union[type[Module], str] = None,
|
|
54
|
-
modules_map:
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
model_path: Optional[str] = None,
|
|
52
|
+
model_name: Optional[str] = None,
|
|
53
|
+
model_class: Optional[Union[type[Module], str]] = None,
|
|
54
|
+
modules_map: Optional[
|
|
55
|
+
Union[dict[str, Union[None, str, list[str]]], str]
|
|
56
|
+
] = None,
|
|
57
|
+
custom_objects_map: Optional[
|
|
58
|
+
Union[dict[str, Union[str, list[str]]], str]
|
|
59
|
+
] = None,
|
|
60
|
+
custom_objects_directory: Optional[str] = None,
|
|
57
61
|
context: mlrun.MLClientCtx = None,
|
|
58
62
|
**kwargs,
|
|
59
63
|
):
|
|
@@ -152,8 +156,8 @@ class PyTorchModelHandler(DLModelHandler):
|
|
|
152
156
|
|
|
153
157
|
def set_labels(
|
|
154
158
|
self,
|
|
155
|
-
to_add: dict[str, Union[str, int, float]] = None,
|
|
156
|
-
to_remove: list[str] = None,
|
|
159
|
+
to_add: Optional[dict[str, Union[str, int, float]]] = None,
|
|
160
|
+
to_remove: Optional[list[str]] = None,
|
|
157
161
|
):
|
|
158
162
|
"""
|
|
159
163
|
Update the labels dictionary of this model artifact. There are required labels that cannot be edited or removed.
|
|
@@ -168,7 +172,7 @@ class PyTorchModelHandler(DLModelHandler):
|
|
|
168
172
|
self._labels[self._LabelKeys.MODEL_CLASS_NAME] = self._model_class_name
|
|
169
173
|
|
|
170
174
|
def save(
|
|
171
|
-
self, output_path: str = None, **kwargs
|
|
175
|
+
self, output_path: Optional[str] = None, **kwargs
|
|
172
176
|
) -> Union[dict[str, Artifact], None]:
|
|
173
177
|
"""
|
|
174
178
|
Save the handled model at the given output path.
|
|
@@ -194,7 +198,7 @@ class PyTorchModelHandler(DLModelHandler):
|
|
|
194
198
|
|
|
195
199
|
return None
|
|
196
200
|
|
|
197
|
-
def load(self, checkpoint: str = None, **kwargs):
|
|
201
|
+
def load(self, checkpoint: Optional[str] = None, **kwargs):
|
|
198
202
|
"""
|
|
199
203
|
Load the specified model in this handler. If a checkpoint is required to be loaded, it can be given here
|
|
200
204
|
according to the provided model path in the initialization of this handler. Additional parameters for the class
|
|
@@ -232,15 +236,15 @@ class PyTorchModelHandler(DLModelHandler):
|
|
|
232
236
|
|
|
233
237
|
def to_onnx(
|
|
234
238
|
self,
|
|
235
|
-
model_name: str = None,
|
|
239
|
+
model_name: Optional[str] = None,
|
|
236
240
|
input_sample: Union[torch.Tensor, tuple[torch.Tensor, ...]] = None,
|
|
237
|
-
input_layers_names: list[str] = None,
|
|
238
|
-
output_layers_names: list[str] = None,
|
|
239
|
-
dynamic_axes: dict[str, dict[int, str]] = None,
|
|
241
|
+
input_layers_names: Optional[list[str]] = None,
|
|
242
|
+
output_layers_names: Optional[list[str]] = None,
|
|
243
|
+
dynamic_axes: Optional[dict[str, dict[int, str]]] = None,
|
|
240
244
|
is_batched: bool = True,
|
|
241
245
|
optimize: bool = True,
|
|
242
|
-
output_path: str = None,
|
|
243
|
-
log: bool = None,
|
|
246
|
+
output_path: Optional[str] = None,
|
|
247
|
+
log: Optional[bool] = None,
|
|
244
248
|
):
|
|
245
249
|
"""
|
|
246
250
|
Convert the model in this handler to an ONNX model. The layer names are optional, they do not change the
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
#
|
|
15
|
-
from typing import Any, Union
|
|
15
|
+
from typing import Any, Optional, Union
|
|
16
16
|
|
|
17
17
|
import numpy as np
|
|
18
18
|
import torch
|
|
@@ -35,17 +35,21 @@ class PyTorchModelServer(V2ModelServer):
|
|
|
35
35
|
def __init__(
|
|
36
36
|
self,
|
|
37
37
|
context: mlrun.MLClientCtx = None,
|
|
38
|
-
name: str = None,
|
|
38
|
+
name: Optional[str] = None,
|
|
39
39
|
model: Module = None,
|
|
40
|
-
model_path: str = None,
|
|
41
|
-
model_name: str = None,
|
|
42
|
-
model_class: Union[type[Module], str] = None,
|
|
43
|
-
modules_map:
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
model_path: Optional[str] = None,
|
|
41
|
+
model_name: Optional[str] = None,
|
|
42
|
+
model_class: Optional[Union[type[Module], str]] = None,
|
|
43
|
+
modules_map: Optional[
|
|
44
|
+
Union[dict[str, Union[None, str, list[str]]], str]
|
|
45
|
+
] = None,
|
|
46
|
+
custom_objects_map: Optional[
|
|
47
|
+
Union[dict[str, Union[str, list[str]]], str]
|
|
48
|
+
] = None,
|
|
49
|
+
custom_objects_directory: Optional[str] = None,
|
|
46
50
|
use_cuda: bool = True,
|
|
47
51
|
to_list: bool = False,
|
|
48
|
-
protocol: str = None,
|
|
52
|
+
protocol: Optional[str] = None,
|
|
49
53
|
**class_args,
|
|
50
54
|
):
|
|
51
55
|
"""
|
|
@@ -11,10 +11,9 @@
|
|
|
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
|
-
# flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
|
|
14
|
+
|
|
16
15
|
import warnings
|
|
17
|
-
from typing import Union
|
|
16
|
+
from typing import Optional, Union
|
|
18
17
|
|
|
19
18
|
import mlrun
|
|
20
19
|
from mlrun.frameworks.sklearn.metric import Metric
|
|
@@ -36,26 +35,28 @@ def apply_mlrun(
|
|
|
36
35
|
model: SKLearnTypes.ModelType = None,
|
|
37
36
|
model_name: str = "model",
|
|
38
37
|
tag: str = "",
|
|
39
|
-
model_path: str = None,
|
|
40
|
-
modules_map: Union[dict[str, Union[None, str, list[str]]], str] = None,
|
|
41
|
-
custom_objects_map: Union[dict[str, Union[str, list[str]]], str] = None,
|
|
42
|
-
custom_objects_directory: str = None,
|
|
38
|
+
model_path: Optional[str] = None,
|
|
39
|
+
modules_map: Optional[Union[dict[str, Union[None, str, list[str]]], str]] = None,
|
|
40
|
+
custom_objects_map: Optional[Union[dict[str, Union[str, list[str]]], str]] = None,
|
|
41
|
+
custom_objects_directory: Optional[str] = None,
|
|
43
42
|
context: mlrun.MLClientCtx = None,
|
|
44
|
-
artifacts: Union[list[MLPlan], list[str], dict[str, dict]] = None,
|
|
45
|
-
metrics:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
artifacts: Optional[Union[list[MLPlan], list[str], dict[str, dict]]] = None,
|
|
44
|
+
metrics: Optional[
|
|
45
|
+
Union[
|
|
46
|
+
list[Metric],
|
|
47
|
+
list[SKLearnTypes.MetricEntryType],
|
|
48
|
+
dict[str, SKLearnTypes.MetricEntryType],
|
|
49
|
+
]
|
|
49
50
|
] = None,
|
|
50
51
|
x_test: SKLearnTypes.DatasetType = None,
|
|
51
52
|
y_test: SKLearnTypes.DatasetType = None,
|
|
52
53
|
sample_set: Union[SKLearnTypes.DatasetType, mlrun.DataItem, str] = None,
|
|
53
|
-
y_columns: Union[list[str], list[int]] = None,
|
|
54
|
-
feature_vector: str = None,
|
|
55
|
-
feature_weights: list[float] = None,
|
|
56
|
-
labels: dict[str, Union[str, int, float]] = None,
|
|
57
|
-
parameters: dict[str, Union[str, int, float]] = None,
|
|
58
|
-
extra_data: dict[str, SKLearnTypes.ExtraDataType] = None,
|
|
54
|
+
y_columns: Optional[Union[list[str], list[int]]] = None,
|
|
55
|
+
feature_vector: Optional[str] = None,
|
|
56
|
+
feature_weights: Optional[list[float]] = None,
|
|
57
|
+
labels: Optional[dict[str, Union[str, int, float]]] = None,
|
|
58
|
+
parameters: Optional[dict[str, Union[str, int, float]]] = None,
|
|
59
|
+
extra_data: Optional[dict[str, SKLearnTypes.ExtraDataType]] = None,
|
|
59
60
|
auto_log: bool = True,
|
|
60
61
|
**kwargs,
|
|
61
62
|
) -> SKLearnModelHandler:
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
#
|
|
15
|
-
from typing import Union
|
|
15
|
+
from typing import Optional, Union
|
|
16
16
|
|
|
17
17
|
import numpy as np
|
|
18
18
|
import pandas as pd
|
|
@@ -32,7 +32,7 @@ class Estimator:
|
|
|
32
32
|
def __init__(
|
|
33
33
|
self,
|
|
34
34
|
context: mlrun.MLClientCtx = None,
|
|
35
|
-
metrics: list[Metric] = None,
|
|
35
|
+
metrics: Optional[list[Metric]] = None,
|
|
36
36
|
):
|
|
37
37
|
"""
|
|
38
38
|
Initialize an estimator with the given metrics. The estimator will log the calculated results using the given
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import importlib
|
|
16
16
|
import json
|
|
17
17
|
import sys
|
|
18
|
-
from typing import Callable, Union
|
|
18
|
+
from typing import Callable, Optional, Union
|
|
19
19
|
|
|
20
20
|
import mlrun.errors
|
|
21
21
|
|
|
@@ -31,8 +31,8 @@ class Metric:
|
|
|
31
31
|
def __init__(
|
|
32
32
|
self,
|
|
33
33
|
metric: Union[Callable, str],
|
|
34
|
-
name: str = None,
|
|
35
|
-
additional_arguments: dict = None,
|
|
34
|
+
name: Optional[str] = None,
|
|
35
|
+
additional_arguments: Optional[dict] = None,
|
|
36
36
|
need_probabilities: bool = False,
|
|
37
37
|
):
|
|
38
38
|
"""
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
#
|
|
15
15
|
from abc import ABC
|
|
16
|
-
from typing import Union
|
|
16
|
+
from typing import Optional, Union
|
|
17
17
|
|
|
18
18
|
import sklearn
|
|
19
19
|
from sklearn.preprocessing import LabelBinarizer
|
|
@@ -39,10 +39,12 @@ class MetricsLibrary(ABC):
|
|
|
39
39
|
@classmethod
|
|
40
40
|
def get_metrics(
|
|
41
41
|
cls,
|
|
42
|
-
metrics:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
metrics: Optional[
|
|
43
|
+
Union[
|
|
44
|
+
list[Metric],
|
|
45
|
+
list[SKLearnTypes.MetricEntryType],
|
|
46
|
+
dict[str, SKLearnTypes.MetricEntryType],
|
|
47
|
+
]
|
|
46
48
|
] = None,
|
|
47
49
|
context: mlrun.MLClientCtx = None,
|
|
48
50
|
include_default: bool = True,
|
|
@@ -262,7 +264,7 @@ class MetricsLibrary(ABC):
|
|
|
262
264
|
def _to_metric_class(
|
|
263
265
|
cls,
|
|
264
266
|
metric_entry: SKLearnTypes.MetricEntryType,
|
|
265
|
-
metric_name: str = None,
|
|
267
|
+
metric_name: Optional[str] = None,
|
|
266
268
|
) -> Metric:
|
|
267
269
|
"""
|
|
268
270
|
Create a Metric instance from a user given metric entry.
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
#
|
|
15
15
|
from abc import ABC
|
|
16
|
+
from typing import Optional
|
|
16
17
|
|
|
17
18
|
import mlrun
|
|
18
19
|
|
|
@@ -161,8 +162,8 @@ class SKLearnMLRunInterface(MLRunInterface, ABC):
|
|
|
161
162
|
def configure_logging(
|
|
162
163
|
self,
|
|
163
164
|
context: mlrun.MLClientCtx = None,
|
|
164
|
-
plans: list[MLPlan] = None,
|
|
165
|
-
metrics: list[Metric] = None,
|
|
165
|
+
plans: Optional[list[MLPlan]] = None,
|
|
166
|
+
metrics: Optional[list[Metric]] = None,
|
|
166
167
|
x_test: SKLearnTypes.DatasetType = None,
|
|
167
168
|
y_test: SKLearnTypes.DatasetType = None,
|
|
168
169
|
model_handler: MLModelHandler = None,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#
|
|
15
15
|
import os
|
|
16
16
|
import pickle
|
|
17
|
+
from typing import Optional
|
|
17
18
|
|
|
18
19
|
import cloudpickle
|
|
19
20
|
|
|
@@ -49,7 +50,7 @@ class SKLearnModelHandler(MLModelHandler):
|
|
|
49
50
|
)
|
|
50
51
|
|
|
51
52
|
@without_mlrun_interface(interface=SKLearnMLRunInterface)
|
|
52
|
-
def save(self, output_path: str = None, **kwargs):
|
|
53
|
+
def save(self, output_path: Optional[str] = None, **kwargs):
|
|
53
54
|
"""
|
|
54
55
|
Save the handled model at the given output path. If a MLRun context is available, the saved model files will be
|
|
55
56
|
logged and returned as artifacts.
|
|
@@ -81,10 +82,10 @@ class SKLearnModelHandler(MLModelHandler):
|
|
|
81
82
|
|
|
82
83
|
def to_onnx(
|
|
83
84
|
self,
|
|
84
|
-
model_name: str = None,
|
|
85
|
+
model_name: Optional[str] = None,
|
|
85
86
|
optimize: bool = True,
|
|
86
87
|
input_sample: SKLearnTypes.DatasetType = None,
|
|
87
|
-
log: bool = None,
|
|
88
|
+
log: Optional[bool] = None,
|
|
88
89
|
):
|
|
89
90
|
"""
|
|
90
91
|
Convert the model in this handler to an ONNX model. The inputs names are optional, they do not change the
|