prefect-client 3.3.5.dev4__py3-none-any.whl → 3.3.6.dev1__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/_build_info.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # Generated by versioningit
2
- __version__ = "3.3.5.dev4"
3
- __build_date__ = "2025-04-17 08:08:34.376039+00:00"
4
- __git_commit__ = "d90d684c9e0773b41bf092ad7ef17e22dda08c77"
2
+ __version__ = "3.3.6.dev1"
3
+ __build_date__ = "2025-04-19 08:07:12.903915+00:00"
4
+ __git_commit__ = "c9c018d468694ea61ce3a482948bf4d03bb67227"
5
5
  __dirty__ = False
prefect/cache_policies.py CHANGED
@@ -33,9 +33,9 @@ def _register_stable_transforms() -> None:
33
33
  so that cache keys that utilize them are deterministic across invocations.
34
34
  """
35
35
  try:
36
- import pandas as pd
36
+ import pandas as pd # pyright: ignore
37
37
 
38
- STABLE_TRANSFORMS[pd.DataFrame] = lambda df: [
38
+ STABLE_TRANSFORMS[pd.DataFrame] = lambda df: [ # pyright: ignore
39
39
  df[col] for col in sorted(df.columns)
40
40
  ]
41
41
  except (ImportError, ModuleNotFoundError):
@@ -183,7 +183,7 @@ class CompoundCachePolicy(CachePolicy):
183
183
  Any keys that return `None` will be ignored.
184
184
  """
185
185
 
186
- policies: list[CachePolicy] = field(default_factory=list)
186
+ policies: list[CachePolicy] = field(default_factory=lambda: [])
187
187
 
188
188
  def __post_init__(self) -> None:
189
189
  # flatten any CompoundCachePolicies
@@ -349,7 +349,7 @@ class Inputs(CachePolicy):
349
349
  Policy that computes a cache key based on a hash of the runtime inputs provided to the task..
