mlrun 1.3.2rc1__py3-none-any.whl → 1.3.2rc2__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 (93) hide show
  1. mlrun/api/api/deps.py +14 -1
  2. mlrun/api/api/endpoints/frontend_spec.py +0 -2
  3. mlrun/api/api/endpoints/functions.py +15 -27
  4. mlrun/api/api/endpoints/grafana_proxy.py +435 -74
  5. mlrun/api/api/endpoints/healthz.py +5 -18
  6. mlrun/api/api/endpoints/model_endpoints.py +33 -37
  7. mlrun/api/api/utils.py +6 -13
  8. mlrun/api/crud/__init__.py +14 -16
  9. mlrun/api/crud/logs.py +5 -7
  10. mlrun/api/crud/model_monitoring/__init__.py +2 -2
  11. mlrun/api/crud/model_monitoring/model_endpoint_store.py +847 -0
  12. mlrun/api/crud/model_monitoring/model_endpoints.py +105 -328
  13. mlrun/api/crud/pipelines.py +2 -3
  14. mlrun/api/db/sqldb/models/models_mysql.py +52 -19
  15. mlrun/api/db/sqldb/models/models_sqlite.py +52 -19
  16. mlrun/api/db/sqldb/session.py +19 -26
  17. mlrun/api/schemas/__init__.py +2 -0
  18. mlrun/api/schemas/constants.py +0 -13
  19. mlrun/api/schemas/frontend_spec.py +0 -1
  20. mlrun/api/schemas/model_endpoints.py +38 -195
  21. mlrun/api/schemas/schedule.py +2 -2
  22. mlrun/api/utils/clients/log_collector.py +5 -0
  23. mlrun/builder.py +9 -41
  24. mlrun/config.py +1 -76
  25. mlrun/data_types/__init__.py +1 -6
  26. mlrun/data_types/data_types.py +1 -3
  27. mlrun/datastore/__init__.py +2 -9
  28. mlrun/datastore/sources.py +20 -25
  29. mlrun/datastore/store_resources.py +1 -1
  30. mlrun/datastore/targets.py +34 -67
  31. mlrun/datastore/utils.py +4 -26
  32. mlrun/db/base.py +2 -4
  33. mlrun/db/filedb.py +5 -13
  34. mlrun/db/httpdb.py +32 -64
  35. mlrun/db/sqldb.py +2 -4
  36. mlrun/errors.py +0 -5
  37. mlrun/execution.py +0 -2
  38. mlrun/feature_store/api.py +8 -24
  39. mlrun/feature_store/feature_set.py +6 -28
  40. mlrun/feature_store/feature_vector.py +0 -2
  41. mlrun/feature_store/ingestion.py +11 -8
  42. mlrun/feature_store/retrieval/base.py +43 -271
  43. mlrun/feature_store/retrieval/dask_merger.py +153 -55
  44. mlrun/feature_store/retrieval/job.py +3 -12
  45. mlrun/feature_store/retrieval/local_merger.py +130 -48
  46. mlrun/feature_store/retrieval/spark_merger.py +125 -126
  47. mlrun/features.py +2 -7
  48. mlrun/model_monitoring/constants.py +6 -48
  49. mlrun/model_monitoring/helpers.py +35 -118
  50. mlrun/model_monitoring/model_monitoring_batch.py +260 -293
  51. mlrun/model_monitoring/stream_processing_fs.py +253 -220
  52. mlrun/platforms/iguazio.py +0 -33
  53. mlrun/projects/project.py +72 -34
  54. mlrun/runtimes/base.py +0 -5
  55. mlrun/runtimes/daskjob.py +0 -2
  56. mlrun/runtimes/function.py +3 -29
  57. mlrun/runtimes/kubejob.py +15 -39
  58. mlrun/runtimes/local.py +45 -7
  59. mlrun/runtimes/mpijob/abstract.py +0 -2
  60. mlrun/runtimes/mpijob/v1.py +0 -2
  61. mlrun/runtimes/pod.py +0 -2
  62. mlrun/runtimes/remotesparkjob.py +0 -2
  63. mlrun/runtimes/serving.py +0 -6
  64. mlrun/runtimes/sparkjob/abstract.py +2 -39
  65. mlrun/runtimes/sparkjob/spark3job.py +0 -2
  66. mlrun/serving/__init__.py +1 -2
  67. mlrun/serving/routers.py +35 -35
  68. mlrun/serving/server.py +12 -22
  69. mlrun/serving/states.py +30 -162
  70. mlrun/serving/v2_serving.py +10 -13
  71. mlrun/utils/clones.py +1 -1
  72. mlrun/utils/model_monitoring.py +96 -122
  73. mlrun/utils/version/version.json +2 -2
  74. {mlrun-1.3.2rc1.dist-info → mlrun-1.3.2rc2.dist-info}/METADATA +27 -23
  75. {mlrun-1.3.2rc1.dist-info → mlrun-1.3.2rc2.dist-info}/RECORD +79 -92
  76. mlrun/api/crud/model_monitoring/grafana.py +0 -427
  77. mlrun/datastore/spark_udf.py +0 -40
  78. mlrun/model_monitoring/__init__.py +0 -44
  79. mlrun/model_monitoring/common.py +0 -112
  80. mlrun/model_monitoring/model_endpoint.py +0 -141
  81. mlrun/model_monitoring/stores/__init__.py +0 -106
  82. mlrun/model_monitoring/stores/kv_model_endpoint_store.py +0 -448
  83. mlrun/model_monitoring/stores/model_endpoint_store.py +0 -147
  84. mlrun/model_monitoring/stores/models/__init__.py +0 -23
  85. mlrun/model_monitoring/stores/models/base.py +0 -18
  86. mlrun/model_monitoring/stores/models/mysql.py +0 -100
  87. mlrun/model_monitoring/stores/models/sqlite.py +0 -98
  88. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -375
  89. mlrun/utils/db.py +0 -52
  90. {mlrun-1.3.2rc1.dist-info → mlrun-1.3.2rc2.dist-info}/LICENSE +0 -0
  91. {mlrun-1.3.2rc1.dist-info → mlrun-1.3.2rc2.dist-info}/WHEEL +0 -0
  92. {mlrun-1.3.2rc1.dist-info → mlrun-1.3.2rc2.dist-info}/entry_points.txt +0 -0
  93. {mlrun-1.3.2rc1.dist-info → mlrun-1.3.2rc2.dist-info}/top_level.txt +0 -0
