Thread
#prefect-community
    a

    Akshay Verma

    3 years ago
    I am getting
    'FunctionTask' object is not iterable
    error. Can anyone point me out, what it is?
    Jeremiah

    Jeremiah

    3 years ago
    Hi @Akshay Verma, it sounds like you are trying to iterate over a task (or possibly the result of calling a task, which is also a task). Hard to say without more code - can you provide an example?
    a

    Akshay Verma

    3 years ago
    i am doing the following:
    @task
    def generate_context_level_data(mlsi, lvnr, tol):
        ml, ci = td_split_clv(mlsi, lvnr, tol)
        return ml, ci
    
    td_input = {'a': 1, 'b': 2, 'c': 3}
    with Flow('TD') as flow:
        td_input = Parameter("td_input")
        context_level_ml, context_level_ci = generate_context_level_data(td_input['a'],
                                                     td_input['b'],
                                                     td_input['c'])
    Jeremiah

    Jeremiah

    3 years ago
    Ah ok, it’s because you are assigning the result of
    generate_context_level_data
    to two variables (
    context_level_ml
    and
    context_level_ci
    ), but Prefect doesn’t know what the result of
    generate_context_level_data
    is, so Python can’t do that unpacking.
    Try this instead:
    context_result = generate_context_level_data(...)
    context_level_ml = context_result[0]
    context_level_ci = context_result[1]
    Python will let us index an unknown object like
    context_result
    , but not unpack it.
    (Note, I can’t promise this will work exactly as written because it depends on what is actually coming out of
    generate_context_level_data
    but this pattern should work — return a single object from your task, then index it appropriately)
    a

    Akshay Verma

    3 years ago
    ahhh, will try that thanks
    Jeremiah

    Jeremiah

    3 years ago
    @Marvin archive “Error unpacking task: 'FunctionTask' object is not iterable
    @Chris White some help 😉
    a

    Akshay Verma

    3 years ago
    @Jeremiah thanks, that helps! Then I have to make sure what get passed around between
    task
    .
    Chris White

    Chris White

    3 years ago
    @Marvin archive “Error unpacking task: 'FunctionTask' object is not iterable
    Marvin

    Marvin

    3 years ago