Greg Roche

01/19/2021, 2:45 PM
Hi folks, does anyone have any experience with this error when running a
flow, using a LocalAgent running inside a Docker image?
TypeError: start() missing 1 required positional argument: 'self'
Edit: solved, I wasn't initialising the LocalDaskExecutor.
Copy code
flow.executor = LocalDaskExecutor  # wrong
flow.executor = LocalDaskExecutor()  # this works
Full stacktrace:
Copy code
[2021-01-19 11:30:59+0000] INFO - prefect.CloudFlowRunner | Beginning Flow run for 'hello-world'
[2021-01-19 11:30:59+0000] ERROR - prefect.CloudFlowRunner | Unexpected error: TypeError("start() missing 1 required positional argument: 'self'")
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/", line 418, in get_flow_run_state
    with self.check_for_cancellation(), executor.start():
  File "/usr/local/lib/python3.8/", line 240, in helper
    return _GeneratorContextManager(func, args, kwds)
  File "/usr/local/lib/python3.8/", line 83, in __init__
    self.gen = func(*args, **kwds)
TypeError: start() missing 1 required positional argument: 'self'
Here's an example flow:
Copy code
from prefect import Flow, task
from prefect.executors import LocalDaskExecutor
from import S3
from prefect.utilities.logging import get_logger

logger = get_logger()

def say_hello():
    <|>("Hello, world!")

with Flow("hello-world", storage=S3(bucket="my-s3-bucket")) as flow:
    hello = say_hello()

flow.register(project_name="test")  # flow runs successfully when triggered by Prefect Server

flow.executor = LocalDaskExecutor
flow.register(project_name="test")  # TypeError: start() missing 1 required positional argument: 'self'
I've tried stripping back the Dockerfile to just the essentials, here's a minimal setup which still causes the problem above:
Copy code
FROM prefecthq/prefect:latest-python3.8

WORKDIR /my_project
COPY ./my_project_etl ./my_project_etl
COPY requirements.txt .
COPY agents/ .
COPY agents/aws_config /root/.aws/config

# needed to build psycopg2
RUN apt-get update
RUN apt-get install -y libpq-dev

RUN pip install -e .

ENTRYPOINT ["/my_project/"] is just this:
Copy code
prefect backend server
prefect agent local start --show-flow-logs --api <> --label docker-test


01/19/2021, 2:56 PM
Not sure if this is related but you may need to initialize the LocalDaskExecutor:
Copy code
flow.executor = LocalDaskExecutor()

Greg Roche

01/19/2021, 3:00 PM
Yep looks like that was it, thanks very much for correcting my brain fart @josh 😄