Hello! I am trying to use `PrefectResult` with pre...
# prefect-community
Hello! I am trying to use
with prefect core server running on my local machine. According to the docs, I understood that it should cache the result in prefect's database. I am running this simple example, extended from the one in the docs, I just added random raising of exceptions:
Copy code
def add(x, y=1):
    if random.random() > 0.7:
        raise Exception('I failed on purpose')

    return x + y

with Flow("my handled flow!") as flow:
    first_result = add.map(list(range(10)), y=unmapped(2))
When I restart the flow, it doesn't just run the failed mapped tasks, It runs all of them again, also the successful ones. On the other hand it works fine if I use
. Am I missing something? Any help would be much appreciated.
Hi @Jovan Visnjic - which version of Prefect are you running and are you restarting your flows from the Prefect UI or API?
I'm running
and I'm restarting flows from the UI.
Got it @Jovan Visnjic - I can definitely reproduce this so let me dig in a little bit.
Ah ok @Jovan Visnjic - the issue is that you're hoping for a cached result, which
doesn't provide out of the box; it instead provides data persistence for tasks in the event of failure. To allow re-use of the data you'll need to use a cache pattern (like
). You can read more about that here.
Thank you nicholas! Will give it a try.