mlrun 1.7.0rc6__py3-none-any.whl → 1.7.0rc8__py3-none-any.whl

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

Potentially problematic release.


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

Files changed (70) hide show
  1. mlrun/__main__.py +2 -0
  2. mlrun/common/constants.py +6 -0
  3. mlrun/common/schemas/__init__.py +3 -0
  4. mlrun/common/schemas/api_gateway.py +8 -1
  5. mlrun/common/schemas/model_monitoring/__init__.py +4 -0
  6. mlrun/common/schemas/model_monitoring/constants.py +35 -18
  7. mlrun/common/schemas/project.py +1 -0
  8. mlrun/common/types.py +7 -1
  9. mlrun/config.py +34 -10
  10. mlrun/data_types/data_types.py +4 -0
  11. mlrun/datastore/alibaba_oss.py +130 -0
  12. mlrun/datastore/azure_blob.py +4 -5
  13. mlrun/datastore/base.py +22 -16
  14. mlrun/datastore/datastore.py +4 -0
  15. mlrun/datastore/datastore_profile.py +7 -0
  16. mlrun/datastore/google_cloud_storage.py +1 -1
  17. mlrun/datastore/sources.py +2 -3
  18. mlrun/datastore/targets.py +6 -1
  19. mlrun/db/base.py +14 -6
  20. mlrun/db/httpdb.py +61 -56
  21. mlrun/db/nopdb.py +3 -0
  22. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +6 -1
  23. mlrun/frameworks/tf_keras/mlrun_interface.py +20 -8
  24. mlrun/kfpops.py +2 -5
  25. mlrun/model.py +1 -0
  26. mlrun/model_monitoring/__init__.py +1 -1
  27. mlrun/model_monitoring/api.py +104 -295
  28. mlrun/model_monitoring/controller.py +25 -25
  29. mlrun/model_monitoring/db/__init__.py +16 -0
  30. mlrun/model_monitoring/{stores → db/stores}/__init__.py +43 -34
  31. mlrun/model_monitoring/db/stores/base/__init__.py +15 -0
  32. mlrun/model_monitoring/{stores/model_endpoint_store.py → db/stores/base/store.py} +47 -6
  33. mlrun/model_monitoring/db/stores/sqldb/__init__.py +13 -0
  34. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +49 -0
  35. mlrun/model_monitoring/{stores → db/stores/sqldb}/models/base.py +76 -3
  36. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +68 -0
  37. mlrun/model_monitoring/{stores → db/stores/sqldb}/models/sqlite.py +13 -1
  38. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +662 -0
  39. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +13 -0
  40. mlrun/model_monitoring/{stores/kv_model_endpoint_store.py → db/stores/v3io_kv/kv_store.py} +134 -3
  41. mlrun/model_monitoring/helpers.py +3 -3
  42. mlrun/model_monitoring/stream_processing.py +41 -9
  43. mlrun/model_monitoring/tracking_policy.py +7 -1
  44. mlrun/model_monitoring/writer.py +4 -36
  45. mlrun/projects/pipelines.py +14 -2
  46. mlrun/projects/project.py +118 -103
  47. mlrun/run.py +5 -1
  48. mlrun/runtimes/base.py +6 -0
  49. mlrun/runtimes/nuclio/api_gateway.py +218 -65
  50. mlrun/runtimes/nuclio/function.py +3 -0
  51. mlrun/runtimes/nuclio/serving.py +28 -32
  52. mlrun/runtimes/pod.py +26 -0
  53. mlrun/serving/routers.py +4 -3
  54. mlrun/serving/server.py +4 -6
  55. mlrun/serving/states.py +34 -14
  56. mlrun/serving/v2_serving.py +4 -3
  57. mlrun/utils/helpers.py +34 -0
  58. mlrun/utils/http.py +1 -1
  59. mlrun/utils/retryer.py +1 -0
  60. mlrun/utils/version/version.json +2 -2
  61. {mlrun-1.7.0rc6.dist-info → mlrun-1.7.0rc8.dist-info}/METADATA +25 -16
  62. {mlrun-1.7.0rc6.dist-info → mlrun-1.7.0rc8.dist-info}/RECORD +66 -62
  63. mlrun/model_monitoring/batch.py +0 -933
  64. mlrun/model_monitoring/stores/models/__init__.py +0 -27
  65. mlrun/model_monitoring/stores/models/mysql.py +0 -34
  66. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -382
  67. {mlrun-1.7.0rc6.dist-info → mlrun-1.7.0rc8.dist-info}/LICENSE +0 -0
  68. {mlrun-1.7.0rc6.dist-info → mlrun-1.7.0rc8.dist-info}/WHEEL +0 -0
  69. {mlrun-1.7.0rc6.dist-info → mlrun-1.7.0rc8.dist-info}/entry_points.txt +0 -0
  70. {mlrun-1.7.0rc6.dist-info → mlrun-1.7.0rc8.dist-info}/top_level.txt +0 -0
mlrun/db/base.py CHANGED
@@ -17,7 +17,7 @@ from abc import ABC, abstractmethod
17
17
  from typing import Optional, Union
18
18
 
19
19
  import mlrun.common.schemas
20
- import mlrun.model_monitoring.model_endpoint
20
+ import mlrun.model_monitoring
21
21
 
22
22
 
23
23
  class RunDBError(Exception):
@@ -509,9 +509,7 @@ class RunDBInterface(ABC):
509
509
  self,
510
510
  project: str,
511
511
  endpoint_id: str,
512
- model_endpoint: Union[
513
- mlrun.model_monitoring.model_endpoint.ModelEndpoint, dict
514
- ],
512
+ model_endpoint: Union[mlrun.model_monitoring.ModelEndpoint, dict],
515
513
  ):
516
514
  pass
517
515
 
@@ -632,6 +630,10 @@ class RunDBInterface(ABC):
632
630
  def get_api_gateway(self, name, project=None) -> mlrun.common.schemas.APIGateway:
633
631
  pass
634
632
 
633
+ @abstractmethod
634
+ def delete_api_gateway(self, name, project=None):
635
+ pass
636
+
635
637
  def get_builder_status(
636
638
  self,
637
639
  func: "mlrun.runtimes.BaseRuntime",
@@ -724,5 +726,11 @@ class RunDBInterface(ABC):
724
726
  project: str,
725
727
  base_period: int = 10,
726
728
  image: str = "mlrun/mlrun",
727
- ):
728
- pass
729
+ deploy_histogram_data_drift_app: bool = True,
730
+ ) -> None:
731
+ raise NotImplementedError
732
+
733
+ def deploy_histogram_data_drift_app(
734
+ self, project: str, image: str = "mlrun/mlrun"
735
+ ) -> None:
736
+ raise NotImplementedError
mlrun/db/httpdb.py CHANGED
@@ -11,6 +11,7 @@
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
+
14
15
  import enum
15
16
  import http
16
17
  import re
@@ -30,10 +31,12 @@ import semver
30
31
 
31
32
  import mlrun
32
33
  import mlrun.common.schemas
34
+ import mlrun.common.types
33
35
  import mlrun.model_monitoring.model_endpoint
34
36
  import mlrun.platforms
35
37
  import mlrun.projects
36
38
  import mlrun.runtimes.nuclio.api_gateway
39
+ import mlrun.utils
37
40
  from mlrun.errors import MLRunInvalidArgumentError, err_to_str
38
41
 
39
42
  from ..artifacts import Artifact
@@ -180,7 +183,7 @@ class HTTPRunDB(RunDBInterface):
180
183
  headers=None,
181
184
  timeout=45,
182
185
  version=None,
183
- ):
186
+ ) -> requests.Response:
184
187
  """Perform a direct REST API call on the :py:mod:`mlrun` API server.
185
188
 
186
189
  Caution:
@@ -198,7 +201,7 @@ class HTTPRunDB(RunDBInterface):
198
201
  :param version: API version to use, None (the default) will mean to use the default value from config,
199
202
  for un-versioned api set an empty string.
200
203
 
201
- :return: Python HTTP response object
204
+ :return: `requests.Response` HTTP response object
202
205
  """
