I use PyCharm IDE to develop. After update prefect Python to 3.0.3, new type of error occurs.
Take this simple flow:
from prefect import flow, task
@task(name='dummy task')
def dummy_task():
return 'dummy task'
@flow
def dummy_flow():
dummy_task()
if __name__ == '__main__':
dummy_flow()
It works when I run it within the IDE. But when I run it with the debugger, I get the following exception:
/Users/andersohrn/PycharmProjects/pythondummyprefect/.venv/bin/python -X pycache_prefix=/Users/andersohrn/Library/Caches/JetBrains/PyCharm2024.2/cpython-cache /Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 58461 --file /Users/andersohrn/PycharmProjects/pythondummyprefect/test_prefect.py
Connected to pydev debugger (build 242.22855.92)
21:34:10.982 | INFO | prefect - Starting server on http://127.0.0.1:8064
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/Users/andersohrn/PycharmProjects/pythondummyprefect/.venv/lib/python3.11/site-packages/prefect/flow_engine.py", line 632, in start
with self.initialize_run():
File "/usr/local/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/Users/andersohrn/PycharmProjects/pythondummyprefect/.venv/lib/python3.11/site-packages/prefect/flow_engine.py", line 551, in initialize_run
with SyncClientContext.get_or_create() as client_ctx:
File "/usr/local/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/Users/andersohrn/PycharmProjects/pythondummyprefect/.venv/lib/python3.11/site-packages/prefect/context.py", line 230, in get_or_create
with SyncClientContext() as ctx:
^^^^^^^^^^^^^^^^^^^
File "/Users/andersohrn/PycharmProjects/pythondummyprefect/.venv/lib/python3.11/site-packages/prefect/context.py", line 203, in __init__
client=get_client(sync_client=True, httpx_settings=httpx_settings),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andersohrn/PycharmProjects/pythondummyprefect/.venv/lib/python3.11/site-packages/prefect/client/orchestration.py", line 219, in get_client
server.start()
File "/Users/andersohrn/PycharmProjects/pythondummyprefect/.venv/lib/python3.11/site-packages/prefect/server/api/server.py", line 818, in start
raise RuntimeError(error_message)
RuntimeError: Timed out while attempting to connect to ephemeral Prefect API server.
I included the debugger command at the top as well.
I’ve read issue 14878 and understand some default changes have been made that has made an ephemeral server appear. I have not mananged to fix my issue, though.
I am doing local development and like to keep the server as basic as possible, and I want to be able to do debugging in the IDE (usually to ensure the commands within tasks are working ok).
Is there a simple way to accomplish this at 3.0.3? Some environment variable maybe to set differently than current defaults to get back the behaviour prior to update?