@@ -1,147 +0,0 @@
1
- # Copyright 2018 Iguazio
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
-
16
- import typing
17
- from abc import ABC, abstractmethod
18
-
19
-
20
- class ModelEndpointStore(ABC):
21
- """
22
- An abstract class to handle the model endpoint in the DB target.
23
- """
24
-
25
- def __init__(self, project: str):
26
- """
27
- Initialize a new model endpoint target.
28
-
29
- :param project: The name of the project.
30
- """
31
- self.project = project
32
-
33
- @abstractmethod
34
- def write_model_endpoint(self, endpoint: typing.Dict[str, typing.Any]):
35
- """
36
- Create a new endpoint record in the DB table.
37
-
38
- :param endpoint: model endpoint dictionary that will be written into the DB.
39
- """
40
- pass
41
-
42
- @abstractmethod
43
- def update_model_endpoint(
44
- self, endpoint_id: str, attributes: typing.Dict[str, typing.Any]
45
- ):
46
- """
47
- Update a model endpoint record with a given attributes.
48
-
49
- :param endpoint_id: The unique id of the model endpoint.
50
- :param attributes: Dictionary of attributes that will be used for update the model endpoint. Note that the keys
51
- of the attributes dictionary should exist in the DB table.
52
-
53
- """
54
- pass
55
-
56
- @abstractmethod
57
- def delete_model_endpoint(self, endpoint_id: str):
58
- """
59
- Deletes the record of a given model endpoint id.
60
-
61
- :param endpoint_id: The unique id of the model endpoint.
62
- """
63
- pass
64
-
65
- @abstractmethod
66
- def delete_model_endpoints_resources(
67
- self, endpoints: typing.List[typing.Dict[str, typing.Any]]
68
- ):
69
- """
70
- Delete all model endpoints resources.
71
-
72
- :param endpoints: A list of model endpoints flattened dictionaries.
73
-
74
- """
75
- pass
76
-
77
- @abstractmethod
78
- def get_model_endpoint(
79
- self,
80
- endpoint_id: str,
81
- ) -> typing.Dict[str, typing.Any]:
82
- """
83
- Get a single model endpoint record.
84
-
85
- :param endpoint_id: The unique id of the model endpoint.
86
-
87
- :return: A model endpoint record as a dictionary.
88
- """
89
- pass
90
-
91
- @abstractmethod
92
- def list_model_endpoints(
93
- self,
94
- model: str = None,
95
- function: str = None,
96
- labels: typing.List[str] = None,
97
- top_level: bool = None,
98
- uids: typing.List = None,
99
- ) -> typing.List[typing.Dict[str, typing.Any]]:
100
- """
101
- Returns a list of model endpoint dictionaries, supports filtering by model, function, labels or top level.
102
- By default, when no filters are applied, all available model endpoints for the given project will
103
- be listed.
104
-
105
- :param model: The name of the model to filter by.
106
- :param function: The name of the function to filter by.
107
- :param labels: A list of labels to filter by. Label filters work by either filtering a specific value
108
- of a label (i.e. list("key=value")) or by looking for the existence of a given
109
- key (i.e. "key").
110
- :param top_level: If True will return only routers and endpoint that are NOT children of any router.
111
- :param uids: List of model endpoint unique ids to include in the result.
112
-
113
- :return: A list of model endpoint dictionaries.
114
- """
115
- pass
116
-
117
- @abstractmethod
118
- def get_endpoint_real_time_metrics(
119
- self,
120
- endpoint_id: str,
121
- metrics: typing.List[str],
122
- start: str = "now-1h",
123
- end: str = "now",
124
- access_key: str = None,
125
- ) -> typing.Dict[str, typing.List[typing.Tuple[str, float]]]:
126
- """
127
- Getting metrics from the time series DB. There are pre-defined metrics for model endpoints such as
128
- `predictions_per_second` and `latency_avg_5m` but also custom metrics defined by the user.
129
-
130
- :param endpoint_id: The unique id of the model endpoint.
131
- :param metrics: A list of real-time metrics to return for the model endpoint.
132
- :param start: The start time of the metrics. Can be represented by a string containing an RFC 3339
133
- time, a Unix timestamp in milliseconds, a relative time (`'now'` or
134
- `'now-[0-9]+[mhd]'`, where `m` = minutes, `h` = hours, and `'d'` = days), or 0 for the
135
- earliest time.
136
- :param end: The end time of the metrics. Can be represented by a string containing an RFC 3339
137
- time, a Unix timestamp in milliseconds, a relative time (`'now'` or
138
- `'now-[0-9]+[mhd]'`, where `m` = minutes, `h` = hours, and `'d'` = days), or 0 for the
139
- earliest time.
140
- :param access_key: V3IO access key that will be used for generating Frames client object. If not
141
- provided, the access key will be retrieved from the environment variables.
142
-
143
- :return: A dictionary of metrics in which the key is a metric name and the value is a list of tuples that
144
- includes timestamps and the values.
145
- """
146
-
147
- pass
@@ -1,23 +0,0 @@
1
- # Copyright 2018 Iguazio
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
-
16
-
17
- def get_ModelEndpointsTable(connection_string: str = None):
18
- """Return ModelEndpointsTable based on the provided connection string"""
19
- if "mysql:" in connection_string:
20
- from .mysql import ModelEndpointsTable
21
- else:
22
- from .sqlite import ModelEndpointsTable
23
- return ModelEndpointsTable
@@ -1,18 +0,0 @@
1
- # Copyright 2018 Iguazio
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
-
16
- from sqlalchemy.ext.declarative import declarative_base
17
-
18
- Base = declarative_base()
@@ -1,100 +0,0 @@
1
- # Copyright 2018 Iguazio
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
-
16
-
17
- import sqlalchemy.dialects
18
- from sqlalchemy import Boolean, Column, Integer, String, Text
19
-
20
- import mlrun.model_monitoring.constants as model_monitoring_constants
21
- from mlrun.utils.db import BaseModel
22
-
23
- from .base import Base
24
-
25
-
26
- class ModelEndpointsTable(Base, BaseModel):
27
- __tablename__ = model_monitoring_constants.EventFieldType.MODEL_ENDPOINTS
28
-
29
- uid = Column(
30
- model_monitoring_constants.EventFieldType.UID,
31
- String(40),
32
- primary_key=True,
33
- )
34
- state = Column(model_monitoring_constants.EventFieldType.STATE, String(10))
35
- project = Column(model_monitoring_constants.EventFieldType.PROJECT, String(40))
36
- function_uri = Column(
37
- model_monitoring_constants.EventFieldType.FUNCTION_URI,
38
- String(255),
39
- )
40
- model = Column(model_monitoring_constants.EventFieldType.MODEL, String(255))
41
- model_class = Column(
42
- model_monitoring_constants.EventFieldType.MODEL_CLASS,
43
- String(255),
44
- )
45
- labels = Column(model_monitoring_constants.EventFieldType.LABELS, Text)
46
- model_uri = Column(model_monitoring_constants.EventFieldType.MODEL_URI, String(255))
47
- stream_path = Column(model_monitoring_constants.EventFieldType.STREAM_PATH, Text)
48
- algorithm = Column(
49
- model_monitoring_constants.EventFieldType.ALGORITHM,
50
- String(255),
51
- )
52
- active = Column(model_monitoring_constants.EventFieldType.ACTIVE, Boolean)
53
- monitoring_mode = Column(
54
- model_monitoring_constants.EventFieldType.MONITORING_MODE,
55
- String(10),
56
- )
57
- feature_stats = Column(
58
- model_monitoring_constants.EventFieldType.FEATURE_STATS, Text
59
- )
60
- current_stats = Column(
61
- model_monitoring_constants.EventFieldType.CURRENT_STATS, Text
62
- )
63
- feature_names = Column(
64
- model_monitoring_constants.EventFieldType.FEATURE_NAMES, Text
65
- )
66
- children = Column(model_monitoring_constants.EventFieldType.CHILDREN, Text)
67
- label_names = Column(model_monitoring_constants.EventFieldType.LABEL_NAMES, Text)
68
-
69
- endpoint_type = Column(
70
- model_monitoring_constants.EventFieldType.ENDPOINT_TYPE,
71
- String(10),
72
- )
73
- children_uids = Column(
74
- model_monitoring_constants.EventFieldType.CHILDREN_UIDS, Text
75
- )
76
- drift_measures = Column(
77
- model_monitoring_constants.EventFieldType.DRIFT_MEASURES, Text
78
- )
79
- drift_status = Column(
80
- model_monitoring_constants.EventFieldType.DRIFT_STATUS,
81
- String(40),
82
- )
83
- monitor_configuration = Column(
84
- model_monitoring_constants.EventFieldType.MONITOR_CONFIGURATION,
85
- Text,
86
- )
87
- monitoring_feature_set_uri = Column(
88
- model_monitoring_constants.EventFieldType.FEATURE_SET_URI,
89
- String(255),
90
- )
91
- first_request = Column(
92
- model_monitoring_constants.EventFieldType.FIRST_REQUEST,
93
- sqlalchemy.dialects.mysql.TIMESTAMP(fsp=3),
94
- )
95
- last_request = Column(
96
- model_monitoring_constants.EventFieldType.LAST_REQUEST,
97
- sqlalchemy.dialects.mysql.TIMESTAMP(fsp=3),
98
- )
99
- error_count = Column(model_monitoring_constants.EventFieldType.ERROR_COUNT, Integer)
100
- metrics = Column(model_monitoring_constants.EventFieldType.METRICS, Text)
@@ -1,98 +0,0 @@
1
- # Copyright 2018 Iguazio
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
-
16
-
17
- from sqlalchemy import TIMESTAMP, Boolean, Column, Integer, String, Text
18
-
19
- import mlrun.model_monitoring.constants as model_monitoring_constants
20
- from mlrun.utils.db import BaseModel
21
-
22
- from .base import Base
23
-
24
-
25
- class ModelEndpointsTable(Base, BaseModel):
26
- __tablename__ = model_monitoring_constants.EventFieldType.MODEL_ENDPOINTS
27
-
28
- uid = Column(
29
- model_monitoring_constants.EventFieldType.UID,
30
- String(40),
31
- primary_key=True,
32
- )
33
- state = Column(model_monitoring_constants.EventFieldType.STATE, String(10))
34
- project = Column(model_monitoring_constants.EventFieldType.PROJECT, String(40))
35
- function_uri = Column(
36
- model_monitoring_constants.EventFieldType.FUNCTION_URI,
37
- String(255),
38
- )
39
- model = Column(model_monitoring_constants.EventFieldType.MODEL, String(255))
40
- model_class = Column(
41
- model_monitoring_constants.EventFieldType.MODEL_CLASS,
42
- String(255),
43
- )
44
- labels = Column(model_monitoring_constants.EventFieldType.LABELS, Text)
45
- model_uri = Column(model_monitoring_constants.EventFieldType.MODEL_URI, String(255))
46
- stream_path = Column(model_monitoring_constants.EventFieldType.STREAM_PATH, Text)
47
- algorithm = Column(
48
- model_monitoring_constants.EventFieldType.ALGORITHM,
49
- String(255),
50
- )
51
- active = Column(model_monitoring_constants.EventFieldType.ACTIVE, Boolean)
52
- monitoring_mode = Column(
53
- model_monitoring_constants.EventFieldType.MONITORING_MODE,
54
- String(10),
55
- )
56
- feature_stats = Column(
57
- model_monitoring_constants.EventFieldType.FEATURE_STATS, Text
58
- )
59
- current_stats = Column(
60
- model_monitoring_constants.EventFieldType.CURRENT_STATS, Text
61
- )
62
- feature_names = Column(
63
- model_monitoring_constants.EventFieldType.FEATURE_NAMES, Text
64
- )
65
- children = Column(model_monitoring_constants.EventFieldType.CHILDREN, Text)
66
- label_names = Column(model_monitoring_constants.EventFieldType.LABEL_NAMES, Text)
67
- endpoint_type = Column(
68
- model_monitoring_constants.EventFieldType.ENDPOINT_TYPE,
69
- String(10),
70
- )
71
- children_uids = Column(
72
- model_monitoring_constants.EventFieldType.CHILDREN_UIDS, Text
73
- )
74
- drift_measures = Column(
75
- model_monitoring_constants.EventFieldType.DRIFT_MEASURES, Text
76
- )
77
- drift_status = Column(
78
- model_monitoring_constants.EventFieldType.DRIFT_STATUS,
79
- String(40),
80
- )
81
- monitor_configuration = Column(
82
- model_monitoring_constants.EventFieldType.MONITOR_CONFIGURATION,
83
- Text,
84
- )
85
- monitoring_feature_set_uri = Column(
86
- model_monitoring_constants.EventFieldType.FEATURE_SET_URI,
87
- String(255),
88
- )
89
- first_request = Column(
90
- model_monitoring_constants.EventFieldType.FIRST_REQUEST,
91
- TIMESTAMP,
92
- )
93
- last_request = Column(
94
- model_monitoring_constants.EventFieldType.LAST_REQUEST,
95
- TIMESTAMP,
96
- )
97
- error_count = Column(model_monitoring_constants.EventFieldType.ERROR_COUNT, Integer)
98
- metrics = Column(model_monitoring_constants.EventFieldType.METRICS, Text)