PrefectHQ / ControlFlow

🦾 Take control of your AI agents
https://controlflow.ai
Apache License 2.0
337 stars 15 forks source link

Trying to get quickstart example working #182

Closed chrisgoddard closed 1 week ago

chrisgoddard commented 1 week ago

Trying the agent example from the getting started.

Firstly - you don't actually mention configuring Prefect (i.e. starting Prefect server) - that might trip some folks up if they're coming to this for the first time.

Secondly, I'm getting the following error when I run the example:

(prefect-test) chrisgoddard@Good-Studio ~/C/g/p/prefect-test (main) [1]> python src/prefect_test/test2.py                                                                   (base) 
14:04:37.302 | ERROR   | Flow run 'lemon-narwhal' - Encountered exception during execution: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 571, in run_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 662, in run_generator_flow_sync
    yield gen_result
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/flows/flow.py", line 95, in create_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/controllers/controller.py", line 340, in run
    messages.extend(new_messages)
TypeError: 'NoneType' object is not iterable
14:04:37.338 | ERROR   | Flow run 'lemon-narwhal' - Finished in state Failed("Flow run encountered an exception: TypeError: 'NoneType' object is not iterable")
14:04:37.339 | ERROR   | Task run 'Run LLM Controller' - Task run failed with exception TypeError("'NoneType' object is not iterable") - Retries are exhausted
14:04:37.355 | ERROR   | Task run 'Run LLM Controller' - Finished in state Failed("Task run encountered an exception TypeError: 'NoneType' object is not iterable")
14:04:37.356 | ERROR   | Task run 'Run Task 83ae0 ("Review the edited paragraph to see if it meets the...")' - Task run failed with exception TypeError("'NoneType' object is not iterable") - Retries are exhausted
14:04:37.371 | ERROR   | Task run 'Run Task 83ae0 ("Review the edited paragraph to see if it meets the...")' - Finished in state Failed("Task run encountered an exception TypeError: 'NoneType' object is not iterable")
14:04:37.372 | ERROR   | Flow run 'zealous-quokka' - Encountered exception during execution: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 571, in run_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 612, in run_flow_sync
    engine.call_flow_fn()
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 591, in call_flow_fn
    result = call_with_parameters(self.flow.fn, self.parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/decorators.py", line 110, in wrapper
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/src/prefect_test/test2.py", line 50, in writing_flow
    approved = approval_task.run()
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/tasks.py", line 826, in __call__
    return run_task(
           ^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 862, in run_task
    return run_task_sync(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 675, in run_task_sync
    return engine.state if return_type == "state" else engine.result()
                                                       ^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 307, in result
    _result = self.state.result(raise_on_failure=raise_on_failure, fetch=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/client/schemas/objects.py", line 262, in result
    return get_state_result(
           ^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 68, in get_state_result
    return _get_state_result(
           ^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 389, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 248, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/.rye/py/cpython@3.12.3/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 231, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 379, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 127, in _get_state_result
    raise await get_state_exception(state)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 619, in run_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 673, in run_task_sync
    engine.call_task_fn(txn)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 647, in call_task_fn
    result = call_with_parameters(self.task.fn, parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/tasks/task.py", line 354, in run
    controller.run()
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/tasks.py", line 826, in __call__
    return run_task(
           ^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 862, in run_task
    return run_task_sync(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 675, in run_task_sync
    return engine.state if return_type == "state" else engine.result()
                                                       ^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 307, in result
    _result = self.state.result(raise_on_failure=raise_on_failure, fetch=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/client/schemas/objects.py", line 262, in result
    return get_state_result(
           ^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 68, in get_state_result
    return _get_state_result(
           ^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 389, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 248, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/.rye/py/cpython@3.12.3/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 231, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 379, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 127, in _get_state_result
    raise await get_state_exception(state)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 619, in run_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 673, in run_task_sync
    engine.call_task_fn(txn)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 647, in call_task_fn
    result = call_with_parameters(self.task.fn, parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/controllers/controller.py", line 340, in run
    messages.extend(new_messages)
TypeError: 'NoneType' object is not iterable
14:04:37.394 | ERROR   | Flow run 'zealous-quokka' - Finished in state Failed("Flow run encountered an exception: TypeError: 'NoneType' object is not iterable")
Traceback (most recent call last):
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/src/prefect_test/test2.py", line 55, in <module>
    approved, draft = writing_flow()
                      ^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flows.py", line 1286, in __call__
    return run_flow(
           ^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 734, in run_flow
    return run_flow_sync(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 614, in run_flow_sync
    return engine.state if return_type == "state" else engine.result()
                                                       ^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 211, in result
    _result = self.state.result(raise_on_failure=raise_on_failure, fetch=True)  # type: ignore
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/client/schemas/objects.py", line 262, in result
    return get_state_result(
           ^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 68, in get_state_result
    return _get_state_result(
           ^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 389, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 248, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/.rye/py/cpython@3.12.3/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 231, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 379, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 127, in _get_state_result
    raise await get_state_exception(state)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 571, in run_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 612, in run_flow_sync
    engine.call_flow_fn()
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 591, in call_flow_fn
    result = call_with_parameters(self.flow.fn, self.parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/decorators.py", line 110, in wrapper
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/src/prefect_test/test2.py", line 50, in writing_flow
    approved = approval_task.run()
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/tasks.py", line 826, in __call__
    return run_task(
           ^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 862, in run_task
    return run_task_sync(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 675, in run_task_sync
    return engine.state if return_type == "state" else engine.result()
                                                       ^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 307, in result
    _result = self.state.result(raise_on_failure=raise_on_failure, fetch=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/client/schemas/objects.py", line 262, in result
    return get_state_result(
           ^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 68, in get_state_result
    return _get_state_result(
           ^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 389, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 248, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/.rye/py/cpython@3.12.3/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 231, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 379, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 127, in _get_state_result
    raise await get_state_exception(state)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 619, in run_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 673, in run_task_sync
    engine.call_task_fn(txn)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 647, in call_task_fn
    result = call_with_parameters(self.task.fn, parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/tasks/task.py", line 354, in run
    controller.run()
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/tasks.py", line 826, in __call__
    return run_task(
           ^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 862, in run_task
    return run_task_sync(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 675, in run_task_sync
    return engine.state if return_type == "state" else engine.result()
                                                       ^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 307, in result
    _result = self.state.result(raise_on_failure=raise_on_failure, fetch=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/client/schemas/objects.py", line 262, in result
    return get_state_result(
           ^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 68, in get_state_result
    return _get_state_result(
           ^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 389, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 248, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/.rye/py/cpython@3.12.3/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 231, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 379, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/states.py", line 127, in _get_state_result
    raise await get_state_exception(state)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 619, in run_context
    yield self
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 673, in run_task_sync
    engine.call_task_fn(txn)
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/task_engine.py", line 647, in call_task_fn
    result = call_with_parameters(self.task.fn, parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/chrisgoddard/Code/goodkiwi/projects/prefect-test/.venv/lib/python3.12/site-packages/controlflow/controllers/controller.py", line 340, in run
    messages.extend(new_messages)
TypeError: 'NoneType' object is not iterable

I have my OpenAPI key set.

What am I missing?

aaazzam commented 1 week ago

Hey @chrisgoddard! Thanks for reporting this. I just did a fresh env on my machine and couldn't reproduce. But no worries, I'm on the case. Can you pip freeze? I have some suspicion that the --pre flag wasn't turned on (that's our fault for omitting in our quickstart if the case) and you might be on an old version of CF.

aaazzam commented 1 week ago

Sorry, to be more specific, can you share the version of controlflow in your environment?

jlowin commented 1 week ago

Hey @chrisgoddard! Thanks for sharing. I see how you hit that code path, and added a guard. It's a weird situation the orchestrator didn't expect -- your workflow must contain tasks in an incomplete state, but the orchestrator believes none are "ready" to run (meaning they have incomplete upstream dependencies) -- is it possible you have a cyclical workflow? We don't explicitly raise errors in that case. #183 should fix the actual error, though.

For Prefect -- it should run happily in its ephemeral mode with zero config, though if you have an existing Prefect environment maybe it tried to talk to your existing server API URL? I'll look at exposing a separate config for CF's Prefect instance to avoid any unwanted cross talk

jlowin commented 1 week ago

0.8.1 is released and includes this fix! we'll work on making the Prefect settings more isolated as well.

chrisgoddard commented 1 week ago

Yeah I think you're right - I had an old Prefect config from a while back.

Thanks for quick turnaround!