Do you know if there exists a pattern for varying ...
# ask-community
h
Do you know if there exists a pattern for varying the location of a result and hence the result type? My use-case is that on my laptop I don't want to re-run every task unless either the task definition has changed or the inputs have changed; instead I just want to use a cached result. When running in prod in prefect-cloud, when it's working again, I want to save to GCS but locally on the laptop, I'm fine with local storage. It would seem I can't set
@task(result=...)
because I then have to specify the result type to be either local or GCS. How do you handle this?
a
@haf this would be one way to run this locally:
Copy code
from prefect import task, Flow
from prefect.engine.results import LocalResult, GCSResult
import sys


@task(log_stdout=True, checkpoint=True)
def hello_world():
    print("hello world")


with Flow("flow-with-varying-results") as flow:
    hw = hello_world()

if __name__ == "__main__":
    local_run = sys.argv[1].lower()
    if local_run == 'true':
        flow.result = LocalResult()
        flow.run()
    else:
        flow.result = GCSResult()
        flow.register(project_name="community")
🙌 1
h
😊 thank you that’s what I wanted to understand