prefect-client 3.1.15__py3-none-any.whl → 3.2.1__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/_experimental/sla/objects.py +29 -1
- prefect/_internal/compatibility/deprecated.py +4 -4
- prefect/_internal/compatibility/migration.py +1 -1
- prefect/_internal/concurrency/calls.py +1 -2
- prefect/_internal/concurrency/cancellation.py +2 -4
- prefect/_internal/concurrency/threads.py +3 -3
- prefect/_internal/schemas/bases.py +3 -11
- prefect/_internal/schemas/validators.py +36 -60
- prefect/_result_records.py +235 -0
- prefect/_version.py +3 -3
- prefect/agent.py +1 -0
- prefect/automations.py +4 -8
- prefect/blocks/notifications.py +8 -8
- prefect/cache_policies.py +2 -0
- prefect/client/base.py +7 -8
- prefect/client/collections.py +3 -6
- prefect/client/orchestration/__init__.py +15 -263
- prefect/client/orchestration/_deployments/client.py +14 -6
- prefect/client/orchestration/_flow_runs/client.py +10 -6
- prefect/client/orchestration/_work_pools/__init__.py +0 -0
- prefect/client/orchestration/_work_pools/client.py +598 -0
- prefect/client/orchestration/base.py +9 -2
- prefect/client/schemas/actions.py +66 -2
- prefect/client/schemas/objects.py +22 -50
- prefect/client/schemas/schedules.py +7 -18
- prefect/client/types/flexible_schedule_list.py +2 -1
- prefect/context.py +2 -3
- prefect/deployments/flow_runs.py +1 -1
- prefect/deployments/runner.py +119 -43
- prefect/deployments/schedules.py +7 -1
- prefect/engine.py +4 -9
- prefect/events/schemas/automations.py +4 -2
- prefect/events/utilities.py +15 -13
- prefect/exceptions.py +1 -1
- prefect/flow_engine.py +19 -10
- prefect/flow_runs.py +4 -8
- prefect/flows.py +53 -22
- prefect/infrastructure/__init__.py +1 -0
- prefect/infrastructure/base.py +1 -0
- prefect/infrastructure/provisioners/__init__.py +3 -6
- prefect/infrastructure/provisioners/coiled.py +3 -3
- prefect/infrastructure/provisioners/container_instance.py +1 -0
- prefect/infrastructure/provisioners/ecs.py +6 -6
- prefect/infrastructure/provisioners/modal.py +3 -3
- prefect/input/run_input.py +5 -7
- prefect/locking/filesystem.py +4 -3
- prefect/main.py +1 -1
- prefect/results.py +42 -249
- prefect/runner/runner.py +9 -4
- prefect/runner/server.py +5 -5
- prefect/runner/storage.py +12 -10
- prefect/runner/submit.py +2 -4
- prefect/schedules.py +231 -0
- prefect/serializers.py +5 -5
- prefect/settings/__init__.py +2 -1
- prefect/settings/base.py +3 -3
- prefect/settings/models/root.py +4 -0
- prefect/settings/models/server/services.py +50 -9
- prefect/settings/sources.py +8 -4
- prefect/states.py +42 -11
- prefect/task_engine.py +10 -10
- prefect/task_runners.py +11 -22
- prefect/task_worker.py +9 -9
- prefect/tasks.py +22 -41
- prefect/telemetry/bootstrap.py +4 -6
- prefect/telemetry/services.py +2 -4
- prefect/types/__init__.py +2 -1
- prefect/types/_datetime.py +28 -1
- prefect/utilities/_engine.py +0 -1
- prefect/utilities/asyncutils.py +4 -8
- prefect/utilities/collections.py +13 -22
- prefect/utilities/dispatch.py +2 -4
- prefect/utilities/dockerutils.py +6 -6
- prefect/utilities/importtools.py +1 -68
- prefect/utilities/names.py +1 -1
- prefect/utilities/processutils.py +3 -6
- prefect/utilities/pydantic.py +4 -6
- prefect/utilities/schema_tools/hydration.py +6 -5
- prefect/utilities/templating.py +16 -10
- prefect/utilities/visualization.py +2 -4
- prefect/workers/base.py +3 -3
- prefect/workers/block.py +1 -0
- prefect/workers/cloud.py +1 -0
- prefect/workers/process.py +1 -0
- {prefect_client-3.1.15.dist-info → prefect_client-3.2.1.dist-info}/METADATA +1 -1
- {prefect_client-3.1.15.dist-info → prefect_client-3.2.1.dist-info}/RECORD +89 -85
- {prefect_client-3.1.15.dist-info → prefect_client-3.2.1.dist-info}/LICENSE +0 -0
- {prefect_client-3.1.15.dist-info → prefect_client-3.2.1.dist-info}/WHEEL +0 -0
- {prefect_client-3.1.15.dist-info → prefect_client-3.2.1.dist-info}/top_level.txt +0 -0
prefect/flows.py
CHANGED
@@ -49,7 +49,6 @@ from typing_extensions import Literal, ParamSpec
|
|
49
49
|
from prefect._experimental.sla.objects import SlaTypes
|
50
50
|
from prefect._internal.concurrency.api import create_call, from_async
|
51
51
|
from prefect.blocks.core import Block
|
52
|
-
from prefect.client.schemas.actions import DeploymentScheduleCreate
|
53
52
|
from prefect.client.schemas.filters import WorkerFilter, WorkerFilterStatus
|
54
53
|
from prefect.client.schemas.objects import ConcurrencyLimitConfig, FlowRun
|
55
54
|
from prefect.client.utilities import client_injector
|
@@ -69,6 +68,7 @@ from prefect.futures import PrefectFuture
|
|
69
68
|
from prefect.logging import get_logger
|
70
69
|
from prefect.logging.loggers import flow_run_logger
|
71
70
|
from prefect.results import ResultSerializer, ResultStorage
|
71
|
+
from prefect.schedules import Schedule
|
72
72
|
from prefect.settings import (
|
73
73
|
PREFECT_DEFAULT_WORK_POOL_NAME,
|
74
74
|
PREFECT_FLOW_DEFAULT_RETRIES,
|
@@ -120,8 +120,7 @@ class FlowStateHook(Protocol, Generic[P, R]):
|
|
120
120
|
|
121
121
|
def __call__(
|
122
122
|
self, flow: Flow[P, R], flow_run: FlowRun, state: State
|
123
|
-
) -> Awaitable[None] | None:
|
124
|
-
...
|
123
|
+
) -> Awaitable[None] | None: ...
|
125
124
|
|
126
125
|
|
127
126
|
if TYPE_CHECKING:
|
@@ -669,6 +668,7 @@ class Flow(Generic[P, R]):
|
|
669
668
|
cron: Optional[Union[Iterable[str], str]] = None,
|
670
669
|
rrule: Optional[Union[Iterable[str], str]] = None,
|
671
670
|
paused: Optional[bool] = None,
|
671
|
+
schedule: Optional[Schedule] = None,
|
672
672
|
schedules: Optional["FlexibleScheduleList"] = None,
|
673
673
|
concurrency_limit: Optional[Union[int, ConcurrencyLimitConfig, None]] = None,
|
674
674
|
parameters: Optional[dict[str, Any]] = None,
|
@@ -693,6 +693,8 @@ class Flow(Generic[P, R]):
|
|
693
693
|
cron: A cron schedule of when to execute runs of this deployment.
|
694
694
|
rrule: An rrule schedule of when to execute runs of this deployment.
|
695
695
|
paused: Whether or not to set this deployment as paused.
|
696
|
+
schedule: A schedule object defining when to execute runs of this deployment.
|
697
|
+
Used to provide additional scheduling options like `timezone` or `parameters`.
|
696
698
|
schedules: A list of schedule objects defining when to execute runs of this deployment.
|
697
699
|
Used to define multiple schedules or additional scheduling options such as `timezone`.
|
698
700
|
concurrency_limit: The maximum number of runs of this deployment that can run at the same time.
|
@@ -749,6 +751,7 @@ class Flow(Generic[P, R]):
|
|
749
751
|
cron=cron,
|
750
752
|
rrule=rrule,
|
751
753
|
paused=paused,
|
754
|
+
schedule=schedule,
|
752
755
|
schedules=schedules,
|
753
756
|
concurrency_limit=concurrency_limit,
|
754
757
|
tags=tags,
|
@@ -770,6 +773,7 @@ class Flow(Generic[P, R]):
|
|
770
773
|
cron=cron,
|
771
774
|
rrule=rrule,
|
772
775
|
paused=paused,
|
776
|
+
schedule=schedule,
|
773
777
|
schedules=schedules,
|
774
778
|
concurrency_limit=concurrency_limit,
|
775
779
|
tags=tags,
|
@@ -800,6 +804,7 @@ class Flow(Generic[P, R]):
|
|
800
804
|
cron: Optional[Union[Iterable[str], str]] = None,
|
801
805
|
rrule: Optional[Union[Iterable[str], str]] = None,
|
802
806
|
paused: Optional[bool] = None,
|
807
|
+
schedule: Optional[Schedule] = None,
|
803
808
|
schedules: Optional["FlexibleScheduleList"] = None,
|
804
809
|
concurrency_limit: Optional[Union[int, ConcurrencyLimitConfig, None]] = None,
|
805
810
|
parameters: Optional[dict[str, Any]] = None,
|
@@ -824,6 +829,8 @@ class Flow(Generic[P, R]):
|
|
824
829
|
cron: A cron schedule of when to execute runs of this deployment.
|
825
830
|
rrule: An rrule schedule of when to execute runs of this deployment.
|
826
831
|
paused: Whether or not to set this deployment as paused.
|
832
|
+
schedule: A schedule object defining when to execute runs of this deployment.
|
833
|
+
Used to provide additional scheduling options like `timezone` or `parameters`.
|
827
834
|
schedules: A list of schedule objects defining when to execute runs of this deployment.
|
828
835
|
Used to define multiple schedules or additional scheduling options such as `timezone`.
|
829
836
|
concurrency_limit: The maximum number of runs of this deployment that can run at the same time.
|
@@ -882,6 +889,7 @@ class Flow(Generic[P, R]):
|
|
882
889
|
cron=cron,
|
883
890
|
rrule=rrule,
|
884
891
|
paused=paused,
|
892
|
+
schedule=schedule,
|
885
893
|
schedules=schedules,
|
886
894
|
concurrency_limit=concurrency_limit,
|
887
895
|
tags=tags,
|
@@ -905,6 +913,7 @@ class Flow(Generic[P, R]):
|
|
905
913
|
cron=cron,
|
906
914
|
rrule=rrule,
|
907
915
|
paused=paused,
|
916
|
+
schedule=schedule,
|
908
917
|
schedules=schedules,
|
909
918
|
concurrency_limit=concurrency_limit,
|
910
919
|
tags=tags,
|
@@ -954,6 +963,7 @@ class Flow(Generic[P, R]):
|
|
954
963
|
cron: Optional[Union[Iterable[str], str]] = None,
|
955
964
|
rrule: Optional[Union[Iterable[str], str]] = None,
|
956
965
|
paused: Optional[bool] = None,
|
966
|
+
schedule: Optional[Schedule] = None,
|
957
967
|
schedules: Optional["FlexibleScheduleList"] = None,
|
958
968
|
global_limit: Optional[Union[int, ConcurrencyLimitConfig, None]] = None,
|
959
969
|
triggers: Optional[list[Union[DeploymentTriggerTypes, TriggerTypes]]] = None,
|
@@ -983,6 +993,8 @@ class Flow(Generic[P, R]):
|
|
983
993
|
Also accepts an iterable of rrule schedule strings to create multiple schedules.
|
984
994
|
triggers: A list of triggers that will kick off runs of this deployment.
|
985
995
|
paused: Whether or not to set this deployment as paused.
|
996
|
+
schedule: A schedule object defining when to execute runs of this deployment.
|
997
|
+
Used to provide additional scheduling options like `timezone` or `parameters`.
|
986
998
|
schedules: A list of schedule objects defining when to execute runs of this deployment.
|
987
999
|
Used to define multiple schedules or additional scheduling options like `timezone`.
|
988
1000
|
global_limit: The maximum number of concurrent runs allowed across all served flow instances associated with the same deployment.
|
@@ -1048,6 +1060,7 @@ class Flow(Generic[P, R]):
|
|
1048
1060
|
cron=cron,
|
1049
1061
|
rrule=rrule,
|
1050
1062
|
paused=paused,
|
1063
|
+
schedule=schedule,
|
1051
1064
|
schedules=schedules,
|
1052
1065
|
concurrency_limit=global_limit,
|
1053
1066
|
parameters=parameters,
|
@@ -1327,7 +1340,8 @@ class Flow(Generic[P, R]):
|
|
1327
1340
|
cron: Optional[str] = None,
|
1328
1341
|
rrule: Optional[str] = None,
|
1329
1342
|
paused: Optional[bool] = None,
|
1330
|
-
|
1343
|
+
schedule: Optional[Schedule] = None,
|
1344
|
+
schedules: Optional[list[Schedule]] = None,
|
1331
1345
|
concurrency_limit: Optional[Union[int, ConcurrencyLimitConfig, None]] = None,
|
1332
1346
|
triggers: Optional[list[Union[DeploymentTriggerTypes, TriggerTypes]]] = None,
|
1333
1347
|
parameters: Optional[dict[str, Any]] = None,
|
@@ -1374,6 +1388,8 @@ class Flow(Generic[P, R]):
|
|
1374
1388
|
Also accepts an iterable of rrule schedule strings to create multiple schedules.
|
1375
1389
|
triggers: A list of triggers that will kick off runs of this deployment.
|
1376
1390
|
paused: Whether or not to set this deployment as paused.
|
1391
|
+
schedule: A schedule object defining when to execute runs of this deployment.
|
1392
|
+
Used to provide additional scheduling options like `timezone` or `parameters`.
|
1377
1393
|
schedules: A list of schedule objects defining when to execute runs of this deployment.
|
1378
1394
|
Used to define multiple schedules or additional scheduling options like `timezone`.
|
1379
1395
|
concurrency_limit: The maximum number of runs that can be executed concurrently.
|
@@ -1458,6 +1474,7 @@ class Flow(Generic[P, R]):
|
|
1458
1474
|
interval=interval,
|
1459
1475
|
cron=cron,
|
1460
1476
|
rrule=rrule,
|
1477
|
+
schedule=schedule,
|
1461
1478
|
schedules=schedules,
|
1462
1479
|
concurrency_limit=concurrency_limit,
|
1463
1480
|
paused=paused,
|
@@ -1535,16 +1552,14 @@ class Flow(Generic[P, R]):
|
|
1535
1552
|
@overload
|
1536
1553
|
def __call__(
|
1537
1554
|
self: "Flow[P, Coroutine[Any, Any, T]]", *args: P.args, **kwargs: P.kwargs
|
1538
|
-
) -> Coroutine[Any, Any, T]:
|
1539
|
-
...
|
1555
|
+
) -> Coroutine[Any, Any, T]: ...
|
1540
1556
|
|
1541
1557
|
@overload
|
1542
1558
|
def __call__(
|
1543
1559
|
self: "Flow[P, T]",
|
1544
1560
|
*args: P.args,
|
1545
1561
|
**kwargs: P.kwargs,
|
1546
|
-
) -> T:
|
1547
|
-
...
|
1562
|
+
) -> T: ...
|
1548
1563
|
|
1549
1564
|
@overload
|
1550
1565
|
def __call__(
|
@@ -1552,8 +1567,7 @@ class Flow(Generic[P, R]):
|
|
1552
1567
|
*args: P.args,
|
1553
1568
|
return_state: Literal[True],
|
1554
1569
|
**kwargs: P.kwargs,
|
1555
|
-
) -> Awaitable[State[T]]:
|
1556
|
-
...
|
1570
|
+
) -> Awaitable[State[T]]: ...
|
1557
1571
|
|
1558
1572
|
@overload
|
1559
1573
|
def __call__(
|
@@ -1561,8 +1575,7 @@ class Flow(Generic[P, R]):
|
|
1561
1575
|
*args: P.args,
|
1562
1576
|
return_state: Literal[True],
|
1563
1577
|
**kwargs: P.kwargs,
|
1564
|
-
) -> State[T]:
|
1565
|
-
...
|
1578
|
+
) -> State[T]: ...
|
1566
1579
|
|
1567
1580
|
def __call__(
|
1568
1581
|
self,
|
@@ -1701,8 +1714,7 @@ class Flow(Generic[P, R]):
|
|
1701
1714
|
|
1702
1715
|
class FlowDecorator:
|
1703
1716
|
@overload
|
1704
|
-
def __call__(self, __fn: Callable[P, R]) -> Flow[P, R]:
|
1705
|
-
...
|
1717
|
+
def __call__(self, __fn: Callable[P, R]) -> Flow[P, R]: ...
|
1706
1718
|
|
1707
1719
|
@overload
|
1708
1720
|
def __call__(
|
@@ -1728,8 +1740,7 @@ class FlowDecorator:
|
|
1728
1740
|
on_cancellation: Optional[list[FlowStateHook[..., Any]]] = None,
|
1729
1741
|
on_crashed: Optional[list[FlowStateHook[..., Any]]] = None,
|
1730
1742
|
on_running: Optional[list[FlowStateHook[..., Any]]] = None,
|
1731
|
-
) -> Callable[[Callable[P, R]], Flow[P, R]]:
|
1732
|
-
...
|
1743
|
+
) -> Callable[[Callable[P, R]], Flow[P, R]]: ...
|
1733
1744
|
|
1734
1745
|
@overload
|
1735
1746
|
def __call__(
|
@@ -1755,8 +1766,7 @@ class FlowDecorator:
|
|
1755
1766
|
on_cancellation: Optional[list[FlowStateHook[..., Any]]] = None,
|
1756
1767
|
on_crashed: Optional[list[FlowStateHook[..., Any]]] = None,
|
1757
1768
|
on_running: Optional[list[FlowStateHook[..., Any]]] = None,
|
1758
|
-
) -> Callable[[Callable[P, R]], Flow[P, R]]:
|
1759
|
-
...
|
1769
|
+
) -> Callable[[Callable[P, R]], Flow[P, R]]: ...
|
1760
1770
|
|
1761
1771
|
def __call__(
|
1762
1772
|
self,
|
@@ -1950,8 +1960,7 @@ class FlowDecorator:
|
|
1950
1960
|
def from_source(
|
1951
1961
|
source: Union[str, "RunnerStorage", ReadableDeploymentStorage],
|
1952
1962
|
entrypoint: str,
|
1953
|
-
) -> Union["Flow[..., Any]", Coroutine[Any, Any, "Flow[..., Any]"]]:
|
1954
|
-
...
|
1963
|
+
) -> Union["Flow[..., Any]", Coroutine[Any, Any, "Flow[..., Any]"]]: ...
|
1955
1964
|
|
1956
1965
|
|
1957
1966
|
flow: FlowDecorator = FlowDecorator()
|
@@ -2071,6 +2080,29 @@ def load_flow_from_entrypoint(
|
|
2071
2080
|
return flow
|
2072
2081
|
|
2073
2082
|
|
2083
|
+
def load_function_and_convert_to_flow(entrypoint: str) -> Flow[P, Any]:
|
2084
|
+
"""
|
2085
|
+
Loads a function from an entrypoint and converts it to a flow if it is not already a flow.
|
2086
|
+
"""
|
2087
|
+
|
2088
|
+
if ":" in entrypoint:
|
2089
|
+
# split by the last colon once to handle Windows paths with drive letters i.e C:\path\to\file.py:do_stuff
|
2090
|
+
path, func_name = entrypoint.rsplit(":", maxsplit=1)
|
2091
|
+
else:
|
2092
|
+
path, func_name = entrypoint.rsplit(".", maxsplit=1)
|
2093
|
+
try:
|
2094
|
+
func = import_object(entrypoint) # pyright: ignore[reportRedeclaration]
|
2095
|
+
except AttributeError as exc:
|
2096
|
+
raise RuntimeError(
|
2097
|
+
f"Function with name {func_name!r} not found in {path!r}."
|
2098
|
+
) from exc
|
2099
|
+
|
2100
|
+
if isinstance(func, Flow):
|
2101
|
+
return func
|
2102
|
+
else:
|
2103
|
+
return Flow(func, log_prints=True)
|
2104
|
+
|
2105
|
+
|
2074
2106
|
def serve(
|
2075
2107
|
*args: "RunnerDeployment",
|
2076
2108
|
pause_on_shutdown: bool = True,
|
@@ -2223,8 +2255,7 @@ def _display_serve_start_message(*args: "RunnerDeployment"):
|
|
2223
2255
|
from rich.table import Table
|
2224
2256
|
|
2225
2257
|
help_message_top = (
|
2226
|
-
"[green]Your deployments are being served and polling for"
|
2227
|
-
" scheduled runs!\n[/]"
|
2258
|
+
"[green]Your deployments are being served and polling for scheduled runs!\n[/]"
|
2228
2259
|
)
|
2229
2260
|
|
2230
2261
|
table = Table(title="Deployments", show_header=False)
|
prefect/infrastructure/base.py
CHANGED
@@ -22,20 +22,17 @@ _provisioners = {
|
|
22
22
|
|
23
23
|
class Provisioner(Protocol):
|
24
24
|
@property
|
25
|
-
def console(self) -> rich.console.Console:
|
26
|
-
...
|
25
|
+
def console(self) -> rich.console.Console: ...
|
27
26
|
|
28
27
|
@console.setter
|
29
|
-
def console(self, value: rich.console.Console) -> None:
|
30
|
-
...
|
28
|
+
def console(self, value: rich.console.Console) -> None: ...
|
31
29
|
|
32
30
|
async def provision(
|
33
31
|
self,
|
34
32
|
work_pool_name: str,
|
35
33
|
base_job_template: Dict[str, Any],
|
36
34
|
client: Optional["PrefectClient"] = None,
|
37
|
-
) -> Dict[str, Any]:
|
38
|
-
...
|
35
|
+
) -> Dict[str, Any]: ...
|
39
36
|
|
40
37
|
|
41
38
|
def get_infrastructure_provisioner_for_work_pool_type(
|
@@ -118,9 +118,9 @@ class CoiledPushProvisioner:
|
|
118
118
|
block_type_id=credentials_block_type.id
|
119
119
|
)
|
120
120
|
)
|
121
|
-
assert (
|
122
|
-
|
123
|
-
)
|
121
|
+
assert credentials_block_schema is not None, (
|
122
|
+
f"Unable to find schema for block type {credentials_block_type.slug}"
|
123
|
+
)
|
124
124
|
|
125
125
|
block_doc = await client.create_block_document(
|
126
126
|
block_document=BlockDocumentCreate(
|
@@ -341,9 +341,9 @@ class CredentialsBlockResource:
|
|
341
341
|
block_type_id=credentials_block_type.id
|
342
342
|
)
|
343
343
|
)
|
344
|
-
assert (
|
345
|
-
|
346
|
-
)
|
344
|
+
assert credentials_block_schema is not None, (
|
345
|
+
f"Unable to find schema for block type {credentials_block_type.slug}"
|
346
|
+
)
|
347
347
|
|
348
348
|
block_doc = await client.create_block_document(
|
349
349
|
block_document=BlockDocumentCreate(
|
@@ -597,9 +597,9 @@ class ClusterResource:
|
|
597
597
|
)
|
598
598
|
advance()
|
599
599
|
|
600
|
-
base_job_template["variables"]["properties"]["cluster"][
|
601
|
-
|
602
|
-
|
600
|
+
base_job_template["variables"]["properties"]["cluster"]["default"] = (
|
601
|
+
self._cluster_name
|
602
|
+
)
|
603
603
|
|
604
604
|
@property
|
605
605
|
def next_steps(self) -> list[str]:
|
@@ -124,9 +124,9 @@ class ModalPushProvisioner:
|
|
124
124
|
block_type_id=credentials_block_type.id
|
125
125
|
)
|
126
126
|
)
|
127
|
-
assert (
|
128
|
-
|
129
|
-
)
|
127
|
+
assert credentials_block_schema is not None, (
|
128
|
+
f"Unable to find schema for block type {credentials_block_type.slug}"
|
129
|
+
)
|
130
130
|
|
131
131
|
block_doc = await client.create_block_document(
|
132
132
|
block_document=BlockDocumentCreate(
|
prefect/input/run_input.py
CHANGED
@@ -664,8 +664,7 @@ def receive_input( # type: ignore[overload-overlap]
|
|
664
664
|
key_prefix: Optional[str] = None,
|
665
665
|
flow_run_id: Optional[UUID] = None,
|
666
666
|
with_metadata: bool = False,
|
667
|
-
) -> GetInputHandler[R]:
|
668
|
-
...
|
667
|
+
) -> GetInputHandler[R]: ...
|
669
668
|
|
670
669
|
|
671
670
|
@overload
|
@@ -678,8 +677,7 @@ def receive_input(
|
|
678
677
|
key_prefix: Optional[str] = None,
|
679
678
|
flow_run_id: Optional[UUID] = None,
|
680
679
|
with_metadata: bool = False,
|
681
|
-
) -> GetAutomaticInputHandler[T]:
|
682
|
-
...
|
680
|
+
) -> GetAutomaticInputHandler[T]: ...
|
683
681
|
|
684
682
|
|
685
683
|
def receive_input(
|
@@ -697,9 +695,9 @@ def receive_input(
|
|
697
695
|
# the signature is the same as here:
|
698
696
|
# Union[Type[R], Type[T], pydantic.BaseModel],
|
699
697
|
# Seems like a possible mypy bug, so we'll ignore the type check here.
|
700
|
-
input_cls: Union[
|
701
|
-
|
702
|
-
|
698
|
+
input_cls: Union[Type[AutomaticRunInput[T]], Type[R]] = (
|
699
|
+
run_input_subclass_from_type(input_type)
|
700
|
+
) # type: ignore[arg-type]
|
703
701
|
|
704
702
|
if issubclass(input_cls, AutomaticRunInput):
|
705
703
|
return input_cls.receive(
|
prefect/locking/filesystem.py
CHANGED
@@ -9,6 +9,7 @@ import pydantic_core
|
|
9
9
|
from typing_extensions import TypedDict
|
10
10
|
|
11
11
|
from prefect.logging.loggers import get_logger
|
12
|
+
from prefect.types._datetime import DateTime, PendulumDuration
|
12
13
|
|
13
14
|
from .protocol import LockManager
|
14
15
|
|
@@ -116,7 +117,7 @@ class FileSystemLockManager(LockManager):
|
|
116
117
|
)
|
117
118
|
return self.acquire_lock(key, holder, acquire_timeout, hold_timeout)
|
118
119
|
expiration = (
|
119
|
-
|
120
|
+
DateTime.now("utc") + PendulumDuration(seconds=hold_timeout)
|
120
121
|
if hold_timeout is not None
|
121
122
|
else None
|
122
123
|
)
|
@@ -165,7 +166,7 @@ class FileSystemLockManager(LockManager):
|
|
165
166
|
)
|
166
167
|
return self.acquire_lock(key, holder, acquire_timeout, hold_timeout)
|
167
168
|
expiration = (
|
168
|
-
|
169
|
+
DateTime.now("utc") + PendulumDuration(seconds=hold_timeout)
|
169
170
|
if hold_timeout is not None
|
170
171
|
else None
|
171
172
|
)
|
@@ -207,7 +208,7 @@ class FileSystemLockManager(LockManager):
|
|
207
208
|
if (expiration := lock_info.get("expiration")) is None:
|
208
209
|
return True
|
209
210
|
|
210
|
-
expired = expiration <
|
211
|
+
expired = expiration < DateTime.now("utc")
|
211
212
|
if expired:
|
212
213
|
Path(lock_info["path"]).unlink()
|
213
214
|
self._locks.pop(key, None)
|
prefect/main.py
CHANGED
@@ -8,7 +8,7 @@ from prefect.transactions import Transaction
|
|
8
8
|
from prefect.tasks import task, Task
|
9
9
|
from prefect.context import tags
|
10
10
|
from prefect.utilities.annotations import unmapped, allow_failure
|
11
|
-
from prefect.
|
11
|
+
from prefect._result_records import ResultRecordMetadata
|
12
12
|
from prefect.flow_runs import pause_flow_run, resume_flow_run, suspend_flow_run
|
13
13
|
from prefect.client.orchestration import get_client
|
14
14
|
from prefect.client.cloud import get_cloud_client
|