Hey y'all could you explain what this means ? `Use...
# ask-community
t
Hey y'all could you explain what this means ?
UserWarning: No result handler was specified on your Flow. Cloud features such as input caching and resuming task runs from failure may not work properly. registered_flow = client.register(
That's the whole warning message. and here is the code. It worked properly though when i triggered the run from prefect cloud, there was no problem in execution. But I want to be able to resume tasks is they fail. what do I do ?
Copy code
import os
import time
from prefect.storage import GitHub
import prefect
from prefect import task, Flow, Parameter
from prefect.run_configs import LocalRun
from prefect.executors import LocalDaskExecutor


@task
def say_hello(name):
    # Add a sleep to simulate some long-running task
    time.sleep(3)
    # Load the greeting to use from an environment variable
    greeting = os.environ.get("GREETING")
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>(f"{greeting}, {name}!")


with Flow("hello-flow") as flow:
    people = Parameter("people", default=["Arthur", "Ford", "Marvin"])
    say_hello.map(people)

flow.storage = GitHub(
    repo="XXX/test-repo",
    path="learning_storage.py",
    access_token_secret="XXX"
)

flow.run_config = LocalRun(env={"GREETING": "Hello from User 2 "}, labels=["dev"])
flow.executor = LocalDaskExecutor()
flow.register(project_name="test_user_2")
Ran this on my local machine. yes I have a copy of the flow in the mentioned github repo too.
a
@Tilak Maddy it’s just a warning πŸ™‚ if you want to, you could attach one of the Result classes e.g. S3Result. This way, when your flow fails, you could restart from failure, because the inputs of tasks are cached. Example:
Copy code
from prefect import Flow, task
from prefect.engine.results import LocalResult

@task(result=LocalResult(dir='~/Desktop/HelloWorld/results'))
def my_task():
    return 3
πŸ™‚ 1
btw, I wonder what Prefect version are you using? In general, Result handlers have been long deprecated in place of Results. If you upgrade to a newer version, you would use results from
prefect.engine.results
t
i am using prefect 0.15.10
a
interesting. I was curious because of the phrase β€œNo result *handler*” in the message.
t
yeah...but it is weird to me because I hadn't gotten that warning with storage as local
a
it probably defaulted to LocalResult then. If you specify your Result location explicitly, you no longer should get this warning
πŸ’‘ 1