Tilak Maddy

    Tilak Maddy

    9 months ago
    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 ?
    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.
    Anna Geller

    Anna Geller

    9 months ago
    @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:
    from prefect import Flow, task
    from prefect.engine.results import LocalResult
    
    @task(result=LocalResult(dir='~/Desktop/HelloWorld/results'))
    def my_task():
        return 3
    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
    Tilak Maddy

    Tilak Maddy

    9 months ago
    i am using prefect 0.15.10
    Anna Geller

    Anna Geller

    9 months ago
    interesting. I was curious because of the phrase β€œNo result handler” in the message.
    Tilak Maddy

    Tilak Maddy

    9 months ago
    yeah...but it is weird to me because I hadn't gotten that warning with storage as local
    Anna Geller

    Anna Geller

    9 months ago
    it probably defaulted to LocalResult then. If you specify your Result location explicitly, you no longer should get this warning