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

fix(backend): include prefect-redis as dependency #5907

Closed
wants to merge 3 commits into from

Conversation

fatih-acar
Copy link
Contributor

@fatih-acar fatih-acar commented Mar 3, 2025

This PR adds prefect-redis as dependency.

This is actually the default since 3.1.14.
We also need it for Redis messaging & cache support (required for HA).

Also upgrade to 3.1.15 to include some fixes regarding Redis messaging.

Edit: Prefect 3.1.15 introduced a change that breaks mypy, ignore these errors for now

Signed-off-by: Fatih Acar <fatih@opsmill.com>
This is actually the default since 3.1.14.
We also need it for Redis messaging support (required for HA).

Signed-off-by: Fatih Acar <fatih@opsmill.com>
@fatih-acar fatih-acar requested a review from a team as a code owner March 3, 2025 09:16
@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Mar 3, 2025
Copy link

codspeed-hq bot commented Mar 3, 2025

CodSpeed Performance Report

Merging #5907 will not alter performance

Comparing fac-add-prefect-redis (9c9bbe3) with release-1.2 (62a2b9e)

Summary

✅ 10 untouched benchmarks

Prefect 3.1.15 introduced a change that breaks mypy with
error: Incompatible types in "await" (actual type "State[Coroutine[Any, Any, None]]", expected type
"Awaitable[Any]")  [misc]

Signed-off-by: Fatih Acar <fatih@opsmill.com>
@fatih-acar fatih-acar force-pushed the fac-add-prefect-redis branch from 9c79b36 to 9c9bbe3 Compare March 3, 2025 20:58
@dgarros
Copy link
Collaborator

dgarros commented Mar 4, 2025

Have we checked the latest 3.2 release, ideally this should be our target release.
Also do you know if there is an issue open on Prefect side to track the issue with Mypy ?

@fatih-acar
Copy link
Contributor Author

Have we checked the latest 3.2 release, ideally this should be our target release. Also do you know if there is an issue open on Prefect side to track the issue with Mypy ?

Not sure we want to upgrade to Prefect 3.2 at this stage of our release cycle... maybe for our next release?
I mainly need this prefect-redis stuff to have our upcoming release ready for HA.

I don't know if there's an issue open upstream, first step would to try the latest 3.2 release to see if its already fixed?

@ogenstad
Copy link
Contributor

ogenstad commented Mar 5, 2025

Looked at this briefly it's the same in 3.2.9.

git diff 3.1.14 3.1.15 -- src/prefect/tasks.py
diff --git a/src/prefect/tasks.py b/src/prefect/tasks.py
index 7763722573..9b291f7a66 100644
--- a/src/prefect/tasks.py
+++ b/src/prefect/tasks.py
@@ -965,7 +965,7 @@ class Task(Generic[P, R]):
     def __call__(
         self: "Task[P, NoReturn]",
         *args: P.args,
-        return_state: Literal[False],
+        return_state: Literal[False] = False,
         wait_for: Optional[OneOrManyFutureOrResult[Any]] = None,
         **kwargs: P.kwargs,
     ) -> None:
@@ -977,20 +977,22 @@ class Task(Generic[P, R]):
     def __call__(
         self: "Task[P, R]",
         *args: P.args,
-        return_state: Literal[True],
-        wait_for: Optional[OneOrManyFutureOrResult[Any]] = None,
         **kwargs: P.kwargs,
-    ) -> State[R]:
+    ) -> R:
         ...

+    # Keyword parameters `return_state` and `wait_for` aren't allowed after the
+    # ParamSpec `*args` parameter, so we lose return type typing when either of
+    # those are provided.
+    # TODO: Find a way to expose this functionality without losing type information
     @overload
     def __call__(
         self: "Task[P, R]",
         *args: P.args,
-        return_state: Literal[False],
+        return_state: Literal[True] = True,
         wait_for: Optional[OneOrManyFutureOrResult[Any]] = None,
         **kwargs: P.kwargs,
-    ) -> R:
+    ) -> State[R]:
         ...

As a note if I switch the order of these in Prefect it works as before, but could possibly break stuff for other people.

    # Keyword parameters `return_state` and `wait_for` aren't allowed after the
    # ParamSpec `*args` parameter, so we lose return type typing when either of
    # those are provided.
    # TODO: Find a way to expose this functionality without losing type information
    @overload
    def __call__(
        self: "Task[P, R]",
        *args: P.args,
        return_state: Literal[True] = True,
        wait_for: Optional[OneOrManyFutureOrResult[Any]] = None,
        **kwargs: P.kwargs,
    ) -> State[R]: ...

    @overload
    def __call__(
        self: "Task[P, R]",
        *args: P.args,
        return_state: Literal[False] = False,
        wait_for: Optional[OneOrManyFutureOrResult[Any]] = None,
        **kwargs: P.kwargs,
    ) -> R: ...

I'll open an issue during the day.

@dgarros
Copy link
Collaborator

dgarros commented Mar 5, 2025

Thanks @ogenstad
what is your take on upgrading to 3.2.9 for Infrahub 1.2 ?

@ogenstad
Copy link
Contributor

ogenstad commented Mar 5, 2025

what is your take on upgrading to 3.2.9 for Infrahub 1.2 ?

I'd say it depends on when the final release of 1.2 will be cut. I think it would be good with some time to test and validate everything to see if there are any regressions related to this. However looking at the bump in the minor version (https://github.com/PrefectHQ/prefect/releases/tag/3.2.0) it looks like the new features are mostly around the ability to schedule tasks. My guess is that there hasn't been the type of huge changes that would impact us in a negative way.

@ogenstad
Copy link
Contributor

ogenstad commented Mar 5, 2025

I've opened PrefectHQ/prefect#17379

@fatih-acar fatih-acar closed this Mar 5, 2025
@fatih-acar fatih-acar deleted the fac-add-prefect-redis branch March 5, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants