prefect-client 3.1.8__py3-none-any.whl → 3.1.10__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.
Files changed (44) hide show
  1. prefect/__init__.py +53 -59
  2. prefect/_internal/concurrency/services.py +6 -4
  3. prefect/_version.py +3 -3
  4. prefect/agent.py +3 -1
  5. prefect/artifacts.py +61 -74
  6. prefect/automations.py +27 -7
  7. prefect/client/cloud.py +0 -21
  8. prefect/client/schemas/objects.py +11 -0
  9. prefect/client/utilities.py +1 -15
  10. prefect/context.py +16 -27
  11. prefect/deployments/deployments.py +4 -2
  12. prefect/deployments/runner.py +3 -1
  13. prefect/engine.py +2 -1
  14. prefect/events/filters.py +2 -8
  15. prefect/exceptions.py +31 -41
  16. prefect/filesystems.py +2 -2
  17. prefect/flow_engine.py +2 -2
  18. prefect/flows.py +230 -186
  19. prefect/futures.py +42 -27
  20. prefect/infrastructure/__init__.py +3 -1
  21. prefect/infrastructure/base.py +3 -1
  22. prefect/locking/filesystem.py +8 -7
  23. prefect/locking/memory.py +5 -3
  24. prefect/locking/protocol.py +1 -1
  25. prefect/plugins.py +12 -10
  26. prefect/results.py +76 -19
  27. prefect/runner/runner.py +2 -3
  28. prefect/states.py +22 -10
  29. prefect/task_engine.py +1 -1
  30. prefect/telemetry/instrumentation.py +9 -10
  31. prefect/telemetry/processors.py +6 -6
  32. prefect/telemetry/services.py +68 -0
  33. prefect/utilities/engine.py +15 -1
  34. prefect/utilities/importtools.py +28 -21
  35. prefect/variables.py +2 -2
  36. prefect/workers/__init__.py +2 -0
  37. prefect/workers/base.py +6 -12
  38. prefect/workers/block.py +3 -1
  39. prefect/workers/cloud.py +3 -1
  40. {prefect_client-3.1.8.dist-info → prefect_client-3.1.10.dist-info}/METADATA +1 -1
  41. {prefect_client-3.1.8.dist-info → prefect_client-3.1.10.dist-info}/RECORD +44 -43
  42. {prefect_client-3.1.8.dist-info → prefect_client-3.1.10.dist-info}/LICENSE +0 -0
  43. {prefect_client-3.1.8.dist-info → prefect_client-3.1.10.dist-info}/WHEEL +0 -0
  44. {prefect_client-3.1.8.dist-info → prefect_client-3.1.10.dist-info}/top_level.txt +0 -0
