From 5eb4aad5dd2834dfa89e23a9a62b267e028ad81c Mon Sep 17 00:00:00 2001 From: Adam Azzam <33043305+AAAZZAM@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:30:48 -0600 Subject: [PATCH 1/3] Update flows.py --- src/prefect/flows.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/prefect/flows.py b/src/prefect/flows.py index 4ffef3c1dfc3..adf46274f0a0 100644 --- a/src/prefect/flows.py +++ b/src/prefect/flows.py @@ -37,7 +37,7 @@ from uuid import UUID import pydantic -from fastapi.encoders import jsonable_encoder + from pydantic.v1 import BaseModel as V1BaseModel from pydantic.v1.decorator import ValidatedFunction as V1ValidatedFunction from pydantic.v1.errors import ConfigError # TODO @@ -613,6 +613,8 @@ def serialize_parameters(self, parameters: dict[str, Any]) -> dict[str, Any]: serialized_parameters[key] = f"<{type(value).__name__}>" continue try: + from fastapi.encoders import jsonable_encoder + serialized_parameters[key] = jsonable_encoder(value) except (TypeError, ValueError): logger.debug( @@ -1244,16 +1246,14 @@ def __call__(self: "Flow[P, NoReturn]", *args: P.args, **kwargs: P.kwargs) -> No @overload def __call__( self: "Flow[P, Coroutine[Any, Any, T]]", *args: P.args, **kwargs: P.kwargs - ) -> Coroutine[Any, Any, T]: - ... + ) -> Coroutine[Any, Any, T]: ... @overload def __call__( self: "Flow[P, T]", *args: P.args, **kwargs: P.kwargs, - ) -> T: - ... + ) -> T: ... @overload def __call__( @@ -1261,8 +1261,7 @@ def __call__( *args: P.args, return_state: Literal[True], **kwargs: P.kwargs, - ) -> Awaitable[State[T]]: - ... + ) -> Awaitable[State[T]]: ... @overload def __call__( @@ -1270,8 +1269,7 @@ def __call__( *args: P.args, return_state: Literal[True], **kwargs: P.kwargs, - ) -> State[T]: - ... + ) -> State[T]: ... def __call__( self, @@ -1410,8 +1408,7 @@ async def visualize(self, *args: "P.args", **kwargs: "P.kwargs"): class FlowDecorator: @overload - def __call__(self, __fn: Callable[P, R]) -> Flow[P, R]: - ... + def __call__(self, __fn: Callable[P, R]) -> Flow[P, R]: ... @overload def __call__( @@ -1437,8 +1434,7 @@ def __call__( on_cancellation: Optional[list[StateHookCallable]] = None, on_crashed: Optional[list[StateHookCallable]] = None, on_running: Optional[list[StateHookCallable]] = None, - ) -> Callable[[Callable[P, R]], Flow[P, R]]: - ... + ) -> Callable[[Callable[P, R]], Flow[P, R]]: ... @overload def __call__( @@ -1464,8 +1460,7 @@ def __call__( on_cancellation: Optional[list[StateHookCallable]] = None, on_crashed: Optional[list[StateHookCallable]] = None, on_running: Optional[list[StateHookCallable]] = None, - ) -> Callable[[Callable[P, R]], Flow[P, R]]: - ... + ) -> Callable[[Callable[P, R]], Flow[P, R]]: ... def __call__( self, @@ -1659,8 +1654,7 @@ def __call__( def from_source( source: Union[str, "RunnerStorage", ReadableDeploymentStorage], entrypoint: str, - ) -> Union["Flow[..., Any]", Coroutine[Any, Any, "Flow[..., Any]"]]: - ... + ) -> Union["Flow[..., Any]", Coroutine[Any, Any, "Flow[..., Any]"]]: ... flow = FlowDecorator() From 3ed86cfc85898798d6ca68735eaa6a47d390f14f Mon Sep 17 00:00:00 2001 From: Adam Azzam <33043305+AAAZZAM@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:28:09 -0600 Subject: [PATCH 2/3] lint --- src/prefect/flows.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/prefect/flows.py b/src/prefect/flows.py index adf46274f0a0..20d0c7f60e0f 100644 --- a/src/prefect/flows.py +++ b/src/prefect/flows.py @@ -37,7 +37,6 @@ from uuid import UUID import pydantic - from pydantic.v1 import BaseModel as V1BaseModel from pydantic.v1.decorator import ValidatedFunction as V1ValidatedFunction from pydantic.v1.errors import ConfigError # TODO From 9fc1fece4d3a08635ff63b8faa03fe522c11ef37 Mon Sep 17 00:00:00 2001 From: Adam Azzam <33043305+AAAZZAM@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:07:00 -0600 Subject: [PATCH 3/3] Update flows.py --- src/prefect/flows.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/prefect/flows.py b/src/prefect/flows.py index 20d0c7f60e0f..cbd763952c2f 100644 --- a/src/prefect/flows.py +++ b/src/prefect/flows.py @@ -1245,14 +1245,16 @@ def __call__(self: "Flow[P, NoReturn]", *args: P.args, **kwargs: P.kwargs) -> No @overload def __call__( self: "Flow[P, Coroutine[Any, Any, T]]", *args: P.args, **kwargs: P.kwargs - ) -> Coroutine[Any, Any, T]: ... + ) -> Coroutine[Any, Any, T]: + ... @overload def __call__( self: "Flow[P, T]", *args: P.args, **kwargs: P.kwargs, - ) -> T: ... + ) -> T: + ... @overload def __call__( @@ -1260,7 +1262,8 @@ def __call__( *args: P.args, return_state: Literal[True], **kwargs: P.kwargs, - ) -> Awaitable[State[T]]: ... + ) -> Awaitable[State[T]]: + ... @overload def __call__( @@ -1268,7 +1271,8 @@ def __call__( *args: P.args, return_state: Literal[True], **kwargs: P.kwargs, - ) -> State[T]: ... + ) -> State[T]: + ... def __call__( self, @@ -1407,7 +1411,8 @@ async def visualize(self, *args: "P.args", **kwargs: "P.kwargs"): class FlowDecorator: @overload - def __call__(self, __fn: Callable[P, R]) -> Flow[P, R]: ... + def __call__(self, __fn: Callable[P, R]) -> Flow[P, R]: + ... @overload def __call__( @@ -1433,7 +1438,8 @@ def __call__( on_cancellation: Optional[list[StateHookCallable]] = None, on_crashed: Optional[list[StateHookCallable]] = None, on_running: Optional[list[StateHookCallable]] = None, - ) -> Callable[[Callable[P, R]], Flow[P, R]]: ... + ) -> Callable[[Callable[P, R]], Flow[P, R]]: + ... @overload def __call__( @@ -1459,7 +1465,8 @@ def __call__( on_cancellation: Optional[list[StateHookCallable]] = None, on_crashed: Optional[list[StateHookCallable]] = None, on_running: Optional[list[StateHookCallable]] = None, - ) -> Callable[[Callable[P, R]], Flow[P, R]]: ... + ) -> Callable[[Callable[P, R]], Flow[P, R]]: + ... def __call__( self, @@ -1653,7 +1660,8 @@ def __call__( def from_source( source: Union[str, "RunnerStorage", ReadableDeploymentStorage], entrypoint: str, - ) -> Union["Flow[..., Any]", Coroutine[Any, Any, "Flow[..., Any]"]]: ... + ) -> Union["Flow[..., Any]", Coroutine[Any, Any, "Flow[..., Any]"]]: + ... flow = FlowDecorator()