Is there a way to reference a task output in a res...
# ask-community
d
Is there a way to reference a task output in a result
location
or task
target
? I know the Prefect context gives you a bunch of variables – notably including
parameters
, which looks promising! – but what if we have some data (the strings
"foo"
or
"bar"
) computed by some task
compute_foo_or_bar
and we’d like to reference that output in a subsequent task’s output target?
This might apply if, for example, you don’t know a `LocalResult`’s
dir
until you run some task
compute_local_result_dir
as
my_dir = compute_local_result_dir()
, where
my_dir
is one of
"foo"
,
"bar"
, or
"baz"
. In downstream tasks you’d want to use that
LocalResult(dir=my_dir)
, but you don’t know which one prior to running the task.
On further reflection, I think this would be a case where you’d need to go beyond the
@task
utility and start using class-based tasks? Otherwise you get into some really funky business with
@task
-decorated tasks yielding a parameterized
@task
.
k
You can template the target with inputs into the task. But you can also use callables here . You might need to create that location in another task though and pass it in as a variable input . You can then template with that variable input
You can template with task inputs like this
1