mlrun 1.7.1rc2__py3-none-any.whl → 1.7.1rc5__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.

@@ -104,32 +104,32 @@ class OutputStream:
104
104
  self._mock = mock
105
105
  self._mock_queue = []
106
106
 
107
+ def create_stream(self):
108
+ # this import creates an import loop via the utils module, so putting it in execution path
109
+ from mlrun.utils.helpers import logger
110
+
111
+ logger.debug(
112
+ "Creating output stream",
113
+ endpoint=self._endpoint,
114
+ container=self._container,
115
+ stream_path=self._stream_path,
116
+ shards=self._shards,
117
+ retention_in_hours=self._retention_in_hours,
118
+ )
119
+ response = self._v3io_client.stream.create(
120
+ container=self._container,
121
+ stream_path=self._stream_path,
122
+ shard_count=self._shards or 1,
123
+ retention_period_hours=self._retention_in_hours or 24,
124
+ raise_for_status=v3io.dataplane.RaiseForStatus.never,
125
+ )
126
+ if not (response.status_code == 400 and "ResourceInUse" in str(response.body)):
127
+ response.raise_for_status([409, 204])
128
+
107
129
  def _lazy_init(self):
108
130
  if self._create and not self._mock:
109
- # this import creates an import loop via the utils module, so putting it in execution path
110
- from mlrun.utils.helpers import logger
111
-
112
131
  self._create = False
113
-
114
- logger.debug(
115
- "Creating output stream",
116
- endpoint=self._endpoint,
117
- container=self._container,
118
- stream_path=self._stream_path,
119
- shards=self._shards,
120
- retention_in_hours=self._retention_in_hours,
121
- )
122
- response = self._v3io_client.stream.create(
123
- container=self._container,
124
- stream_path=self._stream_path,
125
- shard_count=self._shards or 1,
126
- retention_period_hours=self._retention_in_hours or 24,
127
- raise_for_status=v3io.dataplane.RaiseForStatus.never,
128
- )
129
- if not (
130
- response.status_code == 400 and "ResourceInUse" in str(response.body)
131
- ):
132
- response.raise_for_status([409, 204])
132
+ self.create_stream()
133
133
 
134
134
  def push(self, data, partition_key=None):
135
135
  self._lazy_init()
@@ -984,14 +984,16 @@ def github_webhook(request):
984
984
  return {"msg": "pushed"}
985
985
 
986
986
 
987
- def load_and_run(*args, **kwargs):
987
+ def load_and_run(context, *args, **kwargs):
988
988
  """
989
989
  This function serves as an alias to `load_and_run_workflow`,
990
990
  allowing to continue using `load_and_run` without modifying existing workflows or exported runs.
991
991
  This approach ensures backward compatibility,
992
992
  while directing all new calls to the updated `load_and_run_workflow` function.
993
993
  """
994
- load_and_run_workflow(kwargs.pop("load_only", None))
994
+ kwargs.pop("load_only", None)
995
+ kwargs.pop("save", None)
996
+ load_and_run_workflow(context, *args, **kwargs)
995
997
 
996
998
 
997
999
  def load_and_run_workflow(
@@ -607,7 +607,7 @@ class ServingRuntime(RemoteRuntime):
607
607
  ):
608
608
  # initialize or create required streams/queues
609
609
  self.spec.graph.check_and_process_graph()
610
- self.spec.graph.init_queues()
610
+ self.spec.graph.create_queue_streams()
611
611
  functions_in_steps = self.spec.graph.list_child_functions()
612
612
  child_functions = list(self._spec.function_refs.keys())
613
613
  for function in functions_in_steps:
mlrun/serving/routers.py CHANGED
@@ -491,6 +491,7 @@ class VotingEnsemble(ParallelRun):
491
491
  executor_type: Union[ParallelRunnerModes, str] = ParallelRunnerModes.thread,
492
492
  format_response_with_col_name_flag: bool = False,
493
493
  prediction_col_name: str = "prediction",
494
+ shard_by_endpoint: typing.Optional[bool] = None,
494
495
  **kwargs,
495
496
  ):
496
497
  """Voting Ensemble
@@ -580,6 +581,8 @@ class VotingEnsemble(ParallelRun):
580
581
  `{id: <id>, model_name: <name>, outputs: {..., prediction: [<predictions>], ...}}`
581
582
  the prediction_col_name should be `prediction`.
582
583
  by default, `prediction`
584
+ :param shard_by_endpoint: whether to use the endpoint as the partition/sharding key when writing to model
585
+ monitoring stream. Defaults to True.
583
586
  :param kwargs: extra arguments
584
587
  """