203
206
  url = self.get_base_api_url(path, version)
204
207
  kw = {
@@ -1616,19 +1619,21 @@ class HTTPRunDB(RunDBInterface):
1616
1619
  artifact_path=None,
1617
1620
  ops=None,
1618
1621
  cleanup_ttl=None,
1622
+ timeout=60,
1619
1623
  ):
1620
1624
  """Submit a KFP pipeline for execution.
1621
1625
 
1622
- :param project: The project of the pipeline
1623
- :param pipeline: Pipeline function or path to .yaml/.zip pipeline file.
1624
- :param arguments: A dictionary of arguments to pass to the pipeline.
1625
- :param experiment: A name to assign for the specific experiment.
1626
- :param run: A name for this specific run.
1627
- :param namespace: Kubernetes namespace to execute the pipeline in.
1628
- :param artifact_path: A path to artifacts used by this pipeline.
1629
- :param ops: Transformers to apply on all ops in the pipeline.
1630
- :param cleanup_ttl: pipeline cleanup ttl in secs (time to wait after workflow completion, at which point the
1631
- workflow and all its resources are deleted)
1626
+ :param project: The project of the pipeline
1627
+ :param pipeline: Pipeline function or path to .yaml/.zip pipeline file.
1628
+ :param arguments: A dictionary of arguments to pass to the pipeline.
1629
+ :param experiment: A name to assign for the specific experiment.
1630
+ :param run: A name for this specific run.
1631
+ :param namespace: Kubernetes namespace to execute the pipeline in.
1632
+ :param artifact_path: A path to artifacts used by this pipeline.
1633
+ :param ops: Transformers to apply on all ops in the pipeline.
1634
+ :param cleanup_ttl: Pipeline cleanup ttl in secs (time to wait after workflow completion, at which point the
1635
+ workflow and all its resources are deleted)
1636
+ :param timeout: Timeout for the API call.
1632
1637
  """
1633
1638
 
1634
1639
  if isinstance(pipeline, str):
@@ -1670,7 +1675,7 @@ class HTTPRunDB(RunDBInterface):
1670
1675
  "POST",
1671
1676
  f"projects/{project}/pipelines",
1672
1677
  params=params,
1673
- timeout=20,
1678
+ timeout=timeout,
1674
1679
  body=data,
1675
1680
  headers=headers,
1676
1681
  )
@@ -3050,35 +3055,6 @@ class HTTPRunDB(RunDBInterface):
3050
3055
  params=attributes,
3051
3056
  )
3052
3057
 
3053
- def deploy_monitoring_batch_job(
3054
- self,
3055
- project: str = "",
3056
- default_batch_image: str = "mlrun/mlrun",
3057
- with_schedule: bool = False,
3058
- ):
3059
- """
3060
- Submit model monitoring batch job. By default, submit only the batch job as ML function without scheduling.
3061
- To submit a scheduled job as well, please set with_schedule = True.
3062
-
3063
- :param project: Project name.
3064
- :param default_batch_image: The default image of the model monitoring batch job. By default, the image
3065
- is mlrun/mlrun.
3066
- :param with_schedule: If true, submit the model monitoring scheduled job as well.
3067
-
3068
-
3069
- :returns: model monitoring batch job as a dictionary. You can easily convert the returned function into a
3070
- runtime object by calling ~mlrun.new_function.
3071
- """
3072
-
3073
- params = {
3074
- "default_batch_image": default_batch_image,
3075
- "with_schedule": with_schedule,
3076
- }
3077
- path = f"projects/{project}/jobs/batch-monitoring"
3078
-
3079
- resp = self.api_call(method="POST", path=path, params=params)
3080
- return resp.json()["func"]
3081
-
3082
3058
  def update_model_monitoring_controller(
3083
3059
  self,
3084
3060
  project: str,
@@ -3107,7 +3083,8 @@ class HTTPRunDB(RunDBInterface):
3107
3083
  project: str,
3108
3084
  base_period: int = 10,
3109
3085
  image: str = "mlrun/mlrun",
3110
- ):
3086
+ deploy_histogram_data_drift_app: bool = True,
3087
+ ) -> None:
3111
3088
  """
3112
3089
  Deploy model monitoring application controller, writer and stream functions.
3113
3090
  While the main goal of the controller function is to handle the monitoring processing and triggering
@@ -3116,21 +3093,38 @@ class HTTPRunDB(RunDBInterface):
3116
3093
  The stream function goal is to monitor the log of the data stream. It is triggered when a new log entry
3117
3094
  is detected. It processes the new events into statistics that are then written to statistics databases.
3118
3095
 
3096
+ :param project: Project name.
3097
+ :param base_period: The time period in minutes in which the model monitoring controller function
3098
+ triggers. By default, the base period is 10 minutes.
3099
+ :param image: The image of the model monitoring controller, writer & monitoring
3100
+ stream functions, which are real time nuclio functions.
3101
+ By default, the image is mlrun/mlrun.
3102
+ :param deploy_histogram_data_drift_app: If true, deploy the default histogram-based data drift application.
3103
+ """
3104
+ self.api_call(
3105
+ method=mlrun.common.types.HTTPMethod.POST,
3106
+ path=f"projects/{project}/model-monitoring/enable-model-monitoring",
3107
+ params={
3108
+ "base_period": base_period,
3109
+ "image": image,
3110
+ "deploy_histogram_data_drift_app": deploy_histogram_data_drift_app,
3111
+ },
3112
+ )
3119
3113
 
