Is there a way for to override the `target` keywor...
# ask-community
a
Is there a way for to override the
target
keyword argument for all tasks at flow level? I have some tasks with
target
caching and for testing I would like all the result files to be created again without caching. If we can selectively decide which one to override for a particular run that would be even better
a
@An Hoang target is a file-based persistence, which means that as long as you remove those files (or when you move those files to a different directory), the caching will be effectively disabled without having to specify anything on a flow-level. You can also selectively decide which ones you remove - those that were removed from the target directory will be recreated at runtime and for those that still exist Prefect will use them as file-based “caching” without rerunning the task.
a
Thanks. I have been doing that while debugging and find having to delete selective files cumbersome. Is there a setting or "debug" mode at run level to disable some of those file-based persistence ?
It would be nice while debugging to be able to select which task to turn off persistence for. I always get confused when debugging due to persistence (forgetting to delete files lead to new task code mixed with old task results), but in production it needs the persistence. So I would like to be able to turn file-based persistence off for specific runs
I don't want to delete the entire result folder because there are tasks that are time consuming that I still want persistence for when debugging
k
I understand the sentiment, but I can’t quite envision what an elegant interface for this would be. You can currently turn off checkpointing completely, but you want to checkpoint some tasks. I think even if an interface was exposed you’d still have a bunch of configuration to do for task-specific checkpointing. I think for you specific use case you can do:
Copy code
@task(checkpoint=True, target="...")
def abc(x):
    return x+1

def make_flow():
    with Flow(...) as flow:
        return flow

if debug:
   abc.checkpoint=False
   abc.target=None
   flow = make_flow()
   flow.run()
else:
   flow = make_flow()
   flow.register(...)
👍 1