585
588
  super().__init__(
@@ -606,6 +609,7 @@ class VotingEnsemble(ParallelRun):
606
609
  self.prediction_col_name = prediction_col_name or "prediction"
607
610
  self.format_response_with_col_name_flag = format_response_with_col_name_flag
608
611
  self.model_endpoint_uid = None
612
+ self.shard_by_endpoint = shard_by_endpoint
609
613
 
610
614
  def post_init(self, mode="sync"):
611
615
  server = getattr(self.context, "_server", None) or getattr(
@@ -907,7 +911,12 @@ class VotingEnsemble(ParallelRun):
907
911
  if self._model_logger and self.log_router:
908
912
  if "id" not in request:
909
913
  request["id"] = response.body["id"]
910
- self._model_logger.push(start, request, response.body)
914
+ partition_key = (
915
+ self.model_endpoint_uid if self.shard_by_endpoint is not False else None
916
+ )
917
+ self._model_logger.push(
918
+ start, request, response.body, partition_key=partition_key
919
+ )
911
920
  event.body = _update_result_body(
912
921
  self._result_path, original_body, response.body if response else None
913
922
  )
mlrun/serving/states.py CHANGED
@@ -839,6 +839,8 @@ class QueueStep(BaseStep):
839
839
  retention_in_hours=self.retention_in_hours,
840
840
  **self.options,
841
841
  )
842
+ if hasattr(self._stream, "create_stream"):
843
+ self._stream.create_stream()
842
844
  self._set_error_handler()
843
845
 
844
846
  @property
@@ -1247,8 +1249,8 @@ class FlowStep(BaseStep):
1247
1249
  links[next_step.function] = step
1248
1250
  return links
1249
1251
 
1250
- def init_queues(self):
1251
- """init/create the streams used in this flow"""
1252
+ def create_queue_streams(self):
1253
+ """create the streams used in this flow"""
1252
1254
  for step in self.get_children():
1253
1255
  if step.kind == StepKinds.queue:
1254
1256
  step.init_object(self.context, None)
mlrun/utils/helpers.py CHANGED
@@ -1226,14 +1226,24 @@ def datetime_to_iso(time_obj: Optional[datetime]) -> Optional[str]:
1226
1226
  return time_obj.isoformat()
1227
1227
 
1228
1228
 
1229
- def enrich_datetime_with_tz_info(timestamp_string):
1229
+ def enrich_datetime_with_tz_info(timestamp_string) -> Optional[datetime]:
1230
1230
  if not timestamp_string:
1231
1231
  return timestamp_string
1232
1232
 
1233
1233
  if timestamp_string and not mlrun.utils.helpers.has_timezone(timestamp_string):
1234
1234
  timestamp_string += datetime.now(timezone.utc).astimezone().strftime("%z")
1235
1235
 
1236
- return datetime.strptime(timestamp_string, "%Y-%m-%d %H:%M:%S.%f%z")
1236
+ for _format in [
1237
+ # e.g: 2021-08-25 12:00:00.000Z
1238
+ "%Y-%m-%d %H:%M:%S.%f%z",
1239
+ # e.g: 2024-11-11 07:44:56+0000
1240
+ "%Y-%m-%d %H:%M:%S%z",
1241
+ ]:
1242
+ try:
1243
+ return datetime.strptime(timestamp_string, _format)
1244
+ except ValueError as exc:
1245
+ last_exc = exc
1246
+ raise last_exc
1237
1247
 
1238
1248
 
1239
1249
  def has_timezone(timestamp):
@@ -1,4 +1,4 @@
1
1
  {
2
- "git_commit": "e31c876608ddb9f2760ea3bcd6b4feb901d923a0",
3
- "version": "1.7.1-rc2"
2
+ "git_commit": "78a33ec69a4233a45fa075aecbe3597bd584a3c0",
3
+ "version": "1.7.1-rc5"
4
4
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mlrun
3
- Version: 1.7.1rc2
3
+ Version: 1.7.1rc5
4
4
  Summary: Tracking and config of machine learning runs
5
5
  Home-page: https://github.com/mlrun/mlrun
6
6
  Author: Yaron Haviv
@@ -269,10 +269,10 @@ mlrun/package/utils/_supported_format.py,sha256=O3LPTvZ6A-nGi6mB2kTzJp2DQ-cCOgnl
269
269
  mlrun/package/utils/log_hint_utils.py,sha256=40X7oVzCiAIGsTTSON0iYNHj-_1Y4l4SDMThTA85If8,3696
270
270
  mlrun/package/utils/type_hint_utils.py,sha256=JYrek6vuN3z7e6MGUD3qBLDfQ03C4puZXNTpDSj-VrM,14695
271
271
  mlrun/platforms/__init__.py,sha256=ggSGF7inITs6S-vj9u4S9X_5psgbA0G3GVqf7zu8qYc,2406
272
- mlrun/platforms/iguazio.py,sha256=s_I9zf1IiMS7Rv6b7umQm5LBW-4rDdLqzhbWd5Ve0u0,13741
272
+ mlrun/platforms/iguazio.py,sha256=MNRzIzxcc_3wsePLjBXuKKKSaObVnnrC3ZyXgSRu8m0,13697
273
273
  mlrun/projects/__init__.py,sha256=0Krf0WIKfnZa71WthYOg0SoaTodGg3sV_hK3f_OlTPI,1220
274
274
  mlrun/projects/operations.py,sha256=gtqSU9OvYOV-b681uQtWgnW7YSnX6qfa1Mt1Xm4f1ZI,19752
275
- mlrun/projects/pipelines.py,sha256=IE8MpuXPnXi0_izOCEC1dtpEctcdWZUyCADnMvAZH0M,45331
275
+ mlrun/projects/pipelines.py,sha256=6_EPuKQ5pN1z-3UgyGeMyDZU1hrkkgv7Fgh5KGE074Q,45398
276
276
  mlrun/projects/project.py,sha256=UOu625oJUwJA9o--MboL19Zvqv_xDqO9oCx-0Rs_Khk,191436
277
277
  mlrun/runtimes/__init__.py,sha256=egLM94cDMUyQ1GVABdFGXUQcDhU70lP3k7qSnM_UnHY,9008
278
278
  mlrun/runtimes/base.py,sha256=JXWmTIcm3b0klGUOHDlyFNa3bUgsNzQIgWhUQpSZoE0,37692
@@ -296,7 +296,7 @@ mlrun/runtimes/nuclio/__init__.py,sha256=gx1kizzKv8pGT5TNloN1js1hdbxqDw3rM90sLVY
296
296
  mlrun/runtimes/nuclio/api_gateway.py,sha256=oQRSOvqtODKCzT2LqlqSXZbq2vcZ7epsFZwO9jvarhc,26899
297
297
  mlrun/runtimes/nuclio/function.py,sha256=TQt6RyxK_iyzNJr2r57BRtVXuy2GMrhdeFOlFjb2AZg,52106
298
298
  mlrun/runtimes/nuclio/nuclio.py,sha256=sLK8KdGO1LbftlL3HqPZlFOFTAAuxJACZCVl1c0Ha6E,2942
299
- mlrun/runtimes/nuclio/serving.py,sha256=Tsv-MssXJPe4di9stVOAyCj2MTMI7zQxvtFbAgdAtu0,29717
299
+ mlrun/runtimes/nuclio/serving.py,sha256=L1Tz5EZyo8JZmUBNmIRYL9AoWfqSm4zLQQ9DWbnlmp8,29726
300
300
  mlrun/runtimes/nuclio/application/__init__.py,sha256=rRs5vasy_G9IyoTpYIjYDafGoL6ifFBKgBtsXn31Atw,614
301
301
  mlrun/runtimes/nuclio/application/application.py,sha256=5XFIg7tgU9kKWwGdMFwB1OJpw79BWwlWUdGiHlDo4AY,29055
302
302
  mlrun/runtimes/nuclio/application/reverse_proxy.go,sha256=JIIYae6bXzCLf3jXuu49KWPQYoXr_FDQ2Rbo1OWKAd0,3150
@@ -305,10 +305,10 @@ mlrun/runtimes/sparkjob/spark3job.py,sha256=RuwO9Pk1IFaUCFz8zoYLaK3pYT7w07uAjouc
305
305
  mlrun/serving/__init__.py,sha256=-SMRV3q_5cGVPDxRslXPU0zGYZIygs0cSj7WKlOJJUc,1163
306
306
  mlrun/serving/merger.py,sha256=PXLn3A21FiLteJHaDSLm5xKNT-80eTTjfHUJnBX1gKY,6116
307
307
  mlrun/serving/remote.py,sha256=MrFByphQWmIsKXqw-MOwl2Q1hbtWReYVRKvlcKj9pfw,17980
308
- mlrun/serving/routers.py,sha256=el3-pfh7jXdnobt229jbMagD4WA-elp_ejX54VZQg6k,55347
308
+ mlrun/serving/routers.py,sha256=aJHO-063gaQ1N3vRDXQwKJ5zwy_X9q3RIq5CjsuCOG8,55832
309
309
  mlrun/serving/server.py,sha256=m1HzUDconjowDtheQ71HEKbV7e9A-TUtaCdoqxTH2Pw,22092
310
310
  mlrun/serving/serving_wrapper.py,sha256=R670-S6PX_d5ER6jiHtRvacuPyFzQH0mEf2K0sBIIOM,836
311
- mlrun/serving/states.py,sha256=e4QGSAnNq_eLPDoojxkMkw7fLgUST5ea_BQTO7jWsTA,60228
311
+ mlrun/serving/states.py,sha256=uajsgqmf1qBkkm6es4hb9c1hUARKHUBDqxVmDFEbPLo,60332
312
312
  mlrun/serving/utils.py,sha256=lej7XcUPX1MmHkEOi_0KZRGSpfbmpnE0GK_Sn4zLkHY,4025
313
313
  mlrun/serving/v1_serving.py,sha256=by4myxlnwyZ0ijQ5fURilGCK1sUpdQL2Il1VR3Xqpxg,11805
314
314
  mlrun/serving/v2_serving.py,sha256=y48sMhSmZwwHAeTaqdeaxeRag3hkZH1nDolx5CS8VbU,26379
@@ -323,7 +323,7 @@ mlrun/utils/azure_vault.py,sha256=IEFizrDGDbAaoWwDr1WoA88S_EZ0T--vjYtY-i0cvYQ,34
323
323
  mlrun/utils/clones.py,sha256=mJpx4nyFiY6jlBCvFABsNuyi_mr1mvfPWn81vlafpOU,7361
324
324
  mlrun/utils/condition_evaluator.py,sha256=-nGfRmZzivn01rHTroiGY4rqEv8T1irMyhzxEei-sKc,1897
325
325
  mlrun/utils/db.py,sha256=blQgkWMfFH9lcN4sgJQcPQgEETz2Dl_zwbVA0SslpFg,2186
326
- mlrun/utils/helpers.py,sha256=F2hrR3748PTbFCzvckakACSjzL2ZypqEekTMldizxr0,61146
326
+ mlrun/utils/helpers.py,sha256=bYgoOLM_Yire6idrqcz_XIa-bFKE72OomxrHWSgmGWQ,61425
327
327
  mlrun/utils/http.py,sha256=t6FrXQstZm9xVVjxqIGiLzrwZNCR4CSienSOuVgNIcI,8706
328
328
  mlrun/utils/logger.py,sha256=cag2J30-jynIHmHZ2J8RYmVMNhYBGgAoimc5sbk-A1U,10016
329
329
  mlrun/utils/regex.py,sha256=b0AUa2THS-ELzJj0grl5b8Stq609F2XomTZkD9SB1fQ,4900
@@ -341,11 +341,11 @@ mlrun/utils/notifications/notification/ipython.py,sha256=ZtVL30B_Ha0VGoo4LxO-voT
341
341
  mlrun/utils/notifications/notification/slack.py,sha256=wqpFGr5BTvFO5KuUSzFfxsgmyU1Ohq7fbrGeNe9TXOk,7006
342
342
  mlrun/utils/notifications/notification/webhook.py,sha256=cb9w1Mc8ENfJBdgan7iiVHK9eVls4-R3tUxmXM-P-8I,4746
343
343
  mlrun/utils/version/__init__.py,sha256=7kkrB7hEZ3cLXoWj1kPoDwo4MaswsI2JVOBpbKgPAgc,614
344
- mlrun/utils/version/version.json,sha256=D4idbmZRoOSf9434CduO0fir5zz0S4XOvHurnme_XUY,88
344
+ mlrun/utils/version/version.json,sha256=xd2abWgGQl7rN-nzls-IJ6_5UTRylXfPDwAi7dXwblo,88
345
345
  mlrun/utils/version/version.py,sha256=eEW0tqIAkU9Xifxv8Z9_qsYnNhn3YH7NRAfM-pPLt1g,1878
346
- mlrun-1.7.1rc2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
347
- mlrun-1.7.1rc2.dist-info/METADATA,sha256=EbfTMAW4TIWdT5UGjJq1G1pwhFCIZ8nq5NI_kntKdM8,24486
348
- mlrun-1.7.1rc2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
349
- mlrun-1.7.1rc2.dist-info/entry_points.txt,sha256=1Owd16eAclD5pfRCoJpYC2ZJSyGNTtUr0nCELMioMmU,46
350
- mlrun-1.7.1rc2.dist-info/top_level.txt,sha256=NObLzw3maSF9wVrgSeYBv-fgnHkAJ1kEkh12DLdd5KM,6
351
- mlrun-1.7.1rc2.dist-info/RECORD,,
346
+ mlrun-1.7.1rc5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
347
+ mlrun-1.7.1rc5.dist-info/METADATA,sha256=DnE7Td3ao4a-shSHuUXKDgSiit_wDgDpmzoQTTPOBbs,24486
348
+ mlrun-1.7.1rc5.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
349
+ mlrun-1.7.1rc5.dist-info/entry_points.txt,sha256=1Owd16eAclD5pfRCoJpYC2ZJSyGNTtUr0nCELMioMmU,46
350
+ mlrun-1.7.1rc5.dist-info/top_level.txt,sha256=NObLzw3maSF9wVrgSeYBv-fgnHkAJ1kEkh12DLdd5KM,6
351
+ mlrun-1.7.1rc5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.5.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5