350
350
  """
351
351
 
352
- exclude: list[str] = field(default_factory=list)
352
+ exclude: list[str] = field(default_factory=lambda: [])
353
353
 
354
354
  def compute_key(
355
355
  self,
@@ -13,7 +13,9 @@ class ConcurrencyContext(ContextModel):
13
13
  # Track the slots that have been acquired but were not able to be released
14
14
  # due to cancellation or some other error. These slots are released when
15
15
  # the context manager exits.
16
- cleanup_slots: list[tuple[list[str], int, float]] = Field(default_factory=list)
16
+ cleanup_slots: list[tuple[list[str], int, float]] = Field(
17
+ default_factory=lambda: []
18
+ )
17
19
 
18
20
  def __exit__(self, *exc_info: Any) -> None:
19
21
  if self.cleanup_slots:
prefect/context.py CHANGED
@@ -18,8 +18,6 @@ from typing import TYPE_CHECKING, Any, Callable, ClassVar, Optional, TypeVar, Un
18
18
  from pydantic import BaseModel, ConfigDict, Field, PrivateAttr
19
19
  from typing_extensions import Self
20
20
 
21
- import prefect.logging
22
- import prefect.logging.configuration
23
21
  import prefect.settings
24
22
  import prefect.types._datetime
25
23
  from prefect._internal.compatibility.migration import getattr_migration
@@ -128,7 +126,7 @@ class ContextModel(BaseModel):
128
126
  def __init__(self, **kwargs: Any) -> None: ...
129
127
 
130
128
  # The context variable for storing data must be defined by the child class
131
- __var__: ClassVar[ContextVar[Self]]
129
+ __var__: ClassVar[ContextVar[Any]]
132
130
  _token: Optional[Token[Self]] = PrivateAttr(None)
133
131
  model_config: ClassVar[ConfigDict] = ConfigDict(
134
132
  arbitrary_types_allowed=True,
prefect/runner/runner.py CHANGED
@@ -781,7 +781,7 @@ class Runner:
781
781
  if command is None:
782
782
  runner_command = [get_sys_executable(), "-m", "prefect.engine"]
783
783
  else:
784
- runner_command = shlex.split(command)
784
+ runner_command = shlex.split(command, posix=(os.name != "nt"))
785
785
 
786
786
  flow_run_logger = self._get_flow_run_logger(flow_run)
787
787
 
@@ -0,0 +1,117 @@
1
+ import ast
2
+ import math
3
+ from typing import TYPE_CHECKING, Literal
4
+
5
+ import anyio
6
+ from typing_extensions import TypeAlias
7
+
8
+ from prefect.logging.loggers import get_logger
9
+ from prefect.settings import get_current_settings
10
+ from prefect.utilities.asyncutils import LazySemaphore
11
+ from prefect.utilities.filesystem import get_open_file_limit
12
+
13
+ # Only allow half of the open file limit to be open at once to allow for other
14
+ # actors to open files.
15
+ OPEN_FILE_SEMAPHORE = LazySemaphore(lambda: math.floor(get_open_file_limit() * 0.5))
16
+
17
+ # this potentially could be a TypedDict, but you
18
+ # need some way to convince the type checker that
19
+ # Literal["flow_name", "task_name"] are being provided
20
+ DecoratedFnMetadata: TypeAlias = dict[str, str]
21
+
22
+
23
+ async def find_prefect_decorated_functions_in_file(
24
+ path: anyio.Path, decorator_module: str, decorator_name: Literal["flow", "task"]
25
+ ) -> list[DecoratedFnMetadata]:
26
+ logger = get_logger()
27
+ decorator_name_key = f"{decorator_name}_name"
28
+ decorated_functions: list[DecoratedFnMetadata] = []
29
+
30
+ async with OPEN_FILE_SEMAPHORE:
31
+ try:
32
+ async with await anyio.open_file(path) as f:
33
+ try:
34
+ tree = ast.parse(await f.read())
35
+ except SyntaxError:
36
+ if get_current_settings().debug_mode:
37
+ logger.debug(
38
+ f"Could not parse {path} as a Python file. Skipping."
39
+ )
40
+ return decorated_functions
41
+ except Exception as exc:
42
+ if get_current_settings().debug_mode:
43
+ logger.debug(f"Could not open {path}: {exc}. Skipping.")
44
+ return decorated_functions
45
+
46
+ for node in ast.walk(tree):
47
+ if isinstance(
48
+ node,
49
+ (
50
+ ast.FunctionDef,
51
+ ast.AsyncFunctionDef,
52
+ ),
53
+ ):
54
+ for decorator in node.decorator_list:
55
+ # handles @decorator_name
56
+ is_name_match = (
57
+ isinstance(decorator, ast.Name) and decorator.id == decorator_name
58
+ )
59
+ # handles @decorator_name()
60
+ is_func_name_match = (
61
+ isinstance(decorator, ast.Call)
62
+ and isinstance(decorator.func, ast.Name)
63
+ and decorator.func.id == decorator_name
64
+ )
65
+ # handles @decorator_module.decorator_name
66
+ is_module_attribute_match = (
67
+ isinstance(decorator, ast.Attribute)
68
+ and isinstance(decorator.value, ast.Name)
69
+ and decorator.value.id == decorator_module
70
+ and decorator.attr == decorator_name
71
+ )
72
+ # handles @decorator_module.decorator_name()
73
+ is_module_attribute_func_match = (
74
+ isinstance(decorator, ast.Call)
75
+ and isinstance(decorator.func, ast.Attribute)
76
+ and decorator.func.attr == decorator_name
77
+ and isinstance(decorator.func.value, ast.Name)
78
+ and decorator.func.value.id == decorator_module
79
+ )
80
+ if is_name_match or is_module_attribute_match:
81
+ decorated_functions.append(
82
+ {
83
+ decorator_name_key: node.name,
84
+ "function_name": node.name,
85
+ "filepath": str(path),
86
+ }
87
+ )
88
+ if is_func_name_match or is_module_attribute_func_match:
89
+ name_kwarg_node = None
90
+ if TYPE_CHECKING:
91
+ assert isinstance(decorator, ast.Call)
92
+ for kw in decorator.keywords:
93
+ if kw.arg == "name":
94
+ name_kwarg_node = kw
95
+ break
96
+ if name_kwarg_node is not None and isinstance(
97
+ name_kwarg_node.value, ast.Constant
98
+ ):
99
+ decorated_fn_name = name_kwarg_node.value.value
100
+ else:
101
+ decorated_fn_name = node.name
102
+ decorated_functions.append(
103
+ {
104
+ decorator_name_key: decorated_fn_name,
105
+ "function_name": node.name,
106
+ "filepath": str(path),
107
+ }
108
+ )
109
+ return decorated_functions
110
+
111
+
112
+ async def find_flow_functions_in_file(path: anyio.Path) -> list[DecoratedFnMetadata]:
113
+ return await find_prefect_decorated_functions_in_file(path, "prefect", "flow")
114
+
115
+
116
+ async def find_task_functions_in_file(path: anyio.Path) -> list[DecoratedFnMetadata]:
117
+ return await find_prefect_decorated_functions_in_file(path, "prefect", "task")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prefect-client
3
- Version: 3.3.5.dev4
3
+ Version: 3.3.6.dev1
4
4
  Summary: Workflow orchestration and management.
5
5
  Project-URL: Changelog, https://github.com/PrefectHQ/prefect/releases
6
6
  Project-URL: Documentation, https://docs.prefect.io
@@ -47,7 +47,7 @@ Requires-Dist: prometheus-client>=0.20.0
47
47
  Requires-Dist: pydantic!=2.10.0,<3.0.0,>=2.9
48
48
  Requires-Dist: pydantic-core<3.0.0,>=2.12.0
49
49
  Requires-Dist: pydantic-extra-types<3.0.0,>=2.8.2
50
- Requires-Dist: pydantic-settings>2.2.1
50
+ Requires-Dist: pydantic-settings!=2.9.0,<3.0.0,>2.2.1
51
51
  Requires-Dist: python-dateutil<3.0.0,>=2.8.2
52
52
  Requires-Dist: python-slugify<9.0,>=5.0
53
53
  Requires-Dist: python-socks[asyncio]<3.0,>=2.5.3
@@ -1,14 +1,14 @@
1
1
  prefect/.prefectignore,sha256=awSprvKT0vI8a64mEOLrMxhxqcO-b0ERQeYpA2rNKVQ,390
2
2
  prefect/__init__.py,sha256=iCdcC5ZmeewikCdnPEP6YBAjPNV5dvfxpYCTpw30Hkw,3685
3
3
  prefect/__main__.py,sha256=WFjw3kaYJY6pOTA7WDOgqjsz8zUEUZHCcj3P5wyVa-g,66
4
- prefect/_build_info.py,sha256=fmB9z2o0RI_qL1TVcyAW98Ldqcsjk0vLJjmEcztUgvk,185
4
+ prefect/_build_info.py,sha256=jisNjC8uPjptK7U97v_vxNXQXL36_gwcQrQgC-M9VF0,185
5
5
  prefect/_result_records.py,sha256=S6QmsODkehGVSzbMm6ig022PYbI6gNKz671p_8kBYx4,7789
6
6
  prefect/_waiters.py,sha256=Ia2ITaXdHzevtyWIgJoOg95lrEXQqNEOquHvw3T33UQ,9026
7
7
  prefect/agent.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
8
8
  prefect/artifacts.py,sha256=dMBUOAWnUamzjb5HSqwB5-GR2Qb-Gxee26XG5NDCUuw,22720
9
9
  prefect/automations.py,sha256=ZzPxn2tINdlXTQo805V4rIlbXuNWxd7cdb3gTJxZIeY,12567
10
- prefect/cache_policies.py,sha256=Kwdei4JjitNfx42OepKpDNxwPtEwRgUUAn_soxsnNzI,12699
11
- prefect/context.py,sha256=LYEOlz7ZkuSDj7TmrE4mByy3N3TquFkIE2hEy0WHW1Y,23798
10
+ prefect/cache_policies.py,sha256=jH1aDW6vItTcsEytuTCrNYyjbq87IQPwdOgF0yxiUts,12749
11
+ prefect/context.py,sha256=IXS_ddSkQVFKFCQhjWk7Fwgfstfu6ITCmNeZ1beablY,23737
12
12
  prefect/engine.py,sha256=uB5JN4l045i5JTlRQNT1x7MwlSiGQ5Bop2Q6jHHOgxY,3699
13
13
  prefect/exceptions.py,sha256=wZLQQMRB_DyiYkeEdIC5OKwbba5A94Dlnics-lrWI7A,11581
14
14
  prefect/filesystems.py,sha256=v5YqGB4uXf9Ew2VuB9VCSkawvYMMVvEtZf7w1VmAmr8,18036
@@ -122,7 +122,7 @@ prefect/concurrency/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
122
122
  prefect/concurrency/_asyncio.py,sha256=uHjC3vQAiznRz_ueZE1RQ4x28zTcPJPoO2MMi0J41vU,2575
123
123
  prefect/concurrency/_events.py,sha256=KWHDldCWE3b5AH9eZ7kfmajvp36lRFCjCXIEx77jtKk,1825
124
124
  prefect/concurrency/asyncio.py,sha256=SUnRfqwBdBGwQll7SvywugVQnVbEzePqPFcUfIcTNMs,4505
125
- prefect/concurrency/context.py,sha256=8ZXs3G7NOF5Q2NqydK-K3zfjmYNnmfer-25hH6r6MgA,1009
125
+ prefect/concurrency/context.py,sha256=kJWE2zGuoel9qiGOqHW5qnSyzV1INlsicTmeEEexoFo,1029
126
126
  prefect/concurrency/services.py,sha256=U_1Y8Mm-Fd4Nvn0gxiWc_UdacdqT-vKjzex-oJpUt50,2288
127
127
  prefect/concurrency/sync.py,sha256=MMRJvxK-Yzyt0WEEu95C2RaMwfLdYgYH6vejCqfSUmw,4687
128
128
  prefect/concurrency/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -182,7 +182,7 @@ prefect/logging/highlighters.py,sha256=BCf_LNhFInIfGPqwuu8YVrGa4wVxNc4YXo2pYgftp
182
182
  prefect/logging/loggers.py,sha256=rwFJv0i3dhdKr25XX-xUkQy4Vv4dy18bTy366jrC0OQ,12741
183
183
  prefect/logging/logging.yml,sha256=tT7gTyC4NmngFSqFkCdHaw7R0GPNPDDsTCGZQByiJAQ,3169
184
184
  prefect/runner/__init__.py,sha256=pQBd9wVrUVUDUFJlgiweKSnbahoBZwqnd2O2jkhrULY,158
185
- prefect/runner/runner.py,sha256=kca9eD8_43MquPKmXDuQxiyfj2kcRj9ui2VRiXwLX80,65092
185
+ prefect/runner/runner.py,sha256=jv87XyaJ89uK0VzKpMzL3HfXgKZky8JlRs-gW04no5Y,65117
186
186
  prefect/runner/server.py,sha256=YRYFNoYddA9XfiTIYtudxrnD1vCX-PaOLhvyGUOb9AQ,11966
187
187
  prefect/runner/storage.py,sha256=L7aSjie5L6qbXYCDqYDX3ouQ_NsNMlmfjPeaWOC-ncs,28043
188
188
  prefect/runner/submit.py,sha256=qOEj-NChQ6RYFV35hHEVMTklrNmKwaGs2mR78ku9H0o,9474
@@ -278,6 +278,7 @@ prefect/types/__init__.py,sha256=yBjKxiQmSC7jXoo0UNmM3KZil1NBFS-BWGPfwSEaoJo,462
278
278
  prefect/types/_datetime.py,sha256=Cy6z7MxPDV_-jH2vxqC3PNA2G74IdUDIB07Jaakdj5w,7294
279
279
  prefect/types/entrypoint.py,sha256=2FF03-wLPgtnqR_bKJDB2BsXXINPdu8ptY9ZYEZnXg8,328
280
280
  prefect/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
281
+ prefect/utilities/_ast.py,sha256=sgEPUWElih-3cp4PoAy1IOyPtu8E27lL0Dldf3ijnYY,4905
281
282
  prefect/utilities/_deprecated.py,sha256=b3pqRSoFANdVJAc8TJkygBcP-VjZtLJUxVIWC7kwspI,1303
282
283
  prefect/utilities/_engine.py,sha256=9GW4X1lyAbmPwCuXXIubVJ7Z0DMT3dykkEUtp9tm5hI,3356
283
284
  prefect/utilities/_git.py,sha256=bPYWQdr9xvH0BqxR1ll1RkaSb3x0vhwylhYD5EilkKU,863
@@ -316,7 +317,7 @@ prefect/workers/cloud.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
316
317
  prefect/workers/process.py,sha256=Yi5D0U5AQ51wHT86GdwtImXSefe0gJf3LGq4r4z9zwM,11090
317
318
  prefect/workers/server.py,sha256=2pmVeJZiVbEK02SO6BEZaBIvHMsn6G8LzjW8BXyiTtk,1952
318
319
  prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
319
- prefect_client-3.3.5.dev4.dist-info/METADATA,sha256=eMLy1mSzn_rqmgIw2S34J0_JZ6YtEfY32-q2r-3-SnU,7456
320
- prefect_client-3.3.5.dev4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
321
- prefect_client-3.3.5.dev4.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
322
- prefect_client-3.3.5.dev4.dist-info/RECORD,,
320
+ prefect_client-3.3.6.dev1.dist-info/METADATA,sha256=PMgTb0Zkd5VixWs2eGC-cb6L7wdl9TRKu5ISxI5KoIo,7471
321
+ prefect_client-3.3.6.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
322
+ prefect_client-3.3.6.dev1.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
323
+ prefect_client-3.3.6.dev1.dist-info/RECORD,,