prefect-client 2.14.12__py3-none-any.whl → 2.14.13__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.
prefect/tasks.py CHANGED
@@ -173,6 +173,10 @@ class Task(Generic[P, R]):
173
173
  execution with matching cache key is used.
174
174
  on_failure: An optional list of callables to run when the task enters a failed state.
175
175
  on_completion: An optional list of callables to run when the task enters a completed state.
176
+ retry_condition_fn: An optional callable run when a task run returns a Failed state. Should
177
+ return `True` if the task should continue to its retry policy (e.g. `retries=3`), and `False` if the task
178
+ should end as failed. Defaults to `None`, indicating the task should always continue
179
+ to its retry policy.
176
180
  viz_return_value: An optional value to return when the task dependency tree is visualized.
177
181
  """
178
182
 
@@ -210,6 +214,7 @@ class Task(Generic[P, R]):
210
214
  refresh_cache: Optional[bool] = None,
211
215
  on_completion: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
212
216
  on_failure: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
217
+ retry_condition_fn: Optional[Callable[["Task", TaskRun, State], bool]] = None,
213
218
  viz_return_value: Optional[Any] = None,
214
219
  ):
215
220
  # Validate if hook passed is list and contains callables
@@ -337,6 +342,15 @@ class Task(Generic[P, R]):
337
342
  )
338
343
  self.on_completion = on_completion
339
344
  self.on_failure = on_failure
345
+
346
+ # retry_condition_fn must be a callable or None. If it is neither, raise a TypeError
347
+ if retry_condition_fn is not None and not (callable(retry_condition_fn)):
348
+ raise TypeError(
349
+ "Expected `retry_condition_fn` to be callable, got"
350
+ f" {type(retry_condition_fn).__name__} instead."
351
+ )
352
+
353
+ self.retry_condition_fn = retry_condition_fn
340
354
  self.viz_return_value = viz_return_value
341
355
 
342
356
  def with_options(
@@ -368,6 +382,7 @@ class Task(Generic[P, R]):
368
382
  refresh_cache: Optional[bool] = NotSet,
369
383
  on_completion: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
370
384
  on_failure: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
385
+ retry_condition_fn: Optional[Callable[["Task", TaskRun, State], bool]] = None,
371
386
  viz_return_value: Optional[Any] = None,
372
387
  ):
373
388
  """
@@ -403,6 +418,10 @@ class Task(Generic[P, R]):
403
418
  refresh_cache: A new option for enabling or disabling cache refresh.
404
419
  on_completion: A new list of callables to run when the task enters a completed state.
405
420
  on_failure: A new list of callables to run when the task enters a failed state.
421
+ retry_condition_fn: An optional callable run when a task run returns a Failed state.
422
+ Should return `True` if the task should continue to its retry policy, and `False`
423
+ if the task should end as failed. Defaults to `None`, indicating the task should
424
+ always continue to its retry policy.
406
425
  viz_return_value: An optional value to return when the task dependency tree is visualized.
407
426
 
408
427
  Returns:
@@ -491,6 +510,7 @@ class Task(Generic[P, R]):
491
510
  ),
492
511
  on_completion=on_completion or self.on_completion,
493
512
  on_failure=on_failure or self.on_failure,
513
+ retry_condition_fn=retry_condition_fn or self.retry_condition_fn,
494
514
  viz_return_value=viz_return_value or self.viz_return_value,
495
515
  )
496
516
 
@@ -969,6 +989,7 @@ def task(
969
989
  refresh_cache: Optional[bool] = None,
970
990
  on_completion: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
971
991
  on_failure: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
992
+ retry_condition_fn: Optional[Callable[["Task", TaskRun, State], bool]] = None,
972
993
  viz_return_value: Any = None,
973
994
  ) -> Callable[[Callable[P, R]], Task[P, R]]:
974
995
  ...
@@ -1002,6 +1023,7 @@ def task(
1002
1023
  refresh_cache: Optional[bool] = None,
1003
1024
  on_completion: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
1004
1025
  on_failure: Optional[List[Callable[["Task", TaskRun, State], None]]] = None,
1026
+ retry_condition_fn: Optional[Callable[["Task", TaskRun, State], bool]] = None,
1005
1027
  viz_return_value: Any = None,
1006
1028
  ):
