prefect-client 2.19.4__py3-none-any.whl → 2.19.5__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.
@@ -778,7 +778,7 @@ class GlobalConcurrencyLimitUpdate(ActionBaseModel):
778
778
 
779
779
  name: Optional[str] = Field(None)
780
780
  limit: Optional[NonNegativeInteger] = Field(None)
781
- active: Optional[NonNegativeInteger] = Field(None)
781
+ active: Optional[bool] = Field(None)
782
782
  active_slots: Optional[NonNegativeInteger] = Field(None)
783
783
  slot_decay_per_second: Optional[NonNegativeFloat] = Field(None)
784
784
 
prefect/flows.py CHANGED
@@ -106,7 +106,7 @@ from prefect.utilities.callables import (
106
106
  )
107
107
  from prefect.utilities.collections import listrepr
108
108
  from prefect.utilities.hashing import file_hash
109
- from prefect.utilities.importtools import import_object
109
+ from prefect.utilities.importtools import import_object, safe_load_namespace
110
110
  from prefect.utilities.visualization import (
111
111
  FlowVisualizationError,
112
112
  GraphvizExecutableNotFoundError,
@@ -1850,11 +1850,33 @@ def load_flow_argument_from_entrypoint(
1850
1850
  ):
1851
1851
  for keyword in decorator.keywords:
1852
1852
  if keyword.arg == arg:
1853
- return (
1854
- keyword.value.value
1855
- ) # Return the string value of the argument
1853
+ if isinstance(keyword.value, ast.Constant):
1854
+ return (
1855
+ keyword.value.value
1856
+ ) # Return the string value of the argument
1857
+
1858
+ # if the arg value is not a raw str (i.e. a variable or expression),
1859
+ # then attempt to evaluate it
1860
+ namespace = safe_load_namespace(source_code)
1861
+ literal_arg_value = ast.get_source_segment(
1862
+ source_code, keyword.value
1863
+ )
1864
+ try:
1865
+ evaluated_value = eval(literal_arg_value, namespace) # type: ignore
1866
+ except Exception as e:
1867
+ logger.info(
1868
+ "Failed to parse @flow argument: `%s=%s` due to the following error. Ignoring and falling back to default behavior.",
1869
+ arg,
1870
+ literal_arg_value,
1871
+ exc_info=e,
1872
+ )
1873
+ # ignore the decorator arg and fallback to default behavior
1874
+ break
1875
+ return str(evaluated_value)
1856
1876
 
1857
1877
  if arg == "name":
1858
1878
  return func_name.replace(
1859
1879
  "_", "-"
1860
1880
  ) # If no matching decorator or keyword argument is found
1881
+
1882
+ return None
@@ -124,6 +124,12 @@ class BaseDockerLogin(Block, ABC):
124
124
  )
125
125
  class DockerRegistry(BaseDockerLogin):
