Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove FastAPI from prefect.flow's default import path. #16473

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions src/prefect/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
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
Expand Down Expand Up @@ -613,6 +612,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(
Expand Down Expand Up @@ -1244,34 +1245,30 @@ 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__(
self: "Flow[P, Coroutine[Any, Any, T]]",
*args: P.args,
return_state: Literal[True],
**kwargs: P.kwargs,
) -> Awaitable[State[T]]:
...
) -> Awaitable[State[T]]: ...

@overload
def __call__(
self: "Flow[P, T]",
*args: P.args,
return_state: Literal[True],
**kwargs: P.kwargs,
) -> State[T]:
...
) -> State[T]: ...

def __call__(
self,
Expand Down Expand Up @@ -1410,8 +1407,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__(
Expand All @@ -1437,8 +1433,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__(
Expand All @@ -1464,8 +1459,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,
Expand Down Expand Up @@ -1659,8 +1653,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()
Expand Down
Loading