Hi, is there a way to set one `Parameter` as the d...
# ask-community
a
Hi, is there a way to set one
Parameter
as the default for another? Here's what I did
Copy code
#task 
@task(target= {output_folder_path}/result)
def example_task(output_folder_path)
....

#in flow
step1_folder_path = Parameter("step1_folder_path")
output_folder_path = Parameter("output_folder_path", default = step1_folder_path)
When I do this, I got a warning
Copy code
<ipython-input-226-3b472991f1ef>:8: UserWarning: A Task was passed as an argument to Parameter, you likely want to first initialize Parameter with any static (non-Task) arguments, then call the initialized task with any dynamic (Task) arguments instead. For example:

  my_task = Parameter(...)  # static (non-Task) args go here
  res = my_task(...)  # dynamic (Task) args go here

see <https://docs.prefect.io/core/concepts/flows.html#apis> for more info.
  output_folder_path = Parameter("output_folder_path", default = step1_folder_path)
When I execute the flow, it runs but the
target
doesn't work as intended, the task still runs every time even though the target files are there. When I provide a hardcoded string to the default of
output_folder_path
, everything works fine
k
There is no way to do this because Parameters defaults are registered during build time, and the value doesn’t exist then yet. You need to set the default of
output_folder_path
to
None
make another task that checks for the
output_folder_path
to see if it’s
None
and then grab
step1_folder_path
.
👍 1