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.

Files changed (70) hide show
  1. mlrun/artifacts/manager.py +6 -1
  2. mlrun/common/constants.py +1 -0
  3. mlrun/common/model_monitoring/helpers.py +12 -6
  4. mlrun/common/schemas/__init__.py +1 -0
  5. mlrun/common/schemas/client_spec.py +1 -0
  6. mlrun/common/schemas/common.py +40 -0
  7. mlrun/common/schemas/model_monitoring/constants.py +4 -1
  8. mlrun/common/schemas/project.py +2 -0
  9. mlrun/config.py +20 -16
  10. mlrun/datastore/azure_blob.py +22 -9
  11. mlrun/datastore/base.py +15 -25
  12. mlrun/datastore/datastore.py +19 -8
  13. mlrun/datastore/datastore_profile.py +47 -5
  14. mlrun/datastore/google_cloud_storage.py +10 -6
  15. mlrun/datastore/hdfs.py +51 -0
  16. mlrun/datastore/redis.py +4 -0
  17. mlrun/datastore/s3.py +4 -0
  18. mlrun/datastore/sources.py +31 -50
  19. mlrun/datastore/targets.py +58 -48
  20. mlrun/datastore/utils.py +2 -49
  21. mlrun/datastore/v3io.py +4 -0
  22. mlrun/db/base.py +34 -0
  23. mlrun/db/httpdb.py +71 -42
  24. mlrun/execution.py +3 -3
  25. mlrun/feature_store/feature_vector.py +2 -2
  26. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +3 -3
  27. mlrun/frameworks/tf_keras/model_handler.py +7 -7
  28. mlrun/k8s_utils.py +10 -5
  29. mlrun/kfpops.py +19 -10
  30. mlrun/model.py +5 -0
  31. mlrun/model_monitoring/api.py +3 -3
  32. mlrun/model_monitoring/application.py +1 -1
  33. mlrun/model_monitoring/applications/__init__.py +13 -0
  34. mlrun/model_monitoring/applications/histogram_data_drift.py +218 -0
  35. mlrun/model_monitoring/batch.py +9 -111
  36. mlrun/model_monitoring/controller.py +73 -55
  37. mlrun/model_monitoring/controller_handler.py +13 -5
  38. mlrun/model_monitoring/features_drift_table.py +62 -53
  39. mlrun/model_monitoring/helpers.py +30 -21
  40. mlrun/model_monitoring/metrics/__init__.py +13 -0
  41. mlrun/model_monitoring/metrics/histogram_distance.py +127 -0
  42. mlrun/model_monitoring/stores/kv_model_endpoint_store.py +14 -14
  43. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -1
  44. mlrun/package/packagers/pandas_packagers.py +3 -3
  45. mlrun/package/utils/_archiver.py +3 -1
  46. mlrun/platforms/iguazio.py +8 -65
  47. mlrun/projects/pipelines.py +21 -11
  48. mlrun/projects/project.py +121 -42
  49. mlrun/runtimes/base.py +21 -2
  50. mlrun/runtimes/kubejob.py +5 -3
  51. mlrun/runtimes/local.py +2 -2
  52. mlrun/runtimes/mpijob/abstract.py +6 -6
  53. mlrun/runtimes/nuclio/function.py +9 -9
  54. mlrun/runtimes/nuclio/serving.py +3 -3
  55. mlrun/runtimes/pod.py +3 -3
  56. mlrun/runtimes/sparkjob/spark3job.py +3 -3
  57. mlrun/serving/remote.py +4 -2
  58. mlrun/serving/server.py +15 -18
  59. mlrun/serving/states.py +27 -12
  60. mlrun/utils/async_http.py +3 -3
  61. mlrun/utils/helpers.py +27 -5
  62. mlrun/utils/http.py +3 -3
  63. mlrun/utils/notifications/notification_pusher.py +6 -6
  64. mlrun/utils/version/version.json +2 -2
  65. {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/METADATA +13 -16
  66. {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/RECORD +70 -64
  67. {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/LICENSE +0 -0
  68. {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/WHEEL +0 -0
  69. {mlrun-1.7.0rc2.dist-info → mlrun-1.7.0rc4.dist-info}/entry_points.txt +0 -0
  70. {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 mlconf,
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, url, timeout=timeout, verify=False, **kw
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 - ``mlconf.dbpath``.
309
+ The code utilizes the URL for the API server from the configuration - ``config.dbpath``.
306
310
 
307
311
  For example::
308
312
 
309
- mlconf.dbpath = mlconf.dbpath or 'http://mlrun-api:8080'
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(mlrun.mlconf.httpdb.logs.pull_logs_default_size_limit)
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=mlrun.mlconf.httpdb.logs.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(mlrun.mlconf.httpdb.logs.pull_logs_default_interval))
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=mlrun.mlconf.httpdb.logs.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
- job_id
1140
- ] = mlrun.common.schemas.RuntimeResources(**runtime_resources)
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
- kind
1148
- ] = mlrun.common.schemas.RuntimeResources(**runtime_resources)
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 (defaults to mlrun.mlconf.runtime_resources_deletion_grace_period).
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
- kind
1208
- ] = mlrun.common.schemas.RuntimeResources(**runtime_resources)
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.mlconf.httpdb.builder.docker_registry_secret). "
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.mlconf.default_project).
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 create_model_monitoring_controller(
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
- Submit model monitoring application controller job along with deploying the model monitoring writer function.
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 default_controller_image: The default image of the model monitoring controller job. Note that the writer
3088
- function, which is a real time nuclio functino, will be deployed with the same
3089
- image. By default, the image is mlrun/mlrun.
3090
- :param base_period: Minutes to determine the frequency in which the model monitoring controller job
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
- "default_controller_image": default_controller_image,
3098
+ "image": image,
3098
3099
  "base_period": base_period,
3099
3100
  }
3100
- path = f"projects/{project}/jobs/model-monitoring-controller"
3101
+ path = f"projects/{project}/model-monitoring/model-monitoring-controller"
3102
+ self.api_call(method="POST", path=path, params=params)
3101
3103
 
3102
- resp = self.api_call(method="POST", path=path, params=params)
3103
- return resp.json()["func"]
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["metadata"]["key"]
564
- ] = artifact
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 = fstore.get_offline_features(vector).to_dataframe()
493
+ df = vector.get_offline_features().to_dataframe()
494
494
 
495
495
  # return an online/real-time feature service
496
- svc = fstore.get_online_feature_service(vector, impute_policy={"*": "$mean"})
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
- learning_rate_key
394
- ] = learning_rate_key_chain
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._get_weights_file_artifact_name()
268
- ] = self._context.log_artifact(
269
- self._weights_file,
270
- local_path=self._weights_file,
271
- artifact_path=output_path,
272
- db_key=False,
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 = os.environ.get("KFPMETA_OUT_DIR", "/tmp")
45
- KFP_ARTIFACTS_DIR = os.environ.get("KFP_ARTIFACTS_DIR", "/tmp")
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 + "/mlpipeline-metrics.json", "w") as f:
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
- path = "/".join([KFP_ARTIFACTS_DIR, key])
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 + "/mlpipeline-ui-metadata.json", "w") as f:
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.replace(".", "_")
406
- ] = f"/tmp/{output}" # not using path.join to avoid windows "\"
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": KFPMETA_DIR + "/mlpipeline-ui-metadata.json",
454
- "mlpipeline-metrics": KFPMETA_DIR + "/mlpipeline-metrics.json",
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,
@@ -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
- model_endpoint.status.last_request
441
- ) = datetime_now().isoformat()
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, application_name=self.application_name_to_push
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.