Howdy, When using caching on a task. Is there a w...
# prefect-azure
b
Howdy, When using caching on a task. Is there a way to set the storage location to azure blob so that all workers can access it?
c
b
Thank you! I was not sure if results worked with cache. This is what I am trying to do but it continues to use the local storage. Any thoughts on why it would not work? I was looking at the docs but I am not seeing an example. Thanks for your help!
Copy code
from prefect.filesystems import Azure

def generate_task_name():
    flow_name = flow_run.flow_name
    task_name = task_run.task_name

    return f"{flow_name}::TASK::{task_name}"


def cache_with_storage(context, parameters):
    storage_block_value = context.result_factory.storage_block
    return f"{storage_block_value}-{task_input_hash(context, parameters)}"


@task(
    cache_key_fn=cache_with_storage,
    result_storage=Azure.load("prefect-cache"),
    cache_expiration=timedelta(days=7),
    log_prints=True,
    task_run_name=generate_task_name,
)
async def fetch_data() -> str:
c
I can check with the team - I don’t have an example myself immediately on hand , but it should be persist results=true and result storage location can be a loaded block id