https://prefect.io logo
Title
f

Fred Israel

01/30/2020, 6:53 PM
I have created a simple flow to train a ML model. The problem is on line
train_model(model, train_preprocessed, train.category_id)
I get an error that the task
train
has no attribute
category_id
I understand that the task is not the actual data being returned by the task, but a task object. However, how can I access such data's attributes? I have used the [''] notation to handle multiple returns at runtime, but this time I would like to get a specific attribute instead of a dict's item
c

Chris White

01/30/2020, 7:05 PM
Hi @Fred Israel - whenever you call a task with another task as the argument, that specifies a data dependency in Prefect; so in this case, running
train_model(model, train_preprocessed, train)
will pass whatever data is returned from all three tasks
model
,
train_preprocessed
and
train
as arguments into the
train_model
task’s run method. So, within
train_model
you can access
train.category_id
at runtime