3120
- :param project: Project name.
3121
- :param base_period: The time period in minutes in which the model monitoring controller function
3122
- triggers. By default, the base period is 10 minutes.
3123
- :param image: The image of the model monitoring controller, writer & monitoring
3124
- stream functions, which are real time nuclio functions.
3125
- By default, the image is mlrun/mlrun.
3114
+ def deploy_histogram_data_drift_app(
3115
+ self, project: str, image: str = "mlrun/mlrun"
3116
+ ) -> None:
3126
3117
  """
3118
+ Deploy the histogram data drift application.
3127
3119
 
3128
- params = {
3129
- "base_period": base_period,
3130
- "image": image,
3131
- }
3132
- path = f"projects/{project}/model-monitoring/enable-model-monitoring"
3133
- self.api_call(method="POST", path=path, params=params)
3120
+ :param project: Project name.
3121
+ :param image: The image on which the application will run.
3122
+ """
3123
+ self.api_call(
3124
+ method=mlrun.common.types.HTTPMethod.POST,
3125
+ path=f"projects/{project}/model-monitoring/deploy-histogram-data-drift-app",
3126
+ params={"image": image},
3127
+ )
3134
3128
 
3135
3129
  def create_hub_source(
3136
3130
  self, source: Union[dict, mlrun.common.schemas.IndexedHubSource]
@@ -3397,6 +3391,17 @@ class HTTPRunDB(RunDBInterface):
3397
3391
  response = self.api_call("GET", endpoint_path, error)
3398
3392
  return mlrun.common.schemas.APIGateway(**response.json())
3399
3393
 
3394
+ def delete_api_gateway(self, name, project=None):
3395
+ """
3396
+ Deletes an API gateway
3397
+ :param name: API gateway name
3398
+ :param project: Project name
3399
+ """
3400
+ project = project or config.default_project
3401
+ error = "delete api gateway"
3402
+ endpoint_path = f"projects/{project}/api-gateways/{name}"
3403
+ self.api_call("DELETE", endpoint_path, error)
3404
+
3400
3405
  def store_api_gateway(
3401
3406
  self,
3402
3407
  api_gateway: Union[
@@ -3422,7 +3427,7 @@ class HTTPRunDB(RunDBInterface):
3422
3427
  "PUT",
3423
3428
  endpoint_path,
3424
3429
  error,
3425
- json=api_gateway.dict(exclude_unset=True, exclude_none=True),
3430
+ json=api_gateway.dict(exclude_none=True),
3426
3431
  )
3427
3432
  return mlrun.common.schemas.APIGateway(**response.json())
3428
3433
 
mlrun/db/nopdb.py CHANGED
@@ -519,6 +519,9 @@ class NopDB(RunDBInterface):
519
519
  def get_api_gateway(self, name, project=None):
520
520
  pass
521
521
 
522
+ def delete_api_gateway(self, name, project=None):
523
+ pass
524
+
522
525
  def verify_authorization(
523
526
  self,
524
527
  authorization_verification_input: mlrun.common.schemas.AuthorizationVerificationInput,
@@ -15,9 +15,14 @@
15
15
  from typing import Callable, Union
16
16
 
17
17
  import numpy as np
18
+ import semver
18
19
  import tensorflow as tf
19
20
  from tensorflow import Tensor, Variable
20
- from tensorflow.keras.callbacks import Callback
21
+
22
+ if semver.VersionInfo.parse(tf.__version__) < semver.VersionInfo(2, 6):
23
+ from tensorflow.keras.callbacks import Callback
24
+ else:
25
+ from keras.callbacks import Callback
21
26
 
22
27
  import mlrun
23
28
 
@@ -17,18 +17,30 @@ import os
17
17
  from abc import ABC
18
18
  from typing import Union
19
19
 
20
+ import semver
20
21
  import tensorflow as tf
21
22
  from tensorflow import keras
22
- from tensorflow.keras.callbacks import (
23
- BaseLogger,
24
- Callback,
25
- CSVLogger,
26
- ModelCheckpoint,
27
- ProgbarLogger,
28
- TensorBoard,
29
- )
30
23
  from tensorflow.keras.optimizers import Optimizer
31
24
 
25
+ if semver.VersionInfo.parse(tf.__version__) < semver.VersionInfo(2, 6):
26
+ from tensorflow.keras.callbacks import (
27
+ BaseLogger,
28
+ Callback,
29
+ CSVLogger,
30
+ ModelCheckpoint,
31
+ ProgbarLogger,
32
+ TensorBoard,
33
+ )
34
+ else:
35
+ from keras.callbacks import (
36
+ BaseLogger,
37
+ Callback,
38
+ CSVLogger,
39
+ ModelCheckpoint,
40
+ ProgbarLogger,
41
+ TensorBoard,
42
+ )
43
+
32
44
  import mlrun
33
45
 
34
46
  from .._common import MLRunInterface
mlrun/kfpops.py CHANGED
@@ -103,7 +103,7 @@ def write_kfpmeta(struct):
103
103
  with open(path, "w") as fp:
104
104
  fp.write(str(val))
105
105
  except Exception as exc:
106
- logger.warning("Failed writing to temp file. Ignoring", exc=repr(exc))
106
+ logger.warning("Failed writing to temp file. Ignoring", exc=err_to_str(exc))
107
107
  pass
108
108
 
109
109
  text = "# Run Report\n"
@@ -112,10 +112,7 @@ def write_kfpmeta(struct):
112
112
 
113
113
  text += "## Metadata\n```yaml\n" + dict_to_yaml(struct) + "```\n"
114
114
 
115
- metadata = {
116
- "outputs": output_artifacts
117
- + [{"type": "markdown", "storage": "inline", "source": text}]
118
- }
115
+ metadata = {"outputs": [{"type": "markdown", "storage": "inline", "source": text}]}
119
116
  with open(os.path.join(KFPMETA_DIR, "mlpipeline-ui-metadata.json"), "w") as f:
120
117
  json.dump(metadata, f)
121
118
 
mlrun/model.py CHANGED
@@ -71,6 +71,7 @@ class ModelObj:
71
71
  return new_type.from_dict(param)
72
72
  return param
73
73
 
74
+ @mlrun.utils.filter_warnings("ignore", FutureWarning)
74
75
  def to_dict(
75
76
  self, fields: list = None, exclude: list = None, strip: bool = False
76
77
  ) -> dict:
@@ -15,7 +15,7 @@
15
15
  # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
16
  # for backwards compatibility
17
17
 
18
+ from .db import get_store_object
18
19
  from .helpers import get_stream_path
19
20
  from .model_endpoint import ModelEndpoint
20
- from .stores import ModelEndpointStore, ModelEndpointStoreType, get_model_endpoint_store
21
21
  from .tracking_policy import TrackingPolicy