I'm getting an error with the following flow: `Val...
# ask-community
p
I'm getting an error with the following flow:
ValueError: Could not infer an active Flow context.
Details in thread
Copy code
with Flow("Batch update airtable flow") as f:

    proj, stry = get_selected_bases()
    cmdf = get_communities_2017()

    scrubbed_proj, scrubbed_stry = scrub_dataframes(proj, stry, cmdf)

    debug_task(scrubbed_proj, scrubbed_stry)
Copy code
[2021-02-25 12:44:28-0500] INFO - prefect.FlowRunner | Beginning Flow run for 'Batch update airtable flow'
[2021-02-25 12:44:28-0500] INFO - prefect.TaskRunner | Task 'Get selected bases': Starting task run...
[2021-02-25 12:44:35-0500] INFO - prefect.TaskRunner | Task 'Get selected bases': Finished task run for task with final state: 'Success'
[2021-02-25 12:44:35-0500] INFO - prefect.TaskRunner | Task 'GetItem': Starting task run...
[2021-02-25 12:44:35-0500] INFO - prefect.TaskRunner | Task 'GetItem': Finished task run for task with final state: 'Success'
[2021-02-25 12:44:35-0500] INFO - prefect.TaskRunner | Task 'Get Communities_2017 from DB': Starting task run...
[2021-02-25 12:44:36-0500] INFO - prefect.TaskRunner | Task 'Get Communities_2017 from DB': Finished task run for task with final state: 'Success'
[2021-02-25 12:44:36-0500] INFO - prefect.TaskRunner | Task 'GetItem': Starting task run...
[2021-02-25 12:44:36-0500] INFO - prefect.TaskRunner | Task 'GetItem': Finished task run for task with final state: 'Success'
[2021-02-25 12:44:36-0500] INFO - prefect.TaskRunner | Task 'Scrub dataframes': Starting task run...
[2021-02-25 12:44:36-0500] ERROR - prefect.TaskRunner | Unexpected error: ValueError('Could not infer an active Flow context.')
It is failing on
scrubbed_proj, scrubbed_stry = scrub_dataframes(proj, stry, cmdf)
This is
scrub_dataframes
Copy code
@task(name="Scrub dataframes", nout=2)
def scrub_dataframes(proj, stry, cmdf):
    scrubbed_proj = scrub_proj(cmdf, proj)
    scrubbed_stry = scrub_stry(stry)

    return scrubbed_proj, scrubbed_stry
Both of the scrub functions are just dataframe transformations
*digging in a little further to see if this is an issue with a function breaking on our code
Awesome - this is our issue. I now know that I'll get a
ValueError('Could not infer an active Flow context.')
if the functions themselves are broken