Hey guys, I think I’m going insane. I’m trying to...
# prefect-community
a
Hey guys, I think I’m going insane. I’m trying to set up a little introduction flow (code at the bottom), and I keep getting an error when trying to run this of:
AttributeError: Context object has no attribute dict
. Can anyone spot something wrong with the flow (like structurally or conceptually)?
Copy code
from prefect import Flow, task
from prefect.environments.storage import Local

@task
def extract():
    return [1, 2, 3]


@task
def always_process_and_pass_downstream(element: int) -> int:
    return element * 2


@task
def load(elements: List[int]) -> None:
    total = sum(elements)


@task
def process_and_finish(element: int) -> None:
    avg = sum(element) / len(element)
    pass


with Flow("test client register flow 1", storage=Local()) as flow:
    extracted = extract()
    processed = always_process_and_pass_downstream(element=extracted, mapped=True)
    process_and_finish(element=processed)
    load(elements=processed)

result = flow.run()
Thanks!
👀 2
c
Hi @Alex Cano! let me try and recreate
Hmmm this actually ran fine for me
what version of Prefect are you running?
a
Version 0.8.1… let me kill off my python processes and try some more. I originally tried to execute this flow within a test, so maybe that had something to do with it for some reason?
c
Hmmm maybe but I honestly don’t see how
a
I dropped a breakpoint at the bottom of the
prefect.utilities.context
file and tried to execute that file to see what the context object looks like, and I think the error is not prefect related. I’m getting a
ImportError: cannot import name 'namedtuple' from 'collections'
, which screams I screwed this up somehow haha
c
oooo haha yea it sounds like maybe your environment has some crossed wires
a
Yep seems like it. It looks like its trying to import
namedtuple
from
prefect.utilities.collections
instead of just
collections
. Oh the joys of python’s import system
😂 2