alexandre kempf
01/07/2020, 1:39 PMfrom prefect import task, Parameter, Flow
@task
def load_data(c, b):
return c
@task
def bugtask(c):
return c
with Flow("training") as flowModel:
init = Parameter("c")
data = load_data(init, b= {"f": 4})
# data = load_data(init, b= {"f": bugtask})
state_model = flowModel.run(c=5)
Now if you just use the comment instead of load_data
(basically, if you have a task in your arguments, even nested in other structured and not executed, there is an error.
It this expected ?
I have the feeling that it tries to run all the tasks, even if they are not called !
@josh @Dylan, This is a problem for subflows since I must give the configuration of the subflow as an argument of my run_flow task :sJeremiah
01/07/2020, 2:22 PM[2020-01-07 14:21:20,207] INFO - prefect.FlowRunner | Beginning Flow run for 'training'
[2020-01-07 14:21:20,211] INFO - prefect.FlowRunner | Starting flow run.
[2020-01-07 14:21:20,224] INFO - prefect.TaskRunner | Task 'c': Starting task run...
[2020-01-07 14:21:20,226] INFO - prefect.TaskRunner | Task 'c': finished task run for task with final state: 'Success'
[2020-01-07 14:21:20,230] INFO - prefect.TaskRunner | Task 'load_data': Starting task run...
[2020-01-07 14:21:20,232] INFO - prefect.TaskRunner | Task 'load_data': finished task run for task with final state: 'Success'
[2020-01-07 14:21:20,233] INFO - prefect.FlowRunner | Flow run SUCCESS: all reference tasks succeeded
alexandre kempf
01/07/2020, 2:29 PMJeremiah
01/07/2020, 3:51 PMflowModel.visualize()
you’ll see this:bugtask
in a Constant
like this:from prefect import task, Parameter, Flow
from prefect.tasks.core.constants import Constant
@task
def load_data(c, b):
return c
@task
def bugtask(c):
return c
with Flow("training") as flowModel:
init = Parameter("c")
# data = load_data(init, b= {"f": 4})
data = load_data(init, b= {"f": Constant(bugtask)})
state_model = flowModel.run(c=5)
alexandre kempf
01/07/2020, 4:18 PMJeremiah
01/07/2020, 4:18 PMTask
objectalexandre kempf
01/07/2020, 4:18 PMJeremiah
01/07/2020, 4:19 PMload_data
that calls (for example) b['f'].run(c=c)
it should workalexandre kempf
01/07/2020, 4:22 PMJeremiah
01/07/2020, 4:22 PM