126
126
  """
127
+ DEPRECATION WARNING:
128
+
129
+ This class is deprecated as of March 2024 and will not be available after September 2024.
130
+ It has been replaced by `DockerRegistryCredentials` from the `prefect-docker` package, which
131
+ offers enhanced functionality and better a better user experience.
132
+
127
133
  Connects to a Docker registry.
128
134
 
129
135
  Requires a Docker Engine to be connectable.
@@ -381,6 +381,15 @@ def safe_load_namespace(source_code: str):
381
381
 
382
382
  namespace = {"__name__": "prefect_safe_namespace_loader"}
383
383
 
384
+ # Remove the body of the if __name__ == "__main__": block from the AST to prevent
385
+ # execution of guarded code
386
+ new_body = []
387
+ for node in parsed_code.body:
388
+ if _is_main_block(node):
389
+ continue
390
+ new_body.append(node)
391
+ parsed_code.body = new_body
392
+
384
393
  # Walk through the AST and find all import statements
385
394
  for node in ast.walk(parsed_code):
386
395
  if isinstance(node, ast.Import):
@@ -427,3 +436,23 @@ def safe_load_namespace(source_code: str):
427
436
  except Exception as e:
428
437
  logger.debug("Failed to compile: %s", e)
429
438
  return namespace
439
+
440
+
441
+ def _is_main_block(node: ast.AST):
442
+ """
443
+ Check if the node is an `if __name__ == "__main__":` block.
444
+ """
445
+ if isinstance(node, ast.If):
446
+ try:
447
+ # Check if the condition is `if __name__ == "__main__":`
448
+ if (
449
+ isinstance(node.test, ast.Compare)
450
+ and isinstance(node.test.left, ast.Name)
451
+ and node.test.left.id == "__name__"
452
+ and isinstance(node.test.comparators[0], ast.Constant)
453
+ and node.test.comparators[0].value == "__main__"
454
+ ):
455
+ return True
456
+ except AttributeError:
457
+ pass
458
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefect-client
3
- Version: 2.19.4
3
+ Version: 2.19.5
4
4
  Summary: Workflow orchestration and management.
5
5
  Home-page: https://www.prefect.io
6
6
  Author: Prefect Technologies, Inc.
@@ -9,7 +9,7 @@ prefect/engine.py,sha256=hGaxEyJB0OSb_fc2sRsoL550DGOeuwttWOY3dQR6wZw,90418
9
9
  prefect/exceptions.py,sha256=Fyl-GXvF9OuKHtsyn5EhWg81pkU1UG3DFHsI1JzhOQE,10851
10
10
  prefect/filesystems.py,sha256=XniPSdBAqywj43X7GyfuWJQIbz07QJ5Y3cVNLhIF3lQ,35260
11
11
  prefect/flow_runs.py,sha256=mFHLavZk1yZ62H3UazuNDBZWAF7AqKttA4rMcHgsVSw,3119
12
- prefect/flows.py,sha256=2CRt3E0THxqriT9ZwMCaPBUMxwkRHU4UNg3iYjvQaTE,75292
12
+ prefect/flows.py,sha256=uB5LVVi_Gk4aBk69kyXX1VuU9AiQwtpGifgnpZtJc-Y,76400
13
13
  prefect/futures.py,sha256=RaWfYIXtH7RsWxQ5QWTTlAzwtVV8XWpXaZT_hLq35vQ,12590
14
14
  prefect/manifests.py,sha256=sTM7j8Us5d49zaydYKWsKb7zJ96v1ChkLkLeR0GFYD8,683
15
15
  prefect/new_flow_engine.py,sha256=A1adTWTBAwPCn6ay003Jsoc2SdYgHV4AcJo1bmpa_7Y,16039
@@ -168,7 +168,7 @@ prefect/client/orchestration.py,sha256=O8DEbL7CP271MTVNlID8aRAl1xybfb6MwCUbYyjZe
168
168
  prefect/client/subscriptions.py,sha256=3kqPH3F-CwyrR5wygCpJMjRjM_gcQjd54Qjih6FcLlA,3372
169
169
  prefect/client/utilities.py,sha256=7V4IkfC8x_OZuPXGvtIMmwZCOW63hSY8iVQkuRYTR6g,3079
170
170
  prefect/client/schemas/__init__.py,sha256=KlyqFV-hMulMkNstBn_0ijoHoIwJZaBj6B1r07UmgvE,607
171
- prefect/client/schemas/actions.py,sha256=npka1_fiJ_Y_GU6R_uv8wS2kGiJAu5XXqK5b6S0zy-8,27957
171
+ prefect/client/schemas/actions.py,sha256=4mq1OXMsXs6aGlXg1G232RNcn0ivAOIgikL0IKs6S-E,27943
172
172
  prefect/client/schemas/filters.py,sha256=gv57m0bHJqL7Ifsc_vAdRODFomaMVcrGXKAahOSBU4w,35598
173
173
  prefect/client/schemas/objects.py,sha256=Ie82ck5vXXgs0Q_luVe_NJkg_SAYN68d0nTxxFKt31M,53130
174
174
  prefect/client/schemas/responses.py,sha256=XAc95g3PRL9UIkH9_VMuv0ECHKdc19guBLmdt5KefkI,15325
@@ -213,7 +213,7 @@ prefect/events/schemas/events.py,sha256=Xdk3VRO42j1oe3qiXfhKAEBL-TrvKjn0qZj_jxvI
213
213
  prefect/events/schemas/labelling.py,sha256=and3kx2SgnwD2MlMiRxNyFCV_CDZvAVvW1X9GDn0a6E,3255
214
214
  prefect/infrastructure/__init__.py,sha256=Fm1Rhc4I7ZfJePpUAl1F4iNEtcDugoT650WXXt6xoCM,770
215
215
  prefect/infrastructure/base.py,sha256=s2nNbwXnqHV-sBy7LeZzV1IVjqAO0zv795HM4RHOvQI,10880
216
- prefect/infrastructure/container.py,sha256=RuWqxSgwwoAxJ9FquYH12wEUizMQM9_b-e5p13ZVscI,31851
216
+ prefect/infrastructure/container.py,sha256=gl38tFrym_wHQb0pCtcitMmHlL6eckHKAL3-EAM2Gec,32140
217
217
  prefect/infrastructure/kubernetes.py,sha256=28DLYNomVj2edmtM1c0ksbGUkBd1GwOlIIMDdSaLPbw,35703
218
218
  prefect/infrastructure/process.py,sha256=ZclTVl55ygEItkfB-ARFEIIZW4bk9ImuQzMTFfQNrnE,11324
219
219
  prefect/infrastructure/provisioners/__init__.py,sha256=e9rfFnLqqwjexvYoiRZIY-CEwK-7ZhCQm745Z-Uxon8,1666
@@ -264,7 +264,7 @@ prefect/utilities/dockerutils.py,sha256=O5lIgCej5KGRYU2TC1NzNuIK595uOIWJilhZXYEV
264
264
  prefect/utilities/engine.py,sha256=TKiYqpfgt4zopuI8yvh2e-V9GgLcRrh3TpKRhvLuHdw,25669
265
265
  prefect/utilities/filesystem.py,sha256=M_TeZ1MftjBf7hDLWk-Iphir369TpJ1binMsBKiO9YE,4449
266
266
  prefect/utilities/hashing.py,sha256=EOwZLmoIZImuSTxAvVqInabxJ-4RpEfYeg9e2EDQF8o,1752
267
- prefect/utilities/importtools.py,sha256=1rPTqlUY3qWP4GeX4wYrSE9pUtKrD8-ngnDz0uqT2ZI,14600
267
+ prefect/utilities/importtools.py,sha256=zgBL4ba-H-g8bYZWm8s-yHKNlqIDqakNMs6Q7o7GdtA,15540
268
268
  prefect/utilities/math.py,sha256=wLwcKVidpNeWQi1TUIWWLHGjlz9UgboX9FUGhx_CQzo,2821
269
269
  prefect/utilities/names.py,sha256=x-stHcF7_tebJPvB1dz-5FvdXJXNBTg2kFZXSnIBBmk,1657
270
270
  prefect/utilities/processutils.py,sha256=yo_GO48pZzgn4A0IK5irTAoqyUCYvWKDSqHXCrtP8c4,14547
@@ -285,8 +285,8 @@ prefect/workers/block.py,sha256=5bdCuqT-4I-et_8ZLG2y1AODzYiCQwFiivhdt5NMEog,7635
285
285
  prefect/workers/process.py,sha256=pPtCdA7fKQ4OsvoitT-cayZeh5HgLX4xBUYlb2Zad-Q,9475
286
286
  prefect/workers/server.py,sha256=WVZJxR8nTMzK0ov0BD0xw5OyQpT26AxlXbsGQ1OrxeQ,1551
287
287
  prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
288
- prefect_client-2.19.4.dist-info/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
289
- prefect_client-2.19.4.dist-info/METADATA,sha256=jp5x5csGV9bneDyiyGLFtL_KR0Kmbvm-K3lzNIZ5psU,7401
290
- prefect_client-2.19.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
291
- prefect_client-2.19.4.dist-info/top_level.txt,sha256=MJZYJgFdbRc2woQCeB4vM6T33tr01TmkEhRcns6H_H4,8
292
- prefect_client-2.19.4.dist-info/RECORD,,
288
+ prefect_client-2.19.5.dist-info/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
289
+ prefect_client-2.19.5.dist-info/METADATA,sha256=DVM0ZmLi7wy762ToB9BMNl_D3bbM8WfF_FW8Xmi_DlI,7401
290
+ prefect_client-2.19.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
291
+ prefect_client-2.19.5.dist-info/top_level.txt,sha256=MJZYJgFdbRc2woQCeB4vM6T33tr01TmkEhRcns6H_H4,8
292
+ prefect_client-2.19.5.dist-info/RECORD,,