1007
1029
  """
@@ -1058,6 +1080,10 @@ def task(
1058
1080
  execution with matching cache key is used.
1059
1081
  on_failure: An optional list of callables to run when the task enters a failed state.
1060
1082
  on_completion: An optional list of callables to run when the task enters a completed state.
1083
+ retry_condition_fn: An optional callable run when a task run returns a Failed state. Should
1084
+ return `True` if the task should continue to its retry policy (e.g. `retries=3`), and `False` if the task
1085
+ should end as failed. Defaults to `None`, indicating the task should always continue
1086
+ to its retry policy.
1061
1087
  viz_return_value: An optional value to return when the task dependency tree is visualized.
1062
1088
 
1063
1089
  Returns:
@@ -1134,6 +1160,7 @@ def task(
1134
1160
  refresh_cache=refresh_cache,
1135
1161
  on_completion=on_completion,
1136
1162
  on_failure=on_failure,
1163
+ retry_condition_fn=retry_condition_fn,
1137
1164
  viz_return_value=viz_return_value,
1138
1165
  ),
1139
1166
  )
@@ -1162,6 +1189,7 @@ def task(
1162
1189
  refresh_cache=refresh_cache,
1163
1190
  on_completion=on_completion,
1164
1191
  on_failure=on_failure,
1192
+ retry_condition_fn=retry_condition_fn,
1165
1193
  viz_return_value=viz_return_value,
1166
1194
  ),
1167
1195
  )
@@ -3,6 +3,7 @@ import os
3
3
  import signal
4
4
  import subprocess
5
5
  import sys
6
+ import threading
6
7
  from contextlib import asynccontextmanager
7
8
  from dataclasses import dataclass
8
9
  from functools import partial
@@ -318,6 +319,11 @@ async def stream_text(source: TextReceiveStream, *sinks: TextSink):
318
319
  raise TypeError(f"Unsupported sink type {type(sink).__name__}")
319
320
 
320
321
 
322
+ def _register_signal(signum: int, handler: Callable):
323
+ if threading.current_thread() is threading.main_thread():
324
+ signal.signal(signum, handler)
325
+
326
+
321
327
  def forward_signal_handler(
322
328
  pid: int, signum: int, *signums: int, process_name: str, print_fn: Callable
323
329
  ):
@@ -349,7 +355,7 @@ def forward_signal_handler(
349
355
  )
350
356
 
351
357
  # register current and future signal handlers
352
- signal.signal(signum, handler)
358
+ _register_signal(signum, handler)
353
359
 
354
360
 
355
361
  def setup_signal_handlers_server(pid: int, process_name: str, print_fn: Callable):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefect-client
3
- Version: 2.14.12
3
+ Version: 2.14.13
4
4
  Summary: Workflow orchestration and management.
5
5
  Home-page: https://www.prefect.io
6
6
  Author: Prefect Technologies, Inc.
@@ -3,10 +3,10 @@ prefect/__init__.py,sha256=eomMSkMZMHSV8oRTV0HX3XwoKm0sdm_UmbEqX7rqhnU,5143
3
3
  prefect/_version.py,sha256=fQguBh1dzT7Baahj504O5RrsLlSyg3Zrx42OpgdPnFc,22378
4
4
  prefect/agent.py,sha256=b557LEcKxcBrgAGOlEDlOPclAkucDj1RhzywBSYxYpI,27487
5
5
  prefect/context.py,sha256=61IwPuOCIpYIHtgjz7ADe_-s2Zy8QD6RezWwAKl3Ytk,17774
6
- prefect/engine.py,sha256=gwUAXtltyxcNf-HWETwe1g8za1zlQOwob5YSZSH87so,103529
6
+ prefect/engine.py,sha256=cBl5xQrIkaYBd6GovBxWxsqEmGW4nFR85FuRCRykeJc,105607
7
7
  prefect/exceptions.py,sha256=AtYh--XOUJujutX9r355eDjln27fUBFQXG0slOPWPcY,10840
8
8
  prefect/filesystems.py,sha256=X0M8_jddar7j1JtdEZgyDTX_8EVNJUYYs-Dat48GUhE,34101
9
- prefect/flows.py,sha256=vkIEYd8_F6NZ4s0ZC4O5jCIxrsIcLBT_Tjz5sPiIEhU,64136
9
+ prefect/flows.py,sha256=08xZSLHcFOqTMhIirp4Nc8bc9tYfi9S3G-J1tBjqRBw,64228
10
10
  prefect/futures.py,sha256=uqNlykBSRrXQO1pQ6mZWLMqwkFCLhvMLrEFR4eHs--I,12589
11
11
  prefect/manifests.py,sha256=xfwEEozSEqPK2Lro4dfgdTnjVbQx-aCECNBnf7vO7ZQ,808
12
12
  prefect/plugins.py,sha256=0C-D3-dKi06JZ44XEGmLjCiAkefbE_lKX-g3urzdbQ4,4163
@@ -17,7 +17,7 @@ prefect/serializers.py,sha256=sSbe40Ipj-d6VuzBae5k2ao9lkMUZpIXcLtD7f2a7cE,10852
17
17
  prefect/settings.py,sha256=sS91SR85wBo-2V8kU2QzEh1tj_kMb4Z5gvoQ-Rtw1KY,64632
18
18
  prefect/states.py,sha256=-Ud4AUom3Qu-HQ4hOLvfVZuuF-b_ibaqtzmL7V949Ac,20839
19
19
  prefect/task_runners.py,sha256=HXUg5UqhZRN2QNBqMdGE1lKhwFhT8TaRN75ScgLbnw8,11012
20
- prefect/tasks.py,sha256=_iCyePhTcdq8jW6gkB_TiIrCJjd9A2Mqhq0LfO5sV4Q,44730
20
+ prefect/tasks.py,sha256=n3_vr_cIsFAA5M6anvMlNvsk3jCvmuut_6NXr579VAY,46705
21
21
  prefect/variables.py,sha256=57h-cJ15ZXWrdQiOnoEQmUVlAe59hmIaa57ZcGNBzao,914
22
22
  prefect/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  prefect/_internal/_logging.py,sha256=HvNHY-8P469o5u4LYEDBTem69XZEt1QUeUaLToijpak,810
@@ -103,12 +103,12 @@ prefect/client/base.py,sha256=19VMAsq6Wvp1ZUwAb2OAT4pMQ0CFWsHBwqY3kZfPR2w,12209
103
103
  prefect/client/cloud.py,sha256=vlGivNaOIS0YNc0OnVKEx2L88SRU8pal8GYMoPHXyrU,3955
104
104
  prefect/client/collections.py,sha256=I9EgbTg4Fn57gn8vwP_WdDmgnATbx9gfkm2jjhCORjw,1037
105
105
  prefect/client/constants.py,sha256=Z_GG8KF70vbbXxpJuqW5pLnwzujTVeHbcYYRikNmGH0,29
106
- prefect/client/orchestration.py,sha256=AP4g_ZxaLM1ssH6dEywvGlzDSjM3b5ntgptXUkzN0w4,97293
106
+ prefect/client/orchestration.py,sha256=5Gte2zJ58IgXttJuf4fhRISEVo9kRx6sti5nSW2CX6s,98145
107
107
  prefect/client/utilities.py,sha256=ejALWrVYuqW-A2zKJkAuRXDkhZ5e8fsiEkn-wI1tzF0,1998
108
108
  prefect/client/schemas/__init__.py,sha256=KlyqFV-hMulMkNstBn_0ijoHoIwJZaBj6B1r07UmgvE,607
109
109
  prefect/client/schemas/actions.py,sha256=2Chfqg1yoRweIQW6WvhTFHW0WQ2HDkInDQdPzp-Iot8,24017
110
110
  prefect/client/schemas/filters.py,sha256=7RIrMpiuFL2XVh8rzLzKTkgvFyzUDGbUYDfDXJQGRMs,35026
111
- prefect/client/schemas/objects.py,sha256=zwo9uLVRb_0wHiPpXV_-4398-Eq5V6jMst_U2aSMe-U,52304
111
+ prefect/client/schemas/objects.py,sha256=6NRd3wifcBuIBjGReePAoLK-ZSkfidBWoNG4FOOL0nw,52625
112
112
  prefect/client/schemas/responses.py,sha256=nSYhg2Kl477RdczNsA731vpcJqF93WDnM6eMya3F7qI,9152
113
113
  prefect/client/schemas/schedules.py,sha256=Gomwqp83qGqblBcOeniUtebzovBekxzf0srDy992pEI,14221
114
114
  prefect/client/schemas/sorting.py,sha256=Y-ea8k_vTUKAPKIxqGebwLSXM7x1s5mJ_4-sDd1Ivi8,2276
@@ -129,12 +129,12 @@ prefect/deployments/steps/utility.py,sha256=LebTPEi66OOGuUYSsTQHbYHExIdjspSFHdac
129
129
  prefect/deprecated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
130
130
  prefect/deprecated/data_documents.py,sha256=mGxhPHy7nm8xqLnnoo5oUxcm2MjcZxwEE6boD2EwJgg,9642
131
131
  prefect/events/__init__.py,sha256=2tQCrDogstn-w65lKyf9ahu_wbWhPaaDK_oxH2v1558,173
132
- prefect/events/actions.py,sha256=6ybRk3Weyeby250ME0qKlFRMvOD7iE6iCAU5tnblT14,966
132
+ prefect/events/actions.py,sha256=wYc52xin_CLrNZaou05FdGdLZ5VEhT2lKM_k-MQEJ34,1398
133
133
  prefect/events/clients.py,sha256=AfJeV-FCObvydutrSFD8JLrMVwtDJsL3WN0nbopzA3s,13688
134
134
  prefect/events/filters.py,sha256=vSWHGDCCsi_znQs3gZomCxh-Q498ukn_QHJ7H8q16do,6922
135
135
  prefect/events/instrument.py,sha256=uNiD7AnkfuiwTsCMgNyJURmY9H2tXNfLCb3EC5FL0Qw,3805
136
136
  prefect/events/related.py,sha256=N0o19kTlos1V4L4AgO79Z_k06ZW9bfjSH8Xa9h7lugg,6746
137
- prefect/events/schemas.py,sha256=kNDcN62-G_jz2u9zrzGI5yV6CvAM-_IzpQjAAbFIdSU,11641
137
+ prefect/events/schemas.py,sha256=hXluVgDtEsjYghZhf-MjPhHntmMR6NcJJxU99ZRv2zQ,11643
138
138
  prefect/events/utilities.py,sha256=JApOECe-09SU8QabSnyykdl8fzsXE28RVSCBcFDseH4,2374
139
139
  prefect/events/worker.py,sha256=4Uw-_fiLa449gD2QsEOhubQwxpEyQn8PUo9N_zsJY1M,2684
140
140
  prefect/infrastructure/__init__.py,sha256=Fm1Rhc4I7ZfJePpUAl1F4iNEtcDugoT650WXXt6xoCM,770
@@ -163,14 +163,15 @@ prefect/packaging/file.py,sha256=LdYUpAJfBzaYABCwVs4jMKVyo2DC6psEFGpwJ-iKUd4,227
163
163
  prefect/packaging/orion.py,sha256=ctWh8s3UztYfOTsZ0sfumebI0dbNDOTriDNXohtEC-k,1935
164
164
  prefect/packaging/serializers.py,sha256=1x5GjcBSYrE-YMmrpYYZi2ObTs7MM6YEM3LS0e6mHAk,6321
165
165
  prefect/runner/__init__.py,sha256=RxkH2lejFchDZu9fp9oFmy6fs-I96u1vq5-EVz0uDfA,34
166
- prefect/runner/runner.py,sha256=uWOxIulnBm7a0nvg0fNe4j_r60RcziUBQkjFViq4mAk,45384
166
+ prefect/runner/runner.py,sha256=g6YNvIlLJZHvvII9j6ipL6S1byYmHjcRoliWe6_rOzs,45405
167
167
  prefect/runner/server.py,sha256=RYNPUMPHlLz8GS13P_Y84m545N4C7lVIx5zU3G_pQg0,5495
168
- prefect/runner/storage.py,sha256=hILSisK4CVRt4ywOfAa89c1pjRZIK-_Ea-LN_VIoGD4,22038
168
+ prefect/runner/storage.py,sha256=4XTww9P74Zp3CWUZssCucqQ71o_gAl9TX-7weO1OMxs,22412
169
169
  prefect/runner/utils.py,sha256=GFbCXIp5bFmJJJa_1deY0WNsQ1inWs8HJDCyhYf8BRA,3316
170
170
  prefect/runtime/__init__.py,sha256=iYmfK1HmXiXXCQK77wDloOqZmY7SFF5iyr37jRzuf-c,406
171
171
  prefect/runtime/deployment.py,sha256=UWNXH-3-NNVxLCl5XnDKiofo4a5j8w_42ns1OSQMixg,4751
172
172
  prefect/runtime/flow_run.py,sha256=OYXykn0CZKbIj8ni_Ut-KbAmZhEj85QwQ3xyk_T9GtM,7894
173
173
  prefect/runtime/task_run.py,sha256=_np3pjBHWkvEtSe-QElEAGwUct629vVx_sahPr-H8gM,3402
174
+ prefect/server/api/collections_data/views/aggregate-worker-metadata.json,sha256=TgiWTDSsO2SME2q_XMJS1orA_AcktGMNRPuaoE11YmE,74469
174
175
  prefect/server/api/static/prefect-logo-mark-gradient.png,sha256=ylRjJkI_JHCw8VbQasNnXQHwZW-sH-IQiUGSD3aWP1E,73430
175
176
  prefect/software/__init__.py,sha256=cn7Hesmkv3unA3NynEiyB0Cj2jAzV17yfwjVsS5Ecso,106
176
177
  prefect/software/base.py,sha256=GV6a5RrLx3JaOg1RI44jZTsI_qbqNWbWF3uVO5csnHM,1464
@@ -191,7 +192,7 @@ prefect/utilities/hashing.py,sha256=EOwZLmoIZImuSTxAvVqInabxJ-4RpEfYeg9e2EDQF8o,
191
192
  prefect/utilities/importtools.py,sha256=isblzKv7EPo7HtnlKYpL4t-GJdtTjUSMmvXgXSMEVZM,11764
192
193
  prefect/utilities/math.py,sha256=wLwcKVidpNeWQi1TUIWWLHGjlz9UgboX9FUGhx_CQzo,2821
193
194
  prefect/utilities/names.py,sha256=x-stHcF7_tebJPvB1dz-5FvdXJXNBTg2kFZXSnIBBmk,1657
194
- prefect/utilities/processutils.py,sha256=JJE0Tqo05CAPGaJqJX0E3leoPa8akGpOUUV9c2Z2NJA,14370
195
+ prefect/utilities/processutils.py,sha256=yo_GO48pZzgn4A0IK5irTAoqyUCYvWKDSqHXCrtP8c4,14547
195
196
  prefect/utilities/pydantic.py,sha256=rgkzzUgiCMVjr8DMyHNmfYzy_6eGS8Z0OuNW1ssZ22g,9226
196
197
  prefect/utilities/render_swagger.py,sha256=h2UrORVN3f7gM4zurtMnySjQXZIOWbji3uMinpbkl8U,3717
197
198
  prefect/utilities/services.py,sha256=TCjBJX6huz1nUzmiXI0IZNNfBuxM5-xV9PLbPZNosOw,6438
@@ -206,8 +207,8 @@ prefect/workers/block.py,sha256=lvKlaWdA-DCCXDX23HHK9M5urEq4x2wmpKtU9ft3a7k,7767
206
207
  prefect/workers/process.py,sha256=Kxj_eZYh6R8t8253LYIIafiG7dodCF8RZABwd3Ng_R0,10253
207
208
  prefect/workers/server.py,sha256=WVZJxR8nTMzK0ov0BD0xw5OyQpT26AxlXbsGQ1OrxeQ,1551
208
209
  prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
209
- prefect_client-2.14.12.dist-info/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
210
- prefect_client-2.14.12.dist-info/METADATA,sha256=jlj3iG9tCrVqgyLWFRoWLYRA-9QVvu3qLy4DOVz9KKM,8056
211
- prefect_client-2.14.12.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
212
- prefect_client-2.14.12.dist-info/top_level.txt,sha256=MJZYJgFdbRc2woQCeB4vM6T33tr01TmkEhRcns6H_H4,8
213
- prefect_client-2.14.12.dist-info/RECORD,,
210
+ prefect_client-2.14.13.dist-info/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
211
+ prefect_client-2.14.13.dist-info/METADATA,sha256=NQCDMdjr3oTF35yu_3ZweEHb__b0jJwYF1SetSQf2Ew,8056
212
+ prefect_client-2.14.13.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
213
+ prefect_client-2.14.13.dist-info/top_level.txt,sha256=MJZYJgFdbRc2woQCeB4vM6T33tr01TmkEhRcns6H_H4,8
214
+ prefect_client-2.14.13.dist-info/RECORD,,