mlrun 1.7.0rc23__py3-none-any.whl → 1.7.0rc24__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/common/helpers.py +11 -0
- mlrun/common/schemas/api_gateway.py +57 -16
- mlrun/serving/server.py +4 -0
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.7.0rc23.dist-info → mlrun-1.7.0rc24.dist-info}/METADATA +1 -1
- {mlrun-1.7.0rc23.dist-info → mlrun-1.7.0rc24.dist-info}/RECORD +10 -10
- {mlrun-1.7.0rc23.dist-info → mlrun-1.7.0rc24.dist-info}/LICENSE +0 -0
- {mlrun-1.7.0rc23.dist-info → mlrun-1.7.0rc24.dist-info}/WHEEL +0 -0
- {mlrun-1.7.0rc23.dist-info → mlrun-1.7.0rc24.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.0rc23.dist-info → mlrun-1.7.0rc24.dist-info}/top_level.txt +0 -0
mlrun/common/helpers.py
CHANGED
|
@@ -34,3 +34,14 @@ def parse_versioned_object_uri(
|
|
|
34
34
|
uri = uri[:loc]
|
|
35
35
|
|
|
36
36
|
return project, uri, tag, hash_key
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def generate_api_gateway_name(project: str, name: str) -> str:
|
|
40
|
+
"""
|
|
41
|
+
Generate a unique (within project) api gateway name
|
|
42
|
+
:param project: project name
|
|
43
|
+
:param name: api gateway name
|
|
44
|
+
|
|
45
|
+
:return: the resolved api gateway name
|
|
46
|
+
"""
|
|
47
|
+
return f"{project}-{name}" if project else name
|
|
@@ -17,8 +17,10 @@ from typing import Optional
|
|
|
17
17
|
|
|
18
18
|
import pydantic
|
|
19
19
|
|
|
20
|
+
import mlrun.common.constants as mlrun_constants
|
|
20
21
|
import mlrun.common.types
|
|
21
22
|
from mlrun.common.constants import MLRUN_FUNCTIONS_ANNOTATION
|
|
23
|
+
from mlrun.common.helpers import generate_api_gateway_name
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
class APIGatewayAuthenticationMode(mlrun.common.types.StrEnum):
|
|
@@ -100,7 +102,51 @@ class APIGateway(_APIGatewayBaseModel):
|
|
|
100
102
|
if upstream.nucliofunction.get("name")
|
|
101
103
|
]
|
|
102
104
|
|
|
103
|
-
def
|
|
105
|
+
def enrich_mlrun_names(self):
|
|
106
|
+
self._enrich_api_gateway_mlrun_name()
|
|
107
|
+
self._enrich_mlrun_function_names()
|
|
108
|
+
return self
|
|
109
|
+
|
|
110
|
+
def replace_nuclio_names_with_mlrun_names(self):
|
|
111
|
+
self._replace_nuclio_api_gateway_name_with_mlrun_name()
|
|
112
|
+
self._replace_nuclio_function_names_with_mlrun_names()
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
def _replace_nuclio_function_names_with_mlrun_names(self):
|
|
116
|
+
# replace function names from nuclio names to mlrun names
|
|
117
|
+
# and adds mlrun function URI's to an api gateway annotations
|
|
118
|
+
# so when we then get api gateway entity from nuclio, we are able to get mlrun function names
|
|
119
|
+
mlrun_functions = self.metadata.annotations.get(MLRUN_FUNCTIONS_ANNOTATION)
|
|
120
|
+
if mlrun_functions:
|
|
121
|
+
mlrun_function_uris = (
|
|
122
|
+
mlrun_functions.split("&")
|
|
123
|
+
if "&" in mlrun_functions
|
|
124
|
+
else [mlrun_functions]
|
|
125
|
+
)
|
|
126
|
+
if len(mlrun_function_uris) != len(self.spec.upstreams):
|
|
127
|
+
raise mlrun.errors.MLRunValueError(
|
|
128
|
+
"Error when translating nuclio names to mlrun names in api gateway:"
|
|
129
|
+
" number of functions doesn't match the mlrun functions in annotation"
|
|
130
|
+
)
|
|
131
|
+
for i in range(len(mlrun_function_uris)):
|
|
132
|
+
self.spec.upstreams[i].nucliofunction["name"] = mlrun_function_uris[i]
|
|
133
|
+
return self
|
|
134
|
+
|
|
135
|
+
def _replace_nuclio_api_gateway_name_with_mlrun_name(self):
|
|
136
|
+
# replace api gateway name
|
|
137
|
+
# in Nuclio, api gateways are named as `<project>-<mlrun-api-gateway-name>`
|
|
138
|
+
# remove the project prefix from the name if it exists
|
|
139
|
+
project_name = self.metadata.labels.get(
|
|
140
|
+
mlrun_constants.MLRunInternalLabels.nuclio_project_name
|
|
141
|
+
)
|
|
142
|
+
if project_name and self.spec.name.startswith(f"{project_name}-"):
|
|
143
|
+
self.spec.name = self.spec.name[len(project_name) + 1 :]
|
|
144
|
+
self.metadata.name = self.spec.name
|
|
145
|
+
return self
|
|
146
|
+
|
|
147
|
+
def _enrich_mlrun_function_names(self):
|
|
148
|
+
# enrich mlrun names with nuclio prefixes
|
|
149
|
+
# and add mlrun function's URIs to Nuclio function annotations
|
|
104
150
|
upstream_with_nuclio_names = []
|
|
105
151
|
mlrun_function_uris = []
|
|
106
152
|
for upstream in self.spec.upstreams:
|
|
@@ -126,21 +172,16 @@ class APIGateway(_APIGatewayBaseModel):
|
|
|
126
172
|
)
|
|
127
173
|
return self
|
|
128
174
|
|
|
129
|
-
def
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"Error when translating nuclio names to mlrun names in api gateway:"
|
|
140
|
-
" number of functions doesn't match the mlrun functions in annotation"
|
|
141
|
-
)
|
|
142
|
-
for i in range(len(mlrun_function_uris)):
|
|
143
|
-
self.spec.upstreams[i].nucliofunction["name"] = mlrun_function_uris[i]
|
|
175
|
+
def _enrich_api_gateway_mlrun_name(self):
|
|
176
|
+
# replace api gateway name
|
|
177
|
+
# in Nuclio, api gateways are named as `<project>-<mlrun-api-gateway-name>`
|
|
178
|
+
# add the project prefix to the name
|
|
179
|
+
project_name = self.metadata.labels.get(
|
|
180
|
+
mlrun_constants.MLRunInternalLabels.nuclio_project_name
|
|
181
|
+
)
|
|
182
|
+
if project_name:
|
|
183
|
+
self.spec.name = generate_api_gateway_name(project_name, self.spec.name)
|
|
184
|
+
self.metadata.name = self.spec.name
|
|
144
185
|
return self
|
|
145
186
|
|
|
146
187
|
|
mlrun/serving/server.py
CHANGED
|
@@ -383,6 +383,10 @@ def v2_serving_handler(context, event, get_body=False):
|
|
|
383
383
|
if event.body == b"":
|
|
384
384
|
event.body = None
|
|
385
385
|
|
|
386
|
+
# ML-6065 – workaround for NUC-178
|
|
387
|
+
if hasattr(event, "trigger") and event.trigger.kind in ("kafka", "kafka-cluster"):
|
|
388
|
+
event.path = "/"
|
|
389
|
+
|
|
386
390
|
return context._server.run(event, context, get_body)
|
|
387
391
|
|
|
388
392
|
|
mlrun/utils/version/version.json
CHANGED
|
@@ -21,7 +21,7 @@ mlrun/artifacts/model.py,sha256=ObUkqFMejYOtq0CDFdpYwzwhQ5bsHv0dHTysuVPJnbs,2110
|
|
|
21
21
|
mlrun/artifacts/plots.py,sha256=dS0mHGt1b20tN2JyEH9H5o5I0oMKZkzn3Uz_3Hf4WjU,4813
|
|
22
22
|
mlrun/common/__init__.py,sha256=xY3wHC4TEJgez7qtnn1pQvHosi8-5UJOCtyGBS7FcGE,571
|
|
23
23
|
mlrun/common/constants.py,sha256=glR3bAqDanX6fOOfuM7vJ9GSy-2RVmn1wNtLFeHqjr0,2987
|
|
24
|
-
mlrun/common/helpers.py,sha256=
|
|
24
|
+
mlrun/common/helpers.py,sha256=LRIULbCg8afKkPnzsZ99-B-JPVjcwR1G9vO--1rzRrQ,1387
|
|
25
25
|
mlrun/common/secrets.py,sha256=vc8WV82EZsCB5ENjUkObFOzZP59aZ1w8F82PTnqwBnc,5181
|
|
26
26
|
mlrun/common/types.py,sha256=8BSjewHKuFHIfbwr-UZYu9NVkO6-wvMXwEyYPVAWxLQ,971
|
|
27
27
|
mlrun/common/db/__init__.py,sha256=xY3wHC4TEJgez7qtnn1pQvHosi8-5UJOCtyGBS7FcGE,571
|
|
@@ -37,7 +37,7 @@ mlrun/common/model_monitoring/helpers.py,sha256=1CpxIDQPumFnpUB1eqcvCpLlyPFVeW2s
|
|
|
37
37
|
mlrun/common/runtimes/constants.py,sha256=Rl0Sd8n_L7Imo-uF1LL9CJ5Szi0W1gUm36yrF8PXfSc,10989
|
|
38
38
|
mlrun/common/schemas/__init__.py,sha256=Vg3S4JKA41y43S4nxCYfGOkpAw86sC9tn6BsD5qe_s4,5178
|
|
39
39
|
mlrun/common/schemas/alert.py,sha256=yzXcmrhW8EHb-NxArVSlH0pRPrBLyqpMCTgMCDz4ExM,6644
|
|
40
|
-
mlrun/common/schemas/api_gateway.py,sha256=
|
|
40
|
+
mlrun/common/schemas/api_gateway.py,sha256=QydwqvklisZZu8-cCvGdnhqORwq7Q7cUhY88na57Fh0,6725
|
|
41
41
|
mlrun/common/schemas/artifact.py,sha256=hlKBK3L1Rg4Hv2XSu3u_gxdrsm0NbsaPjIS9cE_Equ4,3247
|
|
42
42
|
mlrun/common/schemas/auth.py,sha256=5c4WSn3KdX1v04ttSQblkF_gyjdjuJSHG7BTCx4_LWM,6336
|
|
43
43
|
mlrun/common/schemas/background_task.py,sha256=2qZxib2qrF_nPZj0ncitCG-2jxz2hg1qj0hFc8eswWQ,1707
|
|
@@ -308,7 +308,7 @@ mlrun/serving/__init__.py,sha256=-SMRV3q_5cGVPDxRslXPU0zGYZIygs0cSj7WKlOJJUc,116
|
|
|
308
308
|
mlrun/serving/merger.py,sha256=PXLn3A21FiLteJHaDSLm5xKNT-80eTTjfHUJnBX1gKY,6116
|
|
309
309
|
mlrun/serving/remote.py,sha256=MrFByphQWmIsKXqw-MOwl2Q1hbtWReYVRKvlcKj9pfw,17980
|
|
310
310
|
mlrun/serving/routers.py,sha256=scvpXD0VmgGRLJb2UqNq0o39ML2_F_SyZ4OXVQhJIOM,55086
|
|
311
|
-
mlrun/serving/server.py,sha256=
|
|
311
|
+
mlrun/serving/server.py,sha256=jQ3ZHijujJgZgbKXsYWJ9qKatbWpuTLz1YgUJ01wsEg,21235
|
|
312
312
|
mlrun/serving/serving_wrapper.py,sha256=R670-S6PX_d5ER6jiHtRvacuPyFzQH0mEf2K0sBIIOM,836
|
|
313
313
|
mlrun/serving/states.py,sha256=n3RPtzwqfQB1o4H80AoVsP5exL3L3i39ONs-CorWGyM,58539
|
|
314
314
|
mlrun/serving/utils.py,sha256=lej7XcUPX1MmHkEOi_0KZRGSpfbmpnE0GK_Sn4zLkHY,4025
|
|
@@ -343,11 +343,11 @@ mlrun/utils/notifications/notification/ipython.py,sha256=ZtVL30B_Ha0VGoo4LxO-voT
|
|
|
343
343
|
mlrun/utils/notifications/notification/slack.py,sha256=EXhIDyhFkwCSzq8trX3TqGHh5ppFKzMxItxM0s0-ukM,6728
|
|
344
344
|
mlrun/utils/notifications/notification/webhook.py,sha256=WgfxX1cpm8n2A-O08pwnsP4tzbxxv_vNUSnyXG4uKts,2752
|
|
345
345
|
mlrun/utils/version/__init__.py,sha256=7kkrB7hEZ3cLXoWj1kPoDwo4MaswsI2JVOBpbKgPAgc,614
|
|
346
|
-
mlrun/utils/version/version.json,sha256=
|
|
346
|
+
mlrun/utils/version/version.json,sha256=eOwXdgA17MTE7ncOR7XaKiORCmVdcrhoB_XIcXc2CZ0,89
|
|
347
347
|
mlrun/utils/version/version.py,sha256=eEW0tqIAkU9Xifxv8Z9_qsYnNhn3YH7NRAfM-pPLt1g,1878
|
|
348
|
-
mlrun-1.7.
|
|
349
|
-
mlrun-1.7.
|
|
350
|
-
mlrun-1.7.
|
|
351
|
-
mlrun-1.7.
|
|
352
|
-
mlrun-1.7.
|
|
353
|
-
mlrun-1.7.
|
|
348
|
+
mlrun-1.7.0rc24.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
349
|
+
mlrun-1.7.0rc24.dist-info/METADATA,sha256=SQgJEbBc_9z9kfYZFk7wM5uV1KPX3leVkWZ3Cg7LsMQ,19237
|
|
350
|
+
mlrun-1.7.0rc24.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
351
|
+
mlrun-1.7.0rc24.dist-info/entry_points.txt,sha256=1Owd16eAclD5pfRCoJpYC2ZJSyGNTtUr0nCELMioMmU,46
|
|
352
|
+
mlrun-1.7.0rc24.dist-info/top_level.txt,sha256=NObLzw3maSF9wVrgSeYBv-fgnHkAJ1kEkh12DLdd5KM,6
|
|
353
|
+
mlrun-1.7.0rc24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|