'Prefect caching through a file target

After reading the documentation on Output Caching based on a file target , I figured this workflow should be an example of output caching:

from time import sleep
from prefect import Flow, task
from prefect.engine.results import LocalResult


@task(target="func_task_target.txt", checkpoint=True, 
      result=LocalResult(dir="~/.prefect"))
def func_task():
    sleep(5)
    return 99

with Flow("Test-cache") as flow:
    func_task()

if __name__ == '__main__':
    flow.run()

I would expect func_task to run one time, get cached, and then use the cached value next time I run the flow. However, it seems that func_task runs each time.

Where am I going wrong? Or have I misunderstood the documentation?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source