mlrun 1.10.0rc6__py3-none-any.whl → 1.10.0rc7__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/__main__.py +47 -4
- mlrun/artifacts/base.py +0 -27
- mlrun/artifacts/dataset.py +0 -8
- mlrun/artifacts/model.py +0 -7
- mlrun/artifacts/plots.py +0 -13
- mlrun/db/base.py +0 -20
- mlrun/db/httpdb.py +1 -65
- mlrun/db/nopdb.py +0 -13
- mlrun/launcher/base.py +1 -0
- mlrun/launcher/client.py +1 -0
- mlrun/launcher/local.py +4 -0
- mlrun/model_monitoring/applications/_application_steps.py +23 -39
- mlrun/model_monitoring/applications/base.py +167 -32
- mlrun/model_monitoring/helpers.py +0 -3
- mlrun/projects/operations.py +11 -24
- mlrun/projects/project.py +41 -82
- mlrun/runtimes/daskjob.py +2 -0
- mlrun/runtimes/kubejob.py +5 -8
- mlrun/runtimes/mpijob/abstract.py +2 -0
- mlrun/runtimes/mpijob/v1.py +2 -0
- mlrun/runtimes/nuclio/function.py +2 -0
- mlrun/runtimes/nuclio/serving.py +46 -0
- mlrun/runtimes/pod.py +3 -0
- mlrun/runtimes/remotesparkjob.py +2 -0
- mlrun/runtimes/sparkjob/spark3job.py +2 -0
- mlrun/serving/server.py +97 -3
- mlrun/utils/helpers.py +0 -4
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.10.0rc6.dist-info → mlrun-1.10.0rc7.dist-info}/METADATA +2 -2
- {mlrun-1.10.0rc6.dist-info → mlrun-1.10.0rc7.dist-info}/RECORD +34 -34
- {mlrun-1.10.0rc6.dist-info → mlrun-1.10.0rc7.dist-info}/WHEEL +0 -0
- {mlrun-1.10.0rc6.dist-info → mlrun-1.10.0rc7.dist-info}/entry_points.txt +0 -0
- {mlrun-1.10.0rc6.dist-info → mlrun-1.10.0rc7.dist-info}/licenses/LICENSE +0 -0
- {mlrun-1.10.0rc6.dist-info → mlrun-1.10.0rc7.dist-info}/top_level.txt +0 -0
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import json
|
|
15
16
|
import socket
|
|
16
17
|
from abc import ABC, abstractmethod
|
|
18
|
+
from collections import defaultdict
|
|
17
19
|
from collections.abc import Iterator
|
|
20
|
+
from contextlib import contextmanager
|
|
18
21
|
from datetime import datetime, timedelta
|
|
19
22
|
from typing import Any, Optional, Union, cast
|
|
20
23
|
|
|
@@ -23,14 +26,58 @@ import pandas as pd
|
|
|
23
26
|
import mlrun
|
|
24
27
|
import mlrun.common.constants as mlrun_constants
|
|
25
28
|
import mlrun.common.schemas.model_monitoring.constants as mm_constants
|
|
29
|
+
import mlrun.datastore.datastore_profile as ds_profile
|
|
26
30
|
import mlrun.errors
|
|
27
31
|
import mlrun.model_monitoring.api as mm_api
|
|
28
32
|
import mlrun.model_monitoring.applications.context as mm_context
|
|
29
33
|
import mlrun.model_monitoring.applications.results as mm_results
|
|
34
|
+
import mlrun.model_monitoring.helpers as mm_helpers
|
|
30
35
|
from mlrun.serving.utils import MonitoringApplicationToDict
|
|
31
36
|
from mlrun.utils import logger
|
|
32
37
|
|
|
33
38
|
|
|
39
|
+
def _serialize_context_and_result(
|
|
40
|
+
*,
|
|
41
|
+
context: mm_context.MonitoringApplicationContext,
|
|
42
|
+
result: Union[
|
|
43
|
+
mm_results.ModelMonitoringApplicationResult,
|
|
44
|
+
mm_results.ModelMonitoringApplicationMetric,
|
|
45
|
+
mm_results._ModelMonitoringApplicationStats,
|
|
46
|
+
],
|
|
47
|
+
) -> dict[mm_constants.WriterEvent, str]:
|
|
48
|
+
"""
|
|
49
|
+
Serialize the returned result from a model monitoring application and its context
|
|
50
|
+
for the writer.
|
|
51
|
+
"""
|
|
52
|
+
writer_event = {
|
|
53
|
+
mm_constants.WriterEvent.ENDPOINT_NAME: context.endpoint_name,
|
|
54
|
+
mm_constants.WriterEvent.APPLICATION_NAME: context.application_name,
|
|
55
|
+
mm_constants.WriterEvent.ENDPOINT_ID: context.endpoint_id,
|
|
56
|
+
mm_constants.WriterEvent.START_INFER_TIME: context.start_infer_time.isoformat(
|
|
57
|
+
sep=" ", timespec="microseconds"
|
|
58
|
+
),
|
|
59
|
+
mm_constants.WriterEvent.END_INFER_TIME: context.end_infer_time.isoformat(
|
|
60
|
+
sep=" ", timespec="microseconds"
|
|
61
|
+
),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if isinstance(result, mm_results.ModelMonitoringApplicationResult):
|
|
65
|
+
writer_event[mm_constants.WriterEvent.EVENT_KIND] = (
|
|
66
|
+
mm_constants.WriterEventKind.RESULT
|
|
67
|
+
)
|
|
68
|
+
elif isinstance(result, mm_results._ModelMonitoringApplicationStats):
|
|
69
|
+
writer_event[mm_constants.WriterEvent.EVENT_KIND] = (
|
|
70
|
+
mm_constants.WriterEventKind.STATS
|
|
71
|
+
)
|
|
72
|
+
else:
|
|
73
|
+
writer_event[mm_constants.WriterEvent.EVENT_KIND] = (
|
|
74
|
+
mm_constants.WriterEventKind.METRIC
|
|
75
|
+
)
|
|
76
|
+
writer_event[mm_constants.WriterEvent.DATA] = json.dumps(result.to_dict())
|
|
77
|
+
|
|
78
|
+
return writer_event
|
|
79
|
+
|
|
80
|
+
|
|
34
81
|
class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
35
82
|
"""
|
|
36
83
|
The base class for a model monitoring application.
|
|
@@ -118,6 +165,43 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
|
118
165
|
]
|
|
119
166
|
return result
|
|
120
167
|
|
|
168
|
+
@staticmethod
|
|
169
|
+
@contextmanager
|
|
170
|
+
def _push_to_writer(
|
|
171
|
+
*,
|
|
172
|
+
write_output: bool,
|
|
173
|
+
stream_profile: Optional[ds_profile.DatastoreProfile],
|
|
174
|
+
) -> Iterator[dict[str, list[tuple]]]:
|
|
175
|
+
endpoints_output: dict[str, list[tuple]] = defaultdict(list)
|
|
176
|
+
try:
|
|
177
|
+
yield endpoints_output
|
|
178
|
+
finally:
|
|
179
|
+
if write_output:
|
|
180
|
+
logger.debug(
|
|
181
|
+
"Pushing model monitoring application job data to the writer stream",
|
|
182
|
+
passed_stream_profile=str(stream_profile),
|
|
183
|
+
)
|
|
184
|
+
project_name = (
|
|
185
|
+
mlrun.mlconf.active_project or mlrun.get_current_project().name
|
|
186
|
+
)
|
|
187
|
+
writer_stream = mm_helpers.get_output_stream(
|
|
188
|
+
project=project_name,
|
|
189
|
+
function_name=mm_constants.MonitoringFunctionNames.WRITER,
|
|
190
|
+
profile=stream_profile,
|
|
191
|
+
)
|
|
192
|
+
for endpoint_id, outputs in endpoints_output.items():
|
|
193
|
+
writer_stream.push(
|
|
194
|
+
[
|
|
195
|
+
_serialize_context_and_result(context=ctx, result=res)
|
|
196
|
+
for ctx, res in outputs
|
|
197
|
+
],
|
|
198
|
+
partition_key=endpoint_id,
|
|
199
|
+
)
|
|
200
|
+
logger.debug(
|
|
201
|
+
"Pushed the data to all the relevant model endpoints successfully",
|
|
202
|
+
endpoints_output=endpoints_output,
|
|
203
|
+
)
|
|
204
|
+
|
|
121
205
|
def _handler(
|
|
122
206
|
self,
|
|
123
207
|
context: "mlrun.MLClientCtx",
|
|
@@ -127,6 +211,8 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
|
127
211
|
start: Optional[str] = None,
|
|
128
212
|
end: Optional[str] = None,
|
|
129
213
|
base_period: Optional[int] = None,
|
|
214
|
+
write_output: bool = False,
|
|
215
|
+
stream_profile: Optional[ds_profile.DatastoreProfile] = None,
|
|
130
216
|
):
|
|
131
217
|
"""
|
|
132
218
|
A custom handler that wraps the application's logic implemented in
|
|
@@ -134,46 +220,69 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
|
134
220
|
for an MLRun job.
|
|
135
221
|
This method should not be called directly.
|
|
136
222
|
"""
|
|
223
|
+
|
|
224
|
+
if write_output and (
|
|
225
|
+
not endpoints or sample_data is not None or reference_data is not None
|
|
226
|
+
):
|
|
227
|
+
raise mlrun.errors.MLRunValueError(
|
|
228
|
+
"Writing the results of an application to the TSDB is possible only when "
|
|
229
|
+
"working with endpoints, without any custom data-frame input"
|
|
230
|
+
)
|
|
231
|
+
|
|
137
232
|
feature_stats = (
|
|
138
233
|
mm_api.get_sample_set_statistics(reference_data)
|
|
139
234
|
if reference_data is not None
|
|
140
235
|
else None
|
|
141
236
|
)
|
|
142
237
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
for endpoint_name, endpoint_id in endpoints:
|
|
160
|
-
result = call_do_tracking(
|
|
161
|
-
event={
|
|
162
|
-
mm_constants.ApplicationEvent.ENDPOINT_NAME: endpoint_name,
|
|
163
|
-
mm_constants.ApplicationEvent.ENDPOINT_ID: endpoint_id,
|
|
164
|
-
mm_constants.ApplicationEvent.START_INFER_TIME: window_start,
|
|
165
|
-
mm_constants.ApplicationEvent.END_INFER_TIME: window_end,
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
result_key = (
|
|
169
|
-
f"{endpoint_name}-{endpoint_id}_{window_start.isoformat()}_{window_end.isoformat()}"
|
|
170
|
-
if window_start and window_end
|
|
171
|
-
else f"{endpoint_name}-{endpoint_id}"
|
|
238
|
+
with self._push_to_writer(
|
|
239
|
+
write_output=write_output, stream_profile=stream_profile
|
|
240
|
+
) as endpoints_output:
|
|
241
|
+
|
|
242
|
+
def call_do_tracking(event: Optional[dict] = None):
|
|
243
|
+
nonlocal endpoints_output
|
|
244
|
+
|
|
245
|
+
if event is None:
|
|
246
|
+
event = {}
|
|
247
|
+
monitoring_context = (
|
|
248
|
+
mm_context.MonitoringApplicationContext._from_ml_ctx(
|
|
249
|
+
event=event,
|
|
250
|
+
application_name=self.__class__.__name__,
|
|
251
|
+
context=context,
|
|
252
|
+
sample_df=sample_data,
|
|
253
|
+
feature_stats=feature_stats,
|
|
172
254
|
)
|
|
255
|
+
)
|
|
256
|
+
result = self.do_tracking(monitoring_context)
|
|
257
|
+
endpoints_output[monitoring_context.endpoint_id].append(
|
|
258
|
+
(monitoring_context, result)
|
|
259
|
+
)
|
|
260
|
+
return result
|
|
261
|
+
|
|
262
|
+
if endpoints is not None:
|
|
263
|
+
for window_start, window_end in self._window_generator(
|
|
264
|
+
start, end, base_period
|
|
265
|
+
):
|
|
266
|
+
for endpoint_name, endpoint_id in endpoints:
|
|
267
|
+
result = call_do_tracking(
|
|
268
|
+
event={
|
|
269
|
+
mm_constants.ApplicationEvent.ENDPOINT_NAME: endpoint_name,
|
|
270
|
+
mm_constants.ApplicationEvent.ENDPOINT_ID: endpoint_id,
|
|
271
|
+
mm_constants.ApplicationEvent.START_INFER_TIME: window_start,
|
|
272
|
+
mm_constants.ApplicationEvent.END_INFER_TIME: window_end,
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
result_key = (
|
|
276
|
+
f"{endpoint_name}-{endpoint_id}_{window_start.isoformat()}_{window_end.isoformat()}"
|
|
277
|
+
if window_start and window_end
|
|
278
|
+
else f"{endpoint_name}-{endpoint_id}"
|
|
279
|
+
)
|
|
173
280
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
281
|
+
context.log_result(
|
|
282
|
+
result_key, self._flatten_data_result(result)
|
|
283
|
+
)
|
|
284
|
+
else:
|
|
285
|
+
return self._flatten_data_result(call_do_tracking())
|
|
177
286
|
|
|
178
287
|
@staticmethod
|
|
179
288
|
def _handle_endpoints_type_evaluate(
|
|
@@ -338,6 +447,7 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
|
338
447
|
* ``start``, ``datetime``
|
|
339
448
|
* ``end``, ``datetime``
|
|
340
449
|
* ``base_period``, ``int``
|
|
450
|
+
* ``write_output``, ``bool``
|
|
341
451
|
|
|
342
452
|
For Git sources, add the source archive to the returned job and change the handler:
|
|
343
453
|
|
|
@@ -420,6 +530,8 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
|
420
530
|
start: Optional[datetime] = None,
|
|
421
531
|
end: Optional[datetime] = None,
|
|
422
532
|
base_period: Optional[int] = None,
|
|
533
|
+
write_output: bool = False,
|
|
534
|
+
stream_profile: Optional[ds_profile.DatastoreProfile] = None,
|
|
423
535
|
) -> "mlrun.RunObject":
|
|
424
536
|
"""
|
|
425
537
|
Call this function to run the application's
|
|
@@ -470,6 +582,14 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
|
470
582
|
..., (\\operatorname{start} +
|
|
471
583
|
m\\cdot\\operatorname{base\\_period}, \\operatorname{end}]`,
|
|
472
584
|
where :math:`m` is some positive integer.
|
|
585
|
+
:param write_output: Whether to write the results and metrics to the time-series DB. Can be ``True`` only
|
|
586
|
+
if ``endpoints`` are passed.
|
|
587
|
+
Note: the model monitoring infrastructure must be up for the writing to work.
|
|
588
|
+
:param stream_profile: The stream datastore profile. It should be provided only when running locally and
|
|
589
|
+
writing the outputs to the database (i.e., when both ``run_local`` and
|
|
590
|
+
``write_output`` are set to ``True``).
|
|
591
|
+
For more details on configuring the stream profile, see
|
|
592
|
+
:py:meth:`~mlrun.projects.MlrunProject.set_model_monitoring_credentials`.
|
|
473
593
|
|
|
474
594
|
:returns: The output of the
|
|
475
595
|
:py:meth:`~mlrun.model_monitoring.applications.ModelMonitoringApplicationBase.do_tracking`
|
|
@@ -507,10 +627,25 @@ class ModelMonitoringApplicationBase(MonitoringApplicationToDict, ABC):
|
|
|
507
627
|
)
|
|
508
628
|
params["end"] = end.isoformat() if isinstance(end, datetime) else end
|
|
509
629
|
params["base_period"] = base_period
|
|
630
|
+
params["write_output"] = write_output
|
|
631
|
+
if stream_profile:
|
|
632
|
+
if not run_local:
|
|
633
|
+
raise mlrun.errors.MLRunValueError(
|
|
634
|
+
"Passing a `stream_profile` is relevant only when running locally"
|
|
635
|
+
)
|
|
636
|
+
if not write_output:
|
|
637
|
+
raise mlrun.errors.MLRunValueError(
|
|
638
|
+
"Passing a `stream_profile` is relevant only when writing the outputs"
|
|
639
|
+
)
|
|
640
|
+
params["stream_profile"] = stream_profile
|
|
510
641
|
elif start or end or base_period:
|
|
511
642
|
raise mlrun.errors.MLRunValueError(
|
|
512
643
|
"Custom `start` and `end` times or base_period are supported only with endpoints data"
|
|
513
644
|
)
|
|
645
|
+
elif write_output or stream_profile:
|
|
646
|
+
raise mlrun.errors.MLRunValueError(
|
|
647
|
+
"Writing the application output or passing `stream_profile` are supported only with endpoints data"
|
|
648
|
+
)
|
|
514
649
|
|
|
515
650
|
inputs: dict[str, str] = {}
|
|
516
651
|
for data, identifier in [
|
|
@@ -22,14 +22,11 @@ import numpy as np
|
|
|
22
22
|
import pandas as pd
|
|
23
23
|
|
|
24
24
|
import mlrun
|
|
25
|
-
import mlrun.artifacts
|
|
26
25
|
import mlrun.common.model_monitoring.helpers
|
|
27
26
|
import mlrun.common.schemas.model_monitoring.constants as mm_constants
|
|
28
27
|
import mlrun.data_types.infer
|
|
29
28
|
import mlrun.datastore.datastore_profile
|
|
30
|
-
import mlrun.model_monitoring
|
|
31
29
|
import mlrun.platforms.iguazio
|
|
32
|
-
import mlrun.utils.helpers
|
|
33
30
|
from mlrun.common.schemas import ModelEndpoint
|
|
34
31
|
from mlrun.common.schemas.model_monitoring.model_endpoints import (
|
|
35
32
|
ModelEndpointMonitoringMetric,
|
mlrun/projects/operations.py
CHANGED
|
@@ -281,7 +281,7 @@ def build_function(
|
|
|
281
281
|
mlrun_version_specifier=None,
|
|
282
282
|
builder_env: Optional[dict] = None,
|
|
283
283
|
project_object=None,
|
|
284
|
-
overwrite_build_params: bool =
|
|
284
|
+
overwrite_build_params: bool = True,
|
|
285
285
|
extra_args: Optional[str] = None,
|
|
286
286
|
force_build: bool = False,
|
|
287
287
|
) -> Union[BuildStatus, mlrun_pipelines.models.PipelineNodeWrapper]:
|
|
@@ -308,13 +308,6 @@ def build_function(
|
|
|
308
308
|
e.g. extra_args="--skip-tls-verify --build-arg A=val"
|
|
309
309
|
:param force_build: Force building the image, even when no changes were made
|
|
310
310
|
"""
|
|
311
|
-
if not overwrite_build_params:
|
|
312
|
-
# TODO: change overwrite_build_params default to True in 1.10.0
|
|
313
|
-
warnings.warn(
|
|
314
|
-
"The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.10.0.",
|
|
315
|
-
mlrun.utils.OverwriteBuildParamsWarning,
|
|
316
|
-
)
|
|
317
|
-
|
|
318
311
|
engine, function = _get_engine_and_function(function, project_object)
|
|
319
312
|
if function.kind in mlrun.runtimes.RuntimeKinds.nuclio_runtimes():
|
|
320
313
|
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
@@ -340,22 +333,16 @@ def build_function(
|
|
|
340
333
|
skip_deployed=skip_deployed,
|
|
341
334
|
)
|
|
342
335
|
else:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
secret=secret_name,
|
|
354
|
-
requirements=requirements,
|
|
355
|
-
requirements_file=requirements_file,
|
|
356
|
-
overwrite=overwrite_build_params,
|
|
357
|
-
extra_args=extra_args,
|
|
358
|
-
)
|
|
336
|
+
function.build_config(
|
|
337
|
+
image=image,
|
|
338
|
+
base_image=base_image,
|
|
339
|
+
commands=commands,
|
|
340
|
+
secret=secret_name,
|
|
341
|
+
requirements=requirements,
|
|
342
|
+
requirements_file=requirements_file,
|
|
343
|
+
overwrite=overwrite_build_params,
|
|
344
|
+
extra_args=extra_args,
|
|
345
|
+
)
|
|
359
346
|
ready = function.deploy(
|
|
360
347
|
watch=True,
|
|
361
348
|
with_mlrun=with_mlrun,
|
mlrun/projects/project.py
CHANGED
|
@@ -757,14 +757,7 @@ def _project_instance_from_struct(struct, name, allow_cross_project):
|
|
|
757
757
|
"3. Use different project context dir."
|
|
758
758
|
)
|
|
759
759
|
|
|
760
|
-
if allow_cross_project
|
|
761
|
-
# TODO: Remove this warning in version 1.10.0 and also fix cli to support allow_cross_project
|
|
762
|
-
warnings.warn(
|
|
763
|
-
f"Project {name=} is different than specified on the context's project yaml. "
|
|
764
|
-
"This behavior is deprecated and will not be supported from version 1.10.0."
|
|
765
|
-
)
|
|
766
|
-
logger.warn(error_message)
|
|
767
|
-
elif allow_cross_project:
|
|
760
|
+
if allow_cross_project:
|
|
768
761
|
logger.debug(
|
|
769
762
|
"Project name is different than specified on the context's project yaml. Overriding.",
|
|
770
763
|
existing_name=name_from_struct,
|
|
@@ -4111,7 +4104,7 @@ class MlrunProject(ModelObj):
|
|
|
4111
4104
|
requirements: Optional[typing.Union[str, list[str]]] = None,
|
|
4112
4105
|
mlrun_version_specifier: Optional[str] = None,
|
|
4113
4106
|
builder_env: Optional[dict] = None,
|
|
4114
|
-
overwrite_build_params: bool =
|
|
4107
|
+
overwrite_build_params: bool = True,
|
|
4115
4108
|
requirements_file: Optional[str] = None,
|
|
4116
4109
|
extra_args: Optional[str] = None,
|
|
4117
4110
|
force_build: bool = False,
|
|
@@ -4167,7 +4160,7 @@ class MlrunProject(ModelObj):
|
|
|
4167
4160
|
commands: Optional[list] = None,
|
|
4168
4161
|
secret_name: Optional[str] = None,
|
|
4169
4162
|
requirements: Optional[typing.Union[str, list[str]]] = None,
|
|
4170
|
-
overwrite_build_params: bool =
|
|
4163
|
+
overwrite_build_params: bool = True,
|
|
4171
4164
|
requirements_file: Optional[str] = None,
|
|
4172
4165
|
builder_env: Optional[dict] = None,
|
|
4173
4166
|
extra_args: Optional[str] = None,
|
|
@@ -4197,12 +4190,6 @@ class MlrunProject(ModelObj):
|
|
|
4197
4190
|
:param source_code_target_dir: Path on the image where source code would be extracted
|
|
4198
4191
|
(by default `/home/mlrun_code`)
|
|
4199
4192
|
"""
|
|
4200
|
-
if not overwrite_build_params:
|
|
4201
|
-
# TODO: change overwrite_build_params default to True in 1.10.0
|
|
4202
|
-
warnings.warn(
|
|
4203
|
-
"The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.10.0.",
|
|
4204
|
-
mlrun.utils.OverwriteBuildParamsWarning,
|
|
4205
|
-
)
|
|
4206
4193
|
default_image_name = mlrun.mlconf.default_project_image_name.format(
|
|
4207
4194
|
name=self.name
|
|
4208
4195
|
)
|
|
@@ -4236,7 +4223,7 @@ class MlrunProject(ModelObj):
|
|
|
4236
4223
|
requirements: Optional[typing.Union[str, list[str]]] = None,
|
|
4237
4224
|
mlrun_version_specifier: Optional[str] = None,
|
|
4238
4225
|
builder_env: Optional[dict] = None,
|
|
4239
|
-
overwrite_build_params: bool =
|
|
4226
|
+
overwrite_build_params: bool = True,
|
|
4240
4227
|
requirements_file: Optional[str] = None,
|
|
4241
4228
|
extra_args: Optional[str] = None,
|
|
4242
4229
|
target_dir: Optional[str] = None,
|
|
@@ -4276,60 +4263,47 @@ class MlrunProject(ModelObj):
|
|
|
4276
4263
|
base_image=base_image,
|
|
4277
4264
|
)
|
|
4278
4265
|
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4266
|
+
self.build_config(
|
|
4267
|
+
image=image,
|
|
4268
|
+
set_as_default=set_as_default,
|
|
4269
|
+
base_image=base_image,
|
|
4270
|
+
commands=commands,
|
|
4271
|
+
secret_name=secret_name,
|
|
4272
|
+
with_mlrun=with_mlrun,
|
|
4273
|
+
requirements=requirements,
|
|
4274
|
+
requirements_file=requirements_file,
|
|
4275
|
+
overwrite_build_params=overwrite_build_params,
|
|
4276
|
+
)
|
|
4285
4277
|
|
|
4286
|
-
|
|
4287
|
-
with warnings.catch_warnings():
|
|
4288
|
-
warnings.simplefilter(
|
|
4289
|
-
"ignore", category=mlrun.utils.OverwriteBuildParamsWarning
|
|
4290
|
-
)
|
|
4278
|
+
function = mlrun.new_function("mlrun--project--image--builder", kind="job")
|
|
4291
4279
|
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
secret_name=secret_name,
|
|
4298
|
-
with_mlrun=with_mlrun,
|
|
4299
|
-
requirements=requirements,
|
|
4300
|
-
requirements_file=requirements_file,
|
|
4301
|
-
overwrite_build_params=overwrite_build_params,
|
|
4280
|
+
if self.spec.source and not self.spec.load_source_on_run:
|
|
4281
|
+
function.with_source_archive(
|
|
4282
|
+
source=self.spec.source,
|
|
4283
|
+
target_dir=target_dir,
|
|
4284
|
+
pull_at_runtime=False,
|
|
4302
4285
|
)
|
|
4303
4286
|
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
commands=build.commands,
|
|
4320
|
-
secret_name=build.secret,
|
|
4321
|
-
requirements=build.requirements,
|
|
4322
|
-
overwrite_build_params=overwrite_build_params,
|
|
4323
|
-
mlrun_version_specifier=mlrun_version_specifier,
|
|
4324
|
-
builder_env=builder_env,
|
|
4325
|
-
extra_args=extra_args,
|
|
4326
|
-
force_build=True,
|
|
4327
|
-
)
|
|
4287
|
+
build = self.spec.build
|
|
4288
|
+
result = self.build_function(
|
|
4289
|
+
function=function,
|
|
4290
|
+
with_mlrun=build.with_mlrun,
|
|
4291
|
+
image=build.image,
|
|
4292
|
+
base_image=build.base_image,
|
|
4293
|
+
commands=build.commands,
|
|
4294
|
+
secret_name=build.secret,
|
|
4295
|
+
requirements=build.requirements,
|
|
4296
|
+
overwrite_build_params=overwrite_build_params,
|
|
4297
|
+
mlrun_version_specifier=mlrun_version_specifier,
|
|
4298
|
+
builder_env=builder_env,
|
|
4299
|
+
extra_args=extra_args,
|
|
4300
|
+
force_build=True,
|
|
4301
|
+
)
|
|
4328
4302
|
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4303
|
+
# Get the enriched target dir from the function
|
|
4304
|
+
self.spec.build.source_code_target_dir = (
|
|
4305
|
+
function.spec.build.source_code_target_dir
|
|
4306
|
+
)
|
|
4333
4307
|
|
|
4334
4308
|
try:
|
|
4335
4309
|
mlrun.db.get_run_db(secrets=self._secrets).delete_function(
|
|
@@ -5015,9 +4989,6 @@ class MlrunProject(ModelObj):
|
|
|
5015
4989
|
name: Optional[str] = None,
|
|
5016
4990
|
uid: Optional[Union[str, list[str]]] = None,
|
|
5017
4991
|
labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
|
|
5018
|
-
state: Optional[
|
|
5019
|
-
mlrun.common.runtimes.constants.RunStates
|
|
5020
|
-
] = None, # Backward compatibility
|
|
5021
4992
|
states: typing.Optional[list[mlrun.common.runtimes.constants.RunStates]] = None,
|
|
5022
4993
|
sort: bool = True,
|
|
5023
4994
|
iter: bool = False,
|
|
@@ -5061,7 +5032,6 @@ class MlrunProject(ModelObj):
|
|
|
5061
5032
|
- A comma-separated string formatted as `"label1=value1,label2"` to match entities with
|
|
5062
5033
|
the specified key-value pairs or key existence.
|
|
5063
5034
|
|
|
5064
|
-
:param state: Deprecated - List only runs whose state is specified.
|
|
5065
5035
|
:param states: List only runs whose state is one of the provided states.
|
|
5066
5036
|
:param sort: Whether to sort the result according to their start time. Otherwise, results will be
|
|
5067
5037
|
returned by their internal order in the DB (order will not be guaranteed).
|
|
@@ -5075,24 +5045,13 @@ class MlrunProject(ModelObj):
|
|
|
5075
5045
|
:param end_time_from: Filter by run end time in ``[end_time_from, end_time_to]``.
|
|
5076
5046
|
:param end_time_to: Filter by run end time in ``[end_time_from, end_time_to]``.
|
|
5077
5047
|
"""
|
|
5078
|
-
if state:
|
|
5079
|
-
# TODO: Remove this in 1.10.0
|
|
5080
|
-
warnings.warn(
|
|
5081
|
-
"'state' is deprecated in 1.7.0 and will be removed in 1.10.0. Use 'states' instead.",
|
|
5082
|
-
FutureWarning,
|
|
5083
|
-
)
|
|
5084
|
-
|
|
5085
5048
|
db = mlrun.db.get_run_db(secrets=self._secrets)
|
|
5086
5049
|
return db.list_runs(
|
|
5087
5050
|
name,
|
|
5088
5051
|
uid,
|
|
5089
5052
|
self.metadata.name,
|
|
5090
5053
|
labels=labels,
|
|
5091
|
-
states=
|
|
5092
|
-
mlrun.utils.helpers.as_list(state)
|
|
5093
|
-
if state is not None
|
|
5094
|
-
else states or None
|
|
5095
|
-
),
|
|
5054
|
+
states=states or None,
|
|
5096
5055
|
sort=sort,
|
|
5097
5056
|
iter=iter,
|
|
5098
5057
|
start_time_from=start_time_from,
|
mlrun/runtimes/daskjob.py
CHANGED
|
@@ -92,6 +92,7 @@ class DaskSpec(KubeResourceSpec):
|
|
|
92
92
|
preemption_mode=None,
|
|
93
93
|
security_context=None,
|
|
94
94
|
state_thresholds=None,
|
|
95
|
+
serving_spec=None,
|
|
95
96
|
):
|
|
96
97
|
super().__init__(
|
|
97
98
|
command=command,
|
|
@@ -121,6 +122,7 @@ class DaskSpec(KubeResourceSpec):
|
|
|
121
122
|
preemption_mode=preemption_mode,
|
|
122
123
|
security_context=security_context,
|
|
123
124
|
state_thresholds=state_thresholds,
|
|
125
|
+
serving_spec=serving_spec,
|
|
124
126
|
)
|
|
125
127
|
self.args = args
|
|
126
128
|
|
mlrun/runtimes/kubejob.py
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
import typing
|
|
15
|
-
import warnings
|
|
16
15
|
|
|
17
16
|
import mlrun.common.schemas
|
|
18
17
|
import mlrun.db
|
|
@@ -83,7 +82,7 @@ class KubejobRuntime(KubeResource):
|
|
|
83
82
|
with_mlrun=None,
|
|
84
83
|
auto_build=None,
|
|
85
84
|
requirements=None,
|
|
86
|
-
overwrite=
|
|
85
|
+
overwrite=True,
|
|
87
86
|
prepare_image_for_deploy=True,
|
|
88
87
|
requirements_file=None,
|
|
89
88
|
builder_env=None,
|
|
@@ -113,12 +112,6 @@ class KubejobRuntime(KubeResource):
|
|
|
113
112
|
:param builder_env: Kaniko builder pod env vars dict (for config/credentials)
|
|
114
113
|
e.g. builder_env={"GIT_TOKEN": token}
|
|
115
114
|
"""
|
|
116
|
-
if not overwrite:
|
|
117
|
-
# TODO: change overwrite default to True in 1.10.0
|
|
118
|
-
warnings.warn(
|
|
119
|
-
"The `overwrite` parameter default will change from 'False' to 'True' in 1.10.0.",
|
|
120
|
-
mlrun.utils.OverwriteBuildParamsWarning,
|
|
121
|
-
)
|
|
122
115
|
image = mlrun.utils.helpers.remove_image_protocol_prefix(image)
|
|
123
116
|
self.spec.build.build_config(
|
|
124
117
|
image=image,
|
|
@@ -214,3 +207,7 @@ class KubejobRuntime(KubeResource):
|
|
|
214
207
|
raise NotImplementedError(
|
|
215
208
|
f"Running a {self.kind} function from the client is not supported. Use .run() to submit the job to the API."
|
|
216
209
|
)
|
|
210
|
+
|
|
211
|
+
@property
|
|
212
|
+
def serving_spec(self):
|
|
213
|
+
return self.spec.serving_spec
|
|
@@ -54,6 +54,7 @@ class MPIResourceSpec(KubeResourceSpec):
|
|
|
54
54
|
preemption_mode=None,
|
|
55
55
|
security_context=None,
|
|
56
56
|
state_thresholds=None,
|
|
57
|
+
serving_spec=None,
|
|
57
58
|
):
|
|
58
59
|
super().__init__(
|
|
59
60
|
command=command,
|
|
@@ -83,6 +84,7 @@ class MPIResourceSpec(KubeResourceSpec):
|
|
|
83
84
|
preemption_mode=preemption_mode,
|
|
84
85
|
security_context=security_context,
|
|
85
86
|
state_thresholds=state_thresholds,
|
|
87
|
+
serving_spec=serving_spec,
|
|
86
88
|
)
|
|
87
89
|
self.mpi_args = mpi_args or [
|
|
88
90
|
"-x",
|
mlrun/runtimes/mpijob/v1.py
CHANGED
|
@@ -49,6 +49,7 @@ class MPIV1ResourceSpec(MPIResourceSpec):
|
|
|
49
49
|
preemption_mode=None,
|
|
50
50
|
security_context=None,
|
|
51
51
|
state_thresholds=None,
|
|
52
|
+
serving_spec=None,
|
|
52
53
|
):
|
|
53
54
|
super().__init__(
|
|
54
55
|
command=command,
|
|
@@ -79,6 +80,7 @@ class MPIV1ResourceSpec(MPIResourceSpec):
|
|
|
79
80
|
preemption_mode=preemption_mode,
|
|
80
81
|
security_context=security_context,
|
|
81
82
|
state_thresholds=state_thresholds,
|
|
83
|
+
serving_spec=serving_spec,
|
|
82
84
|
)
|
|
83
85
|
self.clean_pod_policy = clean_pod_policy or MPIJobV1CleanPodPolicies.default()
|
|
84
86
|
|
|
@@ -154,6 +154,7 @@ class NuclioSpec(KubeResourceSpec):
|
|
|
154
154
|
add_templated_ingress_host_mode=None,
|
|
155
155
|
state_thresholds=None,
|
|
156
156
|
disable_default_http_trigger=None,
|
|
157
|
+
serving_spec=None,
|
|
157
158
|
):
|
|
158
159
|
super().__init__(
|
|
159
160
|
command=command,
|
|
@@ -183,6 +184,7 @@ class NuclioSpec(KubeResourceSpec):
|
|
|
183
184
|
preemption_mode=preemption_mode,
|
|
184
185
|
security_context=security_context,
|
|
185
186
|
state_thresholds=state_thresholds,
|
|
187
|
+
serving_spec=serving_spec,
|
|
186
188
|
)
|
|
187
189
|
|
|
188
190
|
self.base_spec = base_spec or {}
|