prefect/flows.py CHANGED
@@ -37,7 +37,6 @@ from typing import (
37
37
  from uuid import UUID
38
38
 
39
39
  import pydantic
40
- from fastapi.encoders import jsonable_encoder
41
40
  from pydantic.v1 import BaseModel as V1BaseModel
42
41
  from pydantic.v1.decorator import ValidatedFunction as V1ValidatedFunction
43
42
  from pydantic.v1.errors import ConfigError # TODO
@@ -364,7 +363,7 @@ class Flow(Generic[P, R]):
364
363
  self._entrypoint: Optional[str] = None
365
364
 
366
365
  module = fn.__module__
367
- if module in ("__main__", "__prefect_loader__"):
366
+ if module and (module == "__main__" or module.startswith("__prefect_loader_")):
368
367
  module_name = inspect.getfile(fn)
369
368
  module = module_name if module_name != "__main__" else module
370
369
 
@@ -613,6 +612,8 @@ class Flow(Generic[P, R]):
613
612
  serialized_parameters[key] = f"<{type(value).__name__}>"
614
613
  continue
615
614
  try:
615
+ from fastapi.encoders import jsonable_encoder
616
+
616
617
  serialized_parameters[key] = jsonable_encoder(value)
617
618
  except (TypeError, ValueError):
618
619
  logger.debug(
@@ -924,10 +925,10 @@ class Flow(Generic[P, R]):
924
925
  @classmethod
925
926
  @sync_compatible
926
927
  async def from_source(
927
- cls: Type["Flow[P, R]"],
928
+ cls,
928
929
  source: Union[str, "RunnerStorage", ReadableDeploymentStorage],
929
930
  entrypoint: str,
930
- ) -> "Flow[P, R]":
931
+ ) -> "Flow[..., Any]":
931
932
  """
932
933
  Loads a flow from a remote source.
933
934
 
@@ -1025,7 +1026,7 @@ class Flow(Generic[P, R]):
1025
1026
 
1026
1027
  full_entrypoint = str(storage.destination / entrypoint)
1027
1028
  flow = cast(
1028
- Flow[P, R],
1029
+ "Flow[..., Any]",
1029
1030
  await from_async.wait_for_call_in_new_thread(
1030
1031
  create_call(load_flow_from_entrypoint, full_entrypoint)
1031
1032
  ),
@@ -1408,194 +1409,200 @@ class Flow(Generic[P, R]):
1408
1409
  raise new_exception
1409
1410
 
1410
1411
 
1411
- @overload
1412
- def flow(__fn: Callable[P, R]) -> Flow[P, R]:
1413
- ...
1414
-
1415
-
1416
- @overload
1417
- def flow(
1418
- *,
1419
- name: Optional[str] = None,
1420
- version: Optional[str] = None,
1421
- flow_run_name: Optional[Union[Callable[[], str], str]] = None,
1422
- retries: Optional[int] = None,
1423
- retry_delay_seconds: Optional[Union[int, float]] = None,
1424
- task_runner: Optional[TaskRunner[PrefectFuture[R]]] = None,
1425
- description: Optional[str] = None,
1426
- timeout_seconds: Union[int, float, None] = None,
1427
- validate_parameters: bool = True,
1428
- persist_result: Optional[bool] = None,
1429
- result_storage: Optional[ResultStorage] = None,
1430
- result_serializer: Optional[ResultSerializer] = None,
1431
- cache_result_in_memory: bool = True,
1432
- log_prints: Optional[bool] = None,
1433
- on_completion: Optional[list[StateHookCallable]] = None,
1434
- on_failure: Optional[list[StateHookCallable]] = None,
1435
- on_cancellation: Optional[list[StateHookCallable]] = None,
1436
- on_crashed: Optional[list[StateHookCallable]] = None,
1437
- on_running: Optional[list[StateHookCallable]] = None,
1438
- ) -> Callable[[Callable[P, R]], Flow[P, R]]:
1439
- ...
1440
-
1441
-
1442
- def flow(
1443
- __fn: Optional[Callable[P, R]] = None,
1444
- *,
1445
- name: Optional[str] = None,
1446
- version: Optional[str] = None,
1447
- flow_run_name: Optional[Union[Callable[[], str], str]] = None,
1448
- retries: Optional[int] = None,
1449
- retry_delay_seconds: Union[int, float, None] = None,
1450
- task_runner: Optional[TaskRunner[PrefectFuture[R]]] = None,
1451
- description: Optional[str] = None,
1452
- timeout_seconds: Union[int, float, None] = None,
1453
- validate_parameters: bool = True,
1454
- persist_result: Optional[bool] = None,
1455
- result_storage: Optional[ResultStorage] = None,
1456
- result_serializer: Optional[ResultSerializer] = None,
1457
- cache_result_in_memory: bool = True,
1458
- log_prints: Optional[bool] = None,
1459
- on_completion: Optional[list[StateHookCallable]] = None,
1460
- on_failure: Optional[list[StateHookCallable]] = None,
1461
- on_cancellation: Optional[list[StateHookCallable]] = None,
1462
- on_crashed: Optional[list[StateHookCallable]] = None,
1463
- on_running: Optional[list[StateHookCallable]] = None,
1464
- ):
1465
- """
1466
- Decorator to designate a function as a Prefect workflow.
1412
+ class FlowDecorator:
1413
+ @overload
1414
+ def __call__(self, __fn: Callable[P, R]) -> Flow[P, R]:
1415
+ ...
1467
1416
 
1468
- This decorator may be used for asynchronous or synchronous functions.
1417
+ @overload
1418
+ def __call__(
1419
+ self,
1420
+ __fn: None = None,
1421
+ *,
1422
+ name: Optional[str] = None,
1423
+ version: Optional[str] = None,
1424
+ flow_run_name: Optional[Union[Callable[[], str], str]] = None,
1425
+ retries: Optional[int] = None,
1426
+ retry_delay_seconds: Optional[Union[int, float]] = None,
1427
+ task_runner: None = None,
1428
+ description: Optional[str] = None,
1429
+ timeout_seconds: Union[int, float, None] = None,
1430
+ validate_parameters: bool = True,
1431
+ persist_result: Optional[bool] = None,
1432
+ result_storage: Optional[ResultStorage] = None,
1433
+ result_serializer: Optional[ResultSerializer] = None,
1434
+ cache_result_in_memory: bool = True,
1435
+ log_prints: Optional[bool] = None,
1436
+ on_completion: Optional[list[StateHookCallable]] = None,
1437
+ on_failure: Optional[list[StateHookCallable]] = None,
1438
+ on_cancellation: Optional[list[StateHookCallable]] = None,
1439
+ on_crashed: Optional[list[StateHookCallable]] = None,
1440
+ on_running: Optional[list[StateHookCallable]] = None,
1441
+ ) -> Callable[[Callable[P, R]], Flow[P, R]]:
1442
+ ...
1469
1443
 
1470
- Flow parameters must be serializable by Pydantic.
1444
+ @overload
1445
+ def __call__(
1446
+ self,
1447
+ __fn: None = None,
1448
+ *,
1449
+ name: Optional[str] = None,
1450
+ version: Optional[str] = None,
1451
+ flow_run_name: Optional[Union[Callable[[], str], str]] = None,
1452
+ retries: Optional[int] = None,
1453
+ retry_delay_seconds: Optional[Union[int, float]] = None,
1454
+ task_runner: Optional[TaskRunner[PrefectFuture[R]]] = None,
1455
+ description: Optional[str] = None,
1456
+ timeout_seconds: Union[int, float, None] = None,
1457
+ validate_parameters: bool = True,
1458
+ persist_result: Optional[bool] = None,
1459
+ result_storage: Optional[ResultStorage] = None,
1460
+ result_serializer: Optional[ResultSerializer] = None,
1461
+ cache_result_in_memory: bool = True,
1462
+ log_prints: Optional[bool] = None,
1463
+ on_completion: Optional[list[StateHookCallable]] = None,
1464
+ on_failure: Optional[list[StateHookCallable]] = None,
1465
+ on_cancellation: Optional[list[StateHookCallable]] = None,
1466
+ on_crashed: Optional[list[StateHookCallable]] = None,
1467
+ on_running: Optional[list[StateHookCallable]] = None,
1468
+ ) -> Callable[[Callable[P, R]], Flow[P, R]]:
1469
+ ...
1471
1470
 
1472
- Args:
1473
- name: An optional name for the flow; if not provided, the name will be inferred
1474
- from the given function.
1475
- version: An optional version string for the flow; if not provided, we will
1476
- attempt to create a version string as a hash of the file containing the
1477
- wrapped function; if the file cannot be located, the version will be null.
1478
- flow_run_name: An optional name to distinguish runs of this flow; this name can
1479
- be provided as a string template with the flow's parameters as variables,
1480
- or a function that returns a string.
1481
- retries: An optional number of times to retry on flow run failure.
1482
- retry_delay_seconds: An optional number of seconds to wait before retrying the
1483
- flow after failure. This is only applicable if `retries` is nonzero.
1484
- task_runner: An optional task runner to use for task execution within the flow; if
1485
- not provided, a `ConcurrentTaskRunner` will be instantiated.
1486
- description: An optional string description for the flow; if not provided, the
1487
- description will be pulled from the docstring for the decorated function.
1488
- timeout_seconds: An optional number of seconds indicating a maximum runtime for
1489
- the flow. If the flow exceeds this runtime, it will be marked as failed.
1490
- Flow execution may continue until the next task is called.
1491
- validate_parameters: By default, parameters passed to flows are validated by
1492
- Pydantic. This will check that input values conform to the annotated types
1493
- on the function. Where possible, values will be coerced into the correct
1494
- type; for example, if a parameter is defined as `x: int` and "5" is passed,
1495
- it will be resolved to `5`. If set to `False`, no validation will be
1496
- performed on flow parameters.
1497
- persist_result: An optional toggle indicating whether the result of this flow
1498
- should be persisted to result storage. Defaults to `None`, which indicates
1499
- that Prefect should choose whether the result should be persisted depending on
1500
- the features being used.
1501
- result_storage: An optional block to use to persist the result of this flow.
1502
- This value will be used as the default for any tasks in this flow.
1503
- If not provided, the local file system will be used unless called as
1504
- a subflow, at which point the default will be loaded from the parent flow.
1505
- result_serializer: An optional serializer to use to serialize the result of this
1506
- flow for persistence. This value will be used as the default for any tasks
1507
- in this flow. If not provided, the value of `PREFECT_RESULTS_DEFAULT_SERIALIZER`
1508
- will be used unless called as a subflow, at which point the default will be
1509
- loaded from the parent flow.
1510
- cache_result_in_memory: An optional toggle indicating whether the cached result of
1511
- a running the flow should be stored in memory. Defaults to `True`.
1512
- log_prints: If set, `print` statements in the flow will be redirected to the
1513
- Prefect logger for the flow run. Defaults to `None`, which indicates that
1514
- the value from the parent flow should be used. If this is a parent flow,
1515
- the default is pulled from the `PREFECT_LOGGING_LOG_PRINTS` setting.
1516
- on_completion: An optional list of functions to call when the flow run is
1517
- completed. Each function should accept three arguments: the flow, the flow
1518
- run, and the final state of the flow run.
1519
- on_failure: An optional list of functions to call when the flow run fails. Each
1520
- function should accept three arguments: the flow, the flow run, and the
1521
- final state of the flow run.
1522
- on_cancellation: An optional list of functions to call when the flow run is
1523
- cancelled. These functions will be passed the flow, flow run, and final state.
1524
- on_crashed: An optional list of functions to call when the flow run crashes. Each
1525
- function should accept three arguments: the flow, the flow run, and the
1526
- final state of the flow run.
1527
- on_running: An optional list of functions to call when the flow run is started. Each
1528
- function should accept three arguments: the flow, the flow run, and the current state
1471
+ def __call__(
1472
+ self,
1473
+ __fn: Optional[Callable[P, R]] = None,
1474
+ *,
1475
+ name: Optional[str] = None,
1476
+ version: Optional[str] = None,
1477
+ flow_run_name: Optional[Union[Callable[[], str], str]] = None,
1478
+ retries: Optional[int] = None,
1479
+ retry_delay_seconds: Union[int, float, None] = None,
1480
+ task_runner: Optional[TaskRunner[PrefectFuture[R]]] = None,
1481
+ description: Optional[str] = None,
1482
+ timeout_seconds: Union[int, float, None] = None,
1483
+ validate_parameters: bool = True,
1484
+ persist_result: Optional[bool] = None,
1485
+ result_storage: Optional[ResultStorage] = None,
1486
+ result_serializer: Optional[ResultSerializer] = None,
1487
+ cache_result_in_memory: bool = True,
1488
+ log_prints: Optional[bool] = None,
1489
+ on_completion: Optional[list[StateHookCallable]] = None,
1490
+ on_failure: Optional[list[StateHookCallable]] = None,
1491
+ on_cancellation: Optional[list[StateHookCallable]] = None,
1492
+ on_crashed: Optional[list[StateHookCallable]] = None,
1493
+ on_running: Optional[list[StateHookCallable]] = None,
1494
+ ) -> Union[Flow[P, R], Callable[[Callable[P, R]], Flow[P, R]]]:
1495
+ """
1496
+ Decorator to designate a function as a Prefect workflow.
1529
1497
 
1530
- Returns:
1531
- A callable `Flow` object which, when called, will run the flow and return its
1532
- final state.
1498
+ This decorator may be used for asynchronous or synchronous functions.
1533
1499
 
1534
- Examples:
1535
- Define a simple flow
1500
+ Flow parameters must be serializable by Pydantic.
1501
+
1502
+ Args:
1503
+ name: An optional name for the flow; if not provided, the name will be inferred
1504
+ from the given function.
1505
+ version: An optional version string for the flow; if not provided, we will
1506
+ attempt to create a version string as a hash of the file containing the
1507
+ wrapped function; if the file cannot be located, the version will be null.
1508
+ flow_run_name: An optional name to distinguish runs of this flow; this name can
1509
+ be provided as a string template with the flow's parameters as variables,
1510
+ or a function that returns a string.
1511
+ retries: An optional number of times to retry on flow run failure.
1512
+ retry_delay_seconds: An optional number of seconds to wait before retrying the
1513
+ flow after failure. This is only applicable if `retries` is nonzero.
1514
+ task_runner: An optional task runner to use for task execution within the flow; if
1515
+ not provided, a `ConcurrentTaskRunner` will be instantiated.
1516
+ description: An optional string description for the flow; if not provided, the
1517
+ description will be pulled from the docstring for the decorated function.
1518
+ timeout_seconds: An optional number of seconds indicating a maximum runtime for
1519
+ the flow. If the flow exceeds this runtime, it will be marked as failed.
1520
+ Flow execution may continue until the next task is called.
1521
+ validate_parameters: By default, parameters passed to flows are validated by
1522
+ Pydantic. This will check that input values conform to the annotated types
1523
+ on the function. Where possible, values will be coerced into the correct
1524
+ type; for example, if a parameter is defined as `x: int` and "5" is passed,
1525
+ it will be resolved to `5`. If set to `False`, no validation will be
1526
+ performed on flow parameters.
1527
+ persist_result: An optional toggle indicating whether the result of this flow
1528
+ should be persisted to result storage. Defaults to `None`, which indicates
1529
+ that Prefect should choose whether the result should be persisted depending on
1530
+ the features being used.
1531
+ result_storage: An optional block to use to persist the result of this flow.
1532
+ This value will be used as the default for any tasks in this flow.
1533
+ If not provided, the local file system will be used unless called as
1534
+ a subflow, at which point the default will be loaded from the parent flow.
1535
+ result_serializer: An optional serializer to use to serialize the result of this
1536
+ flow for persistence. This value will be used as the default for any tasks
1537
+ in this flow. If not provided, the value of `PREFECT_RESULTS_DEFAULT_SERIALIZER`
1538
+ will be used unless called as a subflow, at which point the default will be
1539
+ loaded from the parent flow.
1540
+ cache_result_in_memory: An optional toggle indicating whether the cached result of
1541
+ a running the flow should be stored in memory. Defaults to `True`.
1542
+ log_prints: If set, `print` statements in the flow will be redirected to the
1543
+ Prefect logger for the flow run. Defaults to `None`, which indicates that
1544
+ the value from the parent flow should be used. If this is a parent flow,
1545
+ the default is pulled from the `PREFECT_LOGGING_LOG_PRINTS` setting.
1546
+ on_completion: An optional list of functions to call when the flow run is
1547
+ completed. Each function should accept three arguments: the flow, the flow
1548
+ run, and the final state of the flow run.
1549
+ on_failure: An optional list of functions to call when the flow run fails. Each
1550
+ function should accept three arguments: the flow, the flow run, and the
1551
+ final state of the flow run.
1552
+ on_cancellation: An optional list of functions to call when the flow run is
1553
+ cancelled. These functions will be passed the flow, flow run, and final state.
1554
+ on_crashed: An optional list of functions to call when the flow run crashes. Each
1555
+ function should accept three arguments: the flow, the flow run, and the
1556
+ final state of the flow run.
1557
+ on_running: An optional list of functions to call when the flow run is started. Each
1558
+ function should accept three arguments: the flow, the flow run, and the current state
1536
1559
 
1537
- >>> from prefect import flow
1538
- >>> @flow
1539
- >>> def add(x, y):
1540
- >>> return x + y
1560
+ Returns:
1561
+ A callable `Flow` object which, when called, will run the flow and return its
1562
+ final state.
1541
1563
 
1542
- Define an async flow
1564
+ Examples:
1565
+ Define a simple flow
1543
1566
 
1544
- >>> @flow
1545
- >>> async def add(x, y):
1546
- >>> return x + y
1567
+ >>> from prefect import flow
1568
+ >>> @flow
1569
+ >>> def add(x, y):
1570
+ >>> return x + y
1547
1571
 
1548
- Define a flow with a version and description
1572
+ Define an async flow
1573
+
1574
+ >>> @flow
1575
+ >>> async def add(x, y):
1576
+ >>> return x + y
1549
1577
 
1550
- >>> @flow(version="first-flow", description="This flow is empty!")
1551
- >>> def my_flow():
1552
- >>> pass
1578
+ Define a flow with a version and description
1553
1579
 
1554
- Define a flow with a custom name
1580
+ >>> @flow(version="first-flow", description="This flow is empty!")
1581
+ >>> def my_flow():
1582
+ >>> pass
1555
1583
 
1556
- >>> @flow(name="The Ultimate Flow")
1557
- >>> def my_flow():
1558
- >>> pass
1584
+ Define a flow with a custom name
1559
1585
 
1560
- Define a flow that submits its tasks to dask
1586
+ >>> @flow(name="The Ultimate Flow")
1587
+ >>> def my_flow():
1588
+ >>> pass
1561
1589
 
1562
- >>> from prefect_dask.task_runners import DaskTaskRunner
1563
- >>>
1564
- >>> @flow(task_runner=DaskTaskRunner)
1565
- >>> def my_flow():
1566
- >>> pass
1567
- """
1568
- if __fn:
1569
- if isinstance(__fn, (classmethod, staticmethod)):
1570
- method_decorator = type(__fn).__name__
1571
- raise TypeError(f"@{method_decorator} should be applied on top of @flow")
1572
- return Flow(
1573
- fn=__fn,
1574
- name=name,
1575
- version=version,
1576
- flow_run_name=flow_run_name,
1577
- task_runner=task_runner,
1578
- description=description,
1579
- timeout_seconds=timeout_seconds,
1580
- validate_parameters=validate_parameters,
1581
- retries=retries,
1582
- retry_delay_seconds=retry_delay_seconds,
1583
- persist_result=persist_result,
1584
- result_storage=result_storage,
1585
- result_serializer=result_serializer,
1586
- cache_result_in_memory=cache_result_in_memory,
1587
- log_prints=log_prints,
1588
- on_completion=on_completion,
1589
- on_failure=on_failure,
1590
- on_cancellation=on_cancellation,
1591
- on_crashed=on_crashed,
1592
- on_running=on_running,
1593
- )
1594
- else:
1595
- return cast(
1596
- Callable[[Callable[P, R]], Flow[P, R]],
1597
- partial(
1598
- flow,
1590
+ Define a flow that submits its tasks to dask
1591
+
1592
+ >>> from prefect_dask.task_runners import DaskTaskRunner
1593
+ >>>
1594
+ >>> @flow(task_runner=DaskTaskRunner)
1595
+ >>> def my_flow():
1596
+ >>> pass
1597
+ """
1598
+ if __fn:
1599
+ if isinstance(__fn, (classmethod, staticmethod)):
1600
+ method_decorator = type(__fn).__name__
1601
+ raise TypeError(
1602
+ f"@{method_decorator} should be applied on top of @flow"
1603
+ )
1604
+ return Flow(
1605
+ fn=__fn,
1599
1606
  name=name,
1600
1607
  version=version,
1601
1608
  flow_run_name=flow_run_name,
@@ -1615,8 +1622,49 @@ def flow(
1615
1622
  on_cancellation=on_cancellation,
1616
1623
  on_crashed=on_crashed,
1617
1624
  on_running=on_running,
1618
- ),
1619
- )
1625
+ )
1626
+ else:
1627
+ return cast(
1628
+ Callable[[Callable[P, R]], Flow[P, R]],
1629
+ partial(
1630
+ flow,
1631
+ name=name,
1632
+ version=version,
1633
+ flow_run_name=flow_run_name,
1634
+ task_runner=task_runner,
1635
+ description=description,
1636
+ timeout_seconds=timeout_seconds,
1637
+ validate_parameters=validate_parameters,
1638
+ retries=retries,
1639
+ retry_delay_seconds=retry_delay_seconds,
1640
+ persist_result=persist_result,
1641
+ result_storage=result_storage,
1642
+ result_serializer=result_serializer,
1643
+ cache_result_in_memory=cache_result_in_memory,
1644
+ log_prints=log_prints,
1645
+ on_completion=on_completion,
1646
+ on_failure=on_failure,
1647
+ on_cancellation=on_cancellation,
1648
+ on_crashed=on_crashed,
1649
+ on_running=on_running,
1650
+ ),
1651
+ )
1652
+
1653
+ if not TYPE_CHECKING:
1654
+ # Add from_source so it is available on the flow function we all know and love
1655
+ from_source = staticmethod(Flow.from_source)
1656
+ else:
1657
+ # Mypy loses the plot somewhere along the line, so the annotation is reconstructed
1658
+ # manually here.
1659
+ @staticmethod
1660
+ def from_source(
1661
+ source: Union[str, "RunnerStorage", ReadableDeploymentStorage],
1662
+ entrypoint: str,
1663
+ ) -> Union["Flow[..., Any]", Coroutine[Any, Any, "Flow[..., Any]"]]:
1664
+ ...
1665
+
1666
+
1667
+ flow = FlowDecorator()
1620
1668
 
1621
1669
 
1622
1670
  def _raise_on_name_with_banned_characters(name: Optional[str]) -> Optional[str]:
@@ -1636,10 +1684,6 @@ def _raise_on_name_with_banned_characters(name: Optional[str]) -> Optional[str]:
1636
1684
  return name
1637
1685
 
1638
1686
 
1639
- # Add from_source so it is available on the flow function we all know and love
1640
- flow.from_source = Flow.from_source
1641
-
1642
-
1643
1687
  def select_flow(
1644
1688
  flows: Iterable[Flow[P, R]],
1645
1689
  flow_name: Optional[str] = None,
@@ -1703,7 +1747,7 @@ def load_flow_from_entrypoint(
1703
1747
  The flow object from the script
1704
1748
 
1705
1749
  Raises:
1706
- FlowScriptError: If an exception is encountered while running the script
1750
+ ScriptError: If an exception is encountered while running the script
1707
1751
  MissingFlowError: If the flow function specified in the entrypoint does not exist
1708
1752
  """
1709
1753