One more question around checkpointing: ```target ...
# prefect-community
j
One more question around checkpointing:
Copy code
target (str, optional): location to check for task Result. If a result
            exists at that location then the task run will enter a cached state.
            `target` strings can be templated formatting strings which will be
            formatted at runtime with values from `prefect.context`
If I have a mapped task, and I want it to create separate outputs per map, I see
map_index
in
prefect.context
, but that relies on my arguments being in the same order each time, correct? Is there a way to pass Parameter values into this
target
or the result's location kwarg such that when I look at the directory containing my checkpoint files, I quickly know which ones have completed?
z
Hi @jorwoods! We recommend using
map_index
, but you're correct-- that does rely on order being the same. We have a PR underway that I think will help you address this exact issue, though! It'll allow folks to specify based on task inputs and flow parameters. Here's the link if you're curious: https://github.com/PrefectHQ/prefect/pull/2698
j
That does indeed cover exactly what I had in mind. Thanks @Zachary Hughes!
🎉 1
m
@Zachary Hughes - this a very welcomed PR - I am still trying to understand the difference between
Result.location
vs
target
and how caching works - this PR seems to allow much more flexible templating for
Result.location
- but what about target ?
i.e. the PR allows for passing flow parameters, task inputs and context to generate a richer
Result.location
template but it doesn’t seem to extend target’s templating - or am I missing something here ?
z
Hi Marwan! I'd say a good rule of thumb for the difference is that a location specifies where a result is stored, while a target is used to check whether a result exists at a given location. This PR does appear to be oriented to location specifically. If there's an additional enhancement you'd like, I'd encourage you to chime in on Github (or take a stab at it yourself 😉 )!
m
Hi @Zachary Hughes thanks for the response. I know every Result object has an exists method - so I’m not sure why that’s not used in place of target ? sure I will try to frame my question on github and take a closer look on implementation details