Newskooler

    Newskooler

    1 year ago
    Hi đŸ‘‹ , I am running a very straight forward Flow and I got this error:
    ValueError: Could not infer an active Flow context.
    I find it quite cryptic. Can anyone please shed some light on what my issue may be? I have no clue right now : /
    nicholas

    nicholas

    1 year ago
    Hi @Newskooler - would you mind sharing some of your code?
    Newskooler

    Newskooler

    1 year ago
    Sure, I condensed it to the essential structure:
    @task
    def extract() -> list:
        return get_info()
    
    
    @task
    def transform(raw_data: list) -> pd.DataFrame:
        return transform(raw_data)
    
    
    @task
    def save(mapped_data: pd.DataFrame) -> None:
        x = list(set(mapped_data.columns) & set(['a', 'b', 'c']))
        y = list(set(mapped_data.columns) & set(['1', '2', '3']))
        save_data(
            dataframe=mapped_data,
            x_axis=x,
            y_axis=y,
        )
    
    
    with Flow(name='some name') as flow:
        raw_data = extract()
        mapped_data = transform(raw_data)
        save(mapped_data)
    
    flow.storage = Local(directory='/some/location')
    nicholas

    nicholas

    1 year ago
    What happens when you remove the
    save_data
    call?
    Newskooler

    Newskooler

    1 year ago
    1 moment…
    it does not fail
    nicholas

    nicholas

    1 year ago
    Ok good, that narrows it down. Something in your
    save_data
    method is trying to reference the flow context; is
    save_data
    a task?
    Newskooler

    Newskooler

    1 year ago
    Yes. I will look into the inputs there.
    Thanks!
    nicholas

    nicholas

    1 year ago
    If that's the case, try returning the inputs from
    save
    and passing those to an explicit task call of
    save_data
    in the
    with Flow() as flow:
    block đŸ™‚
    Newskooler

    Newskooler

    1 year ago
    ohh.. this may be it… It’s a
    task
    inside a
    task
    nicholas

    nicholas

    1 year ago
    Exactly!
    Newskooler

    Newskooler

    1 year ago
    Thanks : ))
    nicholas

    nicholas

    1 year ago
    đŸ˜„