mlrun 1.7.0rc2__py3-none-any.whl → 1.7.0rc4__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/artifacts/manager.py +6 -1
- mlrun/common/constants.py +1 -0
- mlrun/common/model_monitoring/helpers.py +12 -6
- mlrun/common/schemas/__init__.py +1 -0
- mlrun/common/schemas/client_spec.py +1 -0
- mlrun/common/schemas/common.py +40 -0
- mlrun/common/schemas/model_monitoring/constants.py +4 -1
- mlrun/common/schemas/project.py +2 -0
- mlrun/config.py +20 -16
- mlrun/datastore/azure_blob.py +22 -9
- mlrun/datastore/base.py +15 -25
- mlrun/datastore/datastore.py +19 -8
- mlrun/datastore/datastore_profile.py +47 -5
- mlrun/datastore/google_cloud_storage.py +10 -6
- mlrun/datastore/hdfs.py +51 -0
- mlrun/datastore/redis.py +4 -0
- mlrun/datastore/s3.py +4 -0
- mlrun/datastore/sources.py +31 -50
- mlrun/datastore/targets.py +58 -48
- mlrun/datastore/utils.py +2 -49
- mlrun/datastore/v3io.py +4 -0
- mlrun/db/base.py +34 -0
- mlrun/db/httpdb.py +71 -42
- mlrun/execution.py +3 -3
- mlrun/feature_store/feature_vector.py +2 -2
- mlrun/frameworks/tf_keras/callbacks/logging_callback.py +3 -3
- mlrun/frameworks/tf_keras/model_handler.py +7 -7
- mlrun/k8s_utils.py +10 -5
- mlrun/kfpops.py +19 -10
- mlrun/model.py +5 -0
- mlrun/model_monitoring/api.py +3 -3
- mlrun/model_monitoring/application.py +1 -1
- mlrun/model_monitoring/applications/__init__.py +13 -0
- mlrun/model_monitoring/applications/histogram_data_drift.py +218 -0
- mlrun/model_monitoring/batch.py +9 -111
- mlrun/model_monitoring/controller.py +73 -55
- mlrun/model_monitoring/controller_handler.py +13 -5
- mlrun/model_monitoring/features_drift_table.py +62 -53
- mlrun/model_monitoring/helpers.py +30 -21
- mlrun/model_monitoring/metrics/__init__.py +13 -0
- mlrun/model_monitoring/metrics/histogram_distance.py +127 -0
- mlrun/model_monitoring/stores/kv_model_endpoint_store.py +14 -14
- mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -1
- mlrun/package/packagers/pandas_packagers.py +3 -3
- mlrun/package/utils/_archiver.py +3 -1
- mlrun/platforms/iguazio.py +8 -65
- mlrun/projects/pipelines.py +21 -11
- mlrun/projects/project.py +121 -42
- mlrun/runtimes/base.py +21 -2
- mlrun/runtimes/kubejob.py +5 -3
- mlrun/runtimes/local.py +2 -2
- mlrun/runtimes/mpijob/abstract.py +6 -6
- mlrun/runtimes/nuclio/function.py +9 -9
- mlrun/runtimes/nuclio/serving.py +3 -3
- mlrun/runtimes/pod.py +3 -3
- mlrun/runtimes/sparkjob/spark3job.py +3 -3
- mlrun/serving/remote.py +4 -2
- mlrun/serving/server.py +15 -18
- mlrun/serving/states.py +27 -12
- mlrun/utils/async_http.py +3 -3
- mlrun/utils/helpers.py +27 -5
- mlrun/utils/http.py +3 -3
- mlrun/utils/notifications/notification_pusher.py +6 -6
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/METADATA +13 -16
- {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/RECORD +70 -64
- {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/LICENSE +0 -0
- {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/WHEEL +0 -0
- {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/top_level.txt +0 -0
mlrun/db/httpdb.py
CHANGED
|
@@ -152,7 +152,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
152
152
|
@staticmethod
|
|
153
153
|
def get_api_path_prefix(version: str = None) -> str:
|
|
154
154
|
"""
|
|
155
|
-
:param version: API version to use, None (the default) will mean to use the default value from
|
|
155
|
+
:param version: API version to use, None (the default) will mean to use the default value from mlrun.config,
|
|
156
156
|
for un-versioned api set an empty string.
|
|
157
157
|
"""
|
|
158
158
|
if version is not None:
|
|
@@ -250,7 +250,11 @@ class HTTPRunDB(RunDBInterface):
|
|
|
250
250
|
|
|
251
251
|
try:
|
|
252
252
|
response = self.session.request(
|
|
253
|
-
method,
|
|
253
|
+
method,
|
|
254
|
+
url,
|
|
255
|
+
timeout=timeout,
|
|
256
|
+
verify=config.httpdb.http.verify,
|
|
257
|
+
**kw,
|
|
254
258
|
)
|
|
255
259
|
except requests.RequestException as exc:
|
|
256
260
|
error = f"{err_to_str(exc)}: {error}" if error else err_to_str(exc)
|
|
@@ -302,11 +306,11 @@ class HTTPRunDB(RunDBInterface):
|
|
|
302
306
|
|
|
303
307
|
def connect(self, secrets=None):
|
|
304
308
|
"""Connect to the MLRun API server. Must be called prior to executing any other method.
|
|
305
|
-
The code utilizes the URL for the API server from the configuration - ``
|
|
309
|
+
The code utilizes the URL for the API server from the configuration - ``config.dbpath``.
|
|
306
310
|
|
|
307
311
|
For example::
|
|
308
312
|
|
|
309
|
-
|
|
313
|
+
config.dbpath = config.dbpath or 'http://mlrun-api:8080'
|
|
310
314
|
db = get_run_db().connect()
|
|
311
315
|
"""
|
|
312
316
|
# hack to allow unit tests to instantiate HTTPRunDB without a real server behind
|
|
@@ -454,6 +458,10 @@ class HTTPRunDB(RunDBInterface):
|
|
|
454
458
|
setattr(
|
|
455
459
|
config.feature_store.data_prefixes, prefix, server_prefix_value
|
|
456
460
|
)
|
|
461
|
+
config.feature_store.default_targets = (
|
|
462
|
+
server_cfg.get("feature_store_default_targets")
|
|
463
|
+
or config.feature_store.default_targets
|
|
464
|
+
)
|
|
457
465
|
|
|
458
466
|
except Exception as exc:
|
|
459
467
|
logger.warning(
|
|
@@ -500,7 +508,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
500
508
|
if offset < 0:
|
|
501
509
|
raise MLRunInvalidArgumentError("Offset cannot be negative")
|
|
502
510
|
if size is None:
|
|
503
|
-
size = int(
|
|
511
|
+
size = int(config.httpdb.logs.pull_logs_default_size_limit)
|
|
504
512
|
elif size == -1:
|
|
505
513
|
logger.warning(
|
|
506
514
|
"Retrieving all logs. This may be inefficient and can result in a large log."
|
|
@@ -546,25 +554,23 @@ class HTTPRunDB(RunDBInterface):
|
|
|
546
554
|
|
|
547
555
|
state, text = self.get_log(uid, project, offset=offset)
|
|
548
556
|
if text:
|
|
549
|
-
print(text.decode(errors=
|
|
557
|
+
print(text.decode(errors=config.httpdb.logs.decode.errors))
|
|
550
558
|
nil_resp = 0
|
|
551
559
|
while True:
|
|
552
560
|
offset += len(text)
|
|
553
561
|
# if we get 3 nil responses in a row, increase the sleep time to 10 seconds
|
|
554
562
|
# TODO: refactor this to use a conditional backoff mechanism
|
|
555
563
|
if nil_resp < 3:
|
|
556
|
-
time.sleep(int(
|
|
564
|
+
time.sleep(int(config.httpdb.logs.pull_logs_default_interval))
|
|
557
565
|
else:
|
|
558
566
|
time.sleep(
|
|
559
|
-
int(
|
|
560
|
-
mlrun.mlconf.httpdb.logs.pull_logs_backoff_no_logs_default_interval
|
|
561
|
-
)
|
|
567
|
+
int(config.httpdb.logs.pull_logs_backoff_no_logs_default_interval)
|
|
562
568
|
)
|
|
563
569
|
state, text = self.get_log(uid, project, offset=offset)
|
|
564
570
|
if text:
|
|
565
571
|
nil_resp = 0
|
|
566
572
|
print(
|
|
567
|
-
text.decode(errors=
|
|
573
|
+
text.decode(errors=config.httpdb.logs.decode.errors),
|
|
568
574
|
end="",
|
|
569
575
|
)
|
|
570
576
|
else:
|
|
@@ -1135,17 +1141,17 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1135
1141
|
structured_dict = {}
|
|
1136
1142
|
for project, job_runtime_resources_map in response.json().items():
|
|
1137
1143
|
for job_id, runtime_resources in job_runtime_resources_map.items():
|
|
1138
|
-
structured_dict.setdefault(project, {})[
|
|
1139
|
-
|
|
1140
|
-
|
|
1144
|
+
structured_dict.setdefault(project, {})[job_id] = (
|
|
1145
|
+
mlrun.common.schemas.RuntimeResources(**runtime_resources)
|
|
1146
|
+
)
|
|
1141
1147
|
return structured_dict
|
|
1142
1148
|
elif group_by == mlrun.common.schemas.ListRuntimeResourcesGroupByField.project:
|
|
1143
1149
|
structured_dict = {}
|
|
1144
1150
|
for project, kind_runtime_resources_map in response.json().items():
|
|
1145
1151
|
for kind, runtime_resources in kind_runtime_resources_map.items():
|
|
1146
|
-
structured_dict.setdefault(project, {})[
|
|
1147
|
-
|
|
1148
|
-
|
|
1152
|
+
structured_dict.setdefault(project, {})[kind] = (
|
|
1153
|
+
mlrun.common.schemas.RuntimeResources(**runtime_resources)
|
|
1154
|
+
)
|
|
1149
1155
|
return structured_dict
|
|
1150
1156
|
else:
|
|
1151
1157
|
raise NotImplementedError(
|
|
@@ -1173,7 +1179,8 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1173
1179
|
:param force: Force deletion - delete the runtime resource even if it's not in terminal state or if the grace
|
|
1174
1180
|
period didn't pass.
|
|
1175
1181
|
:param grace_period: Grace period given to the runtime resource before they are actually removed, counted from
|
|
1176
|
-
the moment they moved to terminal state
|
|
1182
|
+
the moment they moved to terminal state
|
|
1183
|
+
(defaults to mlrun.config.config.runtime_resources_deletion_grace_period).
|
|
1177
1184
|
|
|
1178
1185
|
:returns: :py:class:`~mlrun.common.schemas.GroupedByProjectRuntimeResourcesOutput` listing the runtime resources
|
|
1179
1186
|
that were removed.
|
|
@@ -1203,9 +1210,9 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1203
1210
|
structured_dict = {}
|
|
1204
1211
|
for project, kind_runtime_resources_map in response.json().items():
|
|
1205
1212
|
for kind, runtime_resources in kind_runtime_resources_map.items():
|
|
1206
|
-
structured_dict.setdefault(project, {})[
|
|
1207
|
-
|
|
1208
|
-
|
|
1213
|
+
structured_dict.setdefault(project, {})[kind] = (
|
|
1214
|
+
mlrun.common.schemas.RuntimeResources(**runtime_resources)
|
|
1215
|
+
)
|
|
1209
1216
|
return structured_dict
|
|
1210
1217
|
|
|
1211
1218
|
def create_schedule(
|
|
@@ -1340,7 +1347,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1340
1347
|
logger.warning(
|
|
1341
1348
|
"Building a function image to ECR and loading an S3 source to the image may require conflicting access "
|
|
1342
1349
|
"keys. Only the permissions granted to the platform's configured secret will take affect "
|
|
1343
|
-
"(see mlrun.
|
|
1350
|
+
"(see mlrun.config.config.httpdb.builder.docker_registry_secret). "
|
|
1344
1351
|
"In case the permissions are limited to ECR scope, you may use pull_at_runtime=True instead",
|
|
1345
1352
|
source=func.spec.build.source,
|
|
1346
1353
|
load_source_on_run=func.spec.build.load_source_on_run,
|
|
@@ -1495,7 +1502,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
1495
1502
|
Retrieve updated information on project background tasks being executed.
|
|
1496
1503
|
If no filter is provided, will return background tasks from the last week.
|
|
1497
1504
|
|
|
1498
|
-
:param project: Project name (defaults to mlrun.
|
|
1505
|
+
:param project: Project name (defaults to mlrun.config.config.default_project).
|
|
1499
1506
|
:param state: List only background tasks whose state is specified.
|
|
1500
1507
|
:param created_from: Filter by background task created time in ``[created_from, created_to]``.
|
|
1501
1508
|
:param created_to: Filter by background task created time in ``[created_from, created_to]``.
|
|
@@ -3071,36 +3078,58 @@ class HTTPRunDB(RunDBInterface):
|
|
|
3071
3078
|
resp = self.api_call(method="POST", path=path, params=params)
|
|
3072
3079
|
return resp.json()["func"]
|
|
3073
3080
|
|
|
3074
|
-
def
|
|
3081
|
+
def update_model_monitoring_controller(
|
|
3075
3082
|
self,
|
|
3076
|
-
project: str
|
|
3077
|
-
default_controller_image: str = "mlrun/mlrun",
|
|
3083
|
+
project: str,
|
|
3078
3084
|
base_period: int = 10,
|
|
3085
|
+
image: str = "mlrun/mlrun",
|
|
3079
3086
|
):
|
|
3080
3087
|
"""
|
|
3081
|
-
|
|
3082
|
-
While the main goal of the controller job is to handle the monitoring processing and triggering applications,
|
|
3083
|
-
the goal of the model monitoring writer function is to write all the monitoring application results to the
|
|
3084
|
-
databases. Note that the default scheduling policy of the controller job is to run every 10 min.
|
|
3088
|
+
Redeploy model monitoring application controller function.
|
|
3085
3089
|
|
|
3086
3090
|
:param project: Project name.
|
|
3087
|
-
:param
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
is running. By default, the base period is 5 minutes.
|
|
3092
|
-
:returns: model monitoring controller job as a dictionary. You can easily convert the returned function into a
|
|
3093
|
-
runtime object by calling ~mlrun.new_function.
|
|
3091
|
+
:param base_period: The time period in minutes in which the model monitoring controller function
|
|
3092
|
+
triggers. By default, the base period is 10 minutes.
|
|
3093
|
+
:param image: The image of the model monitoring controller function.
|
|
3094
|
+
By default, the image is mlrun/mlrun.
|
|
3094
3095
|
"""
|
|
3095
3096
|
|
|
3096
3097
|
params = {
|
|
3097
|
-
"
|
|
3098
|
+
"image": image,
|
|
3098
3099
|
"base_period": base_period,
|
|
3099
3100
|
}
|
|
3100
|
-
path = f"projects/{project}/
|
|
3101
|
+
path = f"projects/{project}/model-monitoring/model-monitoring-controller"
|
|
3102
|
+
self.api_call(method="POST", path=path, params=params)
|
|
3101
3103
|
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
+
def enable_model_monitoring(
|
|
3105
|
+
self,
|
|
3106
|
+
project: str,
|
|
3107
|
+
base_period: int = 10,
|
|
3108
|
+
image: str = "mlrun/mlrun",
|
|
3109
|
+
):
|
|
3110
|
+
"""
|
|
3111
|
+
Deploy model monitoring application controller, writer and stream functions.
|
|
3112
|
+
While the main goal of the controller function is to handle the monitoring processing and triggering
|
|
3113
|
+
applications, the goal of the model monitoring writer function is to write all the monitoring
|
|
3114
|
+
application results to the databases.
|
|
3115
|
+
The stream function goal is to monitor the log of the data stream. It is triggered when a new log entry
|
|
3116
|
+
is detected. It processes the new events into statistics that are then written to statistics databases.
|
|
3117
|
+
|
|
3118
|
+
|
|
3119
|
+
:param project: Project name.
|
|
3120
|
+
:param base_period: The time period in minutes in which the model monitoring controller function
|
|
3121
|
+
triggers. By default, the base period is 10 minutes.
|
|
3122
|
+
:param image: The image of the model monitoring controller, writer & monitoring
|
|
3123
|
+
stream functions, which are real time nuclio functions.
|
|
3124
|
+
By default, the image is mlrun/mlrun.
|
|
3125
|
+
"""
|
|
3126
|
+
|
|
3127
|
+
params = {
|
|
3128
|
+
"base_period": base_period,
|
|
3129
|
+
"image": image,
|
|
3130
|
+
}
|
|
3131
|
+
path = f"projects/{project}/model-monitoring/enable-model-monitoring"
|
|
3132
|
+
self.api_call(method="POST", path=path, params=params)
|
|
3104
3133
|
|
|
3105
3134
|
def create_hub_source(
|
|
3106
3135
|
self, source: Union[dict, mlrun.common.schemas.IndexedHubSource]
|
|
@@ -3451,7 +3480,7 @@ class HTTPRunDB(RunDBInterface):
|
|
|
3451
3480
|
run_name: Optional[str] = None,
|
|
3452
3481
|
namespace: Optional[str] = None,
|
|
3453
3482
|
notifications: list[mlrun.model.Notification] = None,
|
|
3454
|
-
):
|
|
3483
|
+
) -> mlrun.common.schemas.WorkflowResponse:
|
|
3455
3484
|
"""
|
|
3456
3485
|
Submitting workflow for a remote execution.
|
|
3457
3486
|
|
mlrun/execution.py
CHANGED
|
@@ -559,9 +559,9 @@ class MLClientCtx:
|
|
|
559
559
|
for k, v in get_in(task, ["status", "results"], {}).items():
|
|
560
560
|
self._results[k] = v
|
|
561
561
|
for artifact in get_in(task, ["status", run_keys.artifacts], []):
|
|
562
|
-
self._artifacts_manager.artifacts[
|
|
563
|
-
artifact
|
|
564
|
-
|
|
562
|
+
self._artifacts_manager.artifacts[artifact["metadata"]["key"]] = (
|
|
563
|
+
artifact
|
|
564
|
+
)
|
|
565
565
|
self._artifacts_manager.link_artifact(
|
|
566
566
|
self.project,
|
|
567
567
|
self.name,
|
|
@@ -490,10 +490,10 @@ class FeatureVector(ModelObj):
|
|
|
490
490
|
vector = fstore.FeatureVector("my-vec", features)
|
|
491
491
|
|
|
492
492
|
# get the vector as a dataframe
|
|
493
|
-
df =
|
|
493
|
+
df = vector.get_offline_features().to_dataframe()
|
|
494
494
|
|
|
495
495
|
# return an online/real-time feature service
|
|
496
|
-
svc =
|
|
496
|
+
svc = vector.get_online_feature_service(impute_policy={"*": "$mean"})
|
|
497
497
|
resp = svc.get([{"stock": "GOOG"}])
|
|
498
498
|
|
|
499
499
|
:param name: List of names of targets to delete (default: delete all ingested targets)
|
|
@@ -389,9 +389,9 @@ class LoggingCallback(Callback):
|
|
|
389
389
|
):
|
|
390
390
|
try:
|
|
391
391
|
self._get_hyperparameter(key_chain=learning_rate_key_chain)
|
|
392
|
-
self._dynamic_hyperparameters_keys[
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
self._dynamic_hyperparameters_keys[learning_rate_key] = (
|
|
393
|
+
learning_rate_key_chain
|
|
394
|
+
)
|
|
395
395
|
except (KeyError, IndexError, ValueError):
|
|
396
396
|
pass
|
|
397
397
|
|
|
@@ -263,13 +263,13 @@ class TFKerasModelHandler(DLModelHandler):
|
|
|
263
263
|
# Update the paths and log artifacts if context is available:
|
|
264
264
|
if self._weights_file is not None:
|
|
265
265
|
if self._context is not None:
|
|
266
|
-
artifacts[
|
|
267
|
-
self.
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
266
|
+
artifacts[self._get_weights_file_artifact_name()] = (
|
|
267
|
+
self._context.log_artifact(
|
|
268
|
+
self._weights_file,
|
|
269
|
+
local_path=self._weights_file,
|
|
270
|
+
artifact_path=output_path,
|
|
271
|
+
db_key=False,
|
|
272
|
+
)
|
|
273
273
|
)
|
|
274
274
|
|
|
275
275
|
return artifacts if self._context is not None else None
|
mlrun/k8s_utils.py
CHANGED
|
@@ -133,13 +133,13 @@ def sanitize_label_value(value: str) -> str:
|
|
|
133
133
|
return re.sub(r"([^a-zA-Z0-9_.-]|^[^a-zA-Z0-9]|[^a-zA-Z0-9]$)", "-", value[:63])
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
def verify_label_key(key):
|
|
136
|
+
def verify_label_key(key: str):
|
|
137
|
+
"""
|
|
138
|
+
Verify that the label key is valid for Kubernetes.
|
|
139
|
+
Refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
|
|
140
|
+
"""
|
|
137
141
|
if not key:
|
|
138
142
|
raise mlrun.errors.MLRunInvalidArgumentError("label key cannot be empty")
|
|
139
|
-
if key.startswith("k8s.io") or key.startswith("kubernetes.io"):
|
|
140
|
-
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
141
|
-
"Labels cannot start with 'k8s.io' or 'kubernetes.io'"
|
|
142
|
-
)
|
|
143
143
|
|
|
144
144
|
mlrun.utils.helpers.verify_field_regex(
|
|
145
145
|
f"project.metadata.labels.'{key}'",
|
|
@@ -147,6 +147,11 @@ def verify_label_key(key):
|
|
|
147
147
|
mlrun.utils.regex.k8s_character_limit,
|
|
148
148
|
)
|
|
149
149
|
|
|
150
|
+
if key.startswith("k8s.io/") or key.startswith("kubernetes.io/"):
|
|
151
|
+
raise mlrun.errors.MLRunInvalidArgumentError(
|
|
152
|
+
"Labels cannot start with 'k8s.io/' or 'kubernetes.io/'"
|
|
153
|
+
)
|
|
154
|
+
|
|
150
155
|
parts = key.split("/")
|
|
151
156
|
if len(parts) == 1:
|
|
152
157
|
name = parts[0]
|
mlrun/kfpops.py
CHANGED
|
@@ -41,8 +41,8 @@ from .utils import (
|
|
|
41
41
|
|
|
42
42
|
# default KFP artifacts and output (ui metadata, metrics etc.)
|
|
43
43
|
# directories to /tmp to allow running with security context
|
|
44
|
-
KFPMETA_DIR =
|
|
45
|
-
KFP_ARTIFACTS_DIR =
|
|
44
|
+
KFPMETA_DIR = "/tmp"
|
|
45
|
+
KFP_ARTIFACTS_DIR = "/tmp"
|
|
46
46
|
|
|
47
47
|
project_annotation = "mlrun/project"
|
|
48
48
|
run_annotation = "mlrun/pipeline-step-type"
|
|
@@ -71,7 +71,7 @@ def write_kfpmeta(struct):
|
|
|
71
71
|
{"name": k, "numberValue": v} for k, v in results.items() if is_num(v)
|
|
72
72
|
],
|
|
73
73
|
}
|
|
74
|
-
with open(KFPMETA_DIR
|
|
74
|
+
with open(os.path.join(KFPMETA_DIR, "mlpipeline-metrics.json"), "w") as f:
|
|
75
75
|
json.dump(metrics, f)
|
|
76
76
|
|
|
77
77
|
struct = deepcopy(struct)
|
|
@@ -91,7 +91,14 @@ def write_kfpmeta(struct):
|
|
|
91
91
|
elif key in results:
|
|
92
92
|
val = results[key]
|
|
93
93
|
try:
|
|
94
|
-
|
|
94
|
+
# NOTE: if key has "../x", it would fail on path traversal
|
|
95
|
+
path = os.path.join(KFP_ARTIFACTS_DIR, key)
|
|
96
|
+
if not mlrun.utils.helpers.is_safe_path(KFP_ARTIFACTS_DIR, path):
|
|
97
|
+
logger.warning(
|
|
98
|
+
"Path traversal is not allowed ignoring", path=path, key=key
|
|
99
|
+
)
|
|
100
|
+
continue
|
|
101
|
+
path = os.path.abspath(path)
|
|
95
102
|
logger.info("Writing artifact output", path=path, val=val)
|
|
96
103
|
with open(path, "w") as fp:
|
|
97
104
|
fp.write(str(val))
|
|
@@ -109,7 +116,7 @@ def write_kfpmeta(struct):
|
|
|
109
116
|
"outputs": output_artifacts
|
|
110
117
|
+ [{"type": "markdown", "storage": "inline", "source": text}]
|
|
111
118
|
}
|
|
112
|
-
with open(KFPMETA_DIR
|
|
119
|
+
with open(os.path.join(KFPMETA_DIR, "mlpipeline-ui-metadata.json"), "w") as f:
|
|
113
120
|
json.dump(metadata, f)
|
|
114
121
|
|
|
115
122
|
|
|
@@ -401,9 +408,9 @@ def mlrun_op(
|
|
|
401
408
|
cmd += ["--label", f"{label}={val}"]
|
|
402
409
|
for output in outputs:
|
|
403
410
|
cmd += ["-o", str(output)]
|
|
404
|
-
file_outputs[
|
|
405
|
-
output
|
|
406
|
-
|
|
411
|
+
file_outputs[output.replace(".", "_")] = (
|
|
412
|
+
f"/tmp/{output}" # not using path.join to avoid windows "\"
|
|
413
|
+
)
|
|
407
414
|
if project:
|
|
408
415
|
cmd += ["--project", project]
|
|
409
416
|
if handler:
|
|
@@ -450,8 +457,10 @@ def mlrun_op(
|
|
|
450
457
|
command=cmd + [command],
|
|
451
458
|
file_outputs=file_outputs,
|
|
452
459
|
output_artifact_paths={
|
|
453
|
-
"mlpipeline-ui-metadata":
|
|
454
|
-
|
|
460
|
+
"mlpipeline-ui-metadata": os.path.join(
|
|
461
|
+
KFPMETA_DIR, "mlpipeline-ui-metadata.json"
|
|
462
|
+
),
|
|
463
|
+
"mlpipeline-metrics": os.path.join(KFPMETA_DIR, "mlpipeline-metrics.json"),
|
|
455
464
|
},
|
|
456
465
|
)
|
|
457
466
|
cop = add_default_function_resources(cop)
|
mlrun/model.py
CHANGED
|
@@ -501,6 +501,7 @@ class ImageBuilder(ModelObj):
|
|
|
501
501
|
requirements: list = None,
|
|
502
502
|
extra_args=None,
|
|
503
503
|
builder_env=None,
|
|
504
|
+
source_code_target_dir=None,
|
|
504
505
|
):
|
|
505
506
|
self.functionSourceCode = functionSourceCode #: functionSourceCode
|
|
506
507
|
self.codeEntryType = "" #: codeEntryType
|
|
@@ -521,6 +522,7 @@ class ImageBuilder(ModelObj):
|
|
|
521
522
|
self.auto_build = auto_build #: auto_build
|
|
522
523
|
self.build_pod = None
|
|
523
524
|
self.requirements = requirements or [] #: pip requirements
|
|
525
|
+
self.source_code_target_dir = source_code_target_dir or None
|
|
524
526
|
|
|
525
527
|
@property
|
|
526
528
|
def source(self):
|
|
@@ -557,6 +559,7 @@ class ImageBuilder(ModelObj):
|
|
|
557
559
|
overwrite=False,
|
|
558
560
|
builder_env=None,
|
|
559
561
|
extra_args=None,
|
|
562
|
+
source_code_target_dir=None,
|
|
560
563
|
):
|
|
561
564
|
if image:
|
|
562
565
|
self.image = image
|
|
@@ -582,6 +585,8 @@ class ImageBuilder(ModelObj):
|
|
|
582
585
|
self.builder_env = builder_env
|
|
583
586
|
if extra_args:
|
|
584
587
|
self.extra_args = extra_args
|
|
588
|
+
if source_code_target_dir:
|
|
589
|
+
self.source_code_target_dir = source_code_target_dir
|
|
585
590
|
|
|
586
591
|
def with_commands(
|
|
587
592
|
self,
|
mlrun/model_monitoring/api.py
CHANGED
|
@@ -436,9 +436,9 @@ def _generate_model_endpoint(
|
|
|
436
436
|
] = possible_drift_threshold
|
|
437
437
|
|
|
438
438
|
model_endpoint.spec.monitoring_mode = monitoring_mode
|
|
439
|
-
model_endpoint.status.first_request = (
|
|
440
|
-
|
|
441
|
-
)
|
|
439
|
+
model_endpoint.status.first_request = model_endpoint.status.last_request = (
|
|
440
|
+
datetime_now().isoformat()
|
|
441
|
+
)
|
|
442
442
|
if sample_set_statistics:
|
|
443
443
|
model_endpoint.status.feature_stats = sample_set_statistics
|
|
444
444
|
|
|
@@ -267,7 +267,7 @@ class PushToMonitoringWriter(StepToDict):
|
|
|
267
267
|
self.project = project
|
|
268
268
|
self.application_name_to_push = writer_application_name
|
|
269
269
|
self.stream_uri = stream_uri or get_stream_path(
|
|
270
|
-
project=self.project,
|
|
270
|
+
project=self.project, function_name=self.application_name_to_push
|
|
271
271
|
)
|
|
272
272
|
self.output_stream = None
|
|
273
273
|
self.name = name or "PushToMonitoringWriter"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2024 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.
|