feature request: support pyc files for flow deployments. #14437
Replies: 8 comments
-
serve deployment is fine, and the entry point is recognized normally as follows |
Beta Was this translation helpful? Give feedback.
-
Thanks for the issue @marchmelo0923. An MRE would help here, even if the ClassificationModelFlow code is just substituted for |
Beta Was this translation helpful? Give feedback.
-
I can't release the code, so it is just abbreviated. Structure itselt is the same as this. And then, all .py codes in my programs are compiled by It successfully open UI server and serve deployment. So, I think It should be work fine. |
Beta Was this translation helpful? Give feedback.
-
Can you invite me to Slack? Since I live in a place with a time difference of 13 hours with you, I don't think it's going to be easy to continue the story by asking on Github like this. |
Beta Was this translation helpful? Give feedback.
-
The reason it works when you do .serve is that you are passing the function directly to the serve call, which we can import from the pyc file. When we deploy, we dont actually run the imports, we parse the python code to determine the flow entrypoint. Because there is no python file, we're not able to determine that entrypoint and this will not work. We can change this issue to a feature request to support deploying from pyc files to continue to gather user input, but for the time being you'll want to use the py files directly in deployments. More information on the slack community here. |
Beta Was this translation helpful? Give feedback.
-
Um... There's nothing I can do then |
Beta Was this translation helpful? Give feedback.
-
Depending on your infrastructure setup, you could consider dockerizing your code and dependencies and running on a docker work pool or any of the other work pools that run containers (K8s, ECS, Cloud run, ACI). |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help..!! |
Beta Was this translation helpful? Give feedback.
-
First check
Bug summary
When Flow or Task function is inside .pyc (compiled module),
It fails on run deployment, while serve is success
Reproduction
Error
Versions (
prefect version
output)Additional context
I think it maybe importlib's problem, so I edit prefect code like this
to
In this case, it got error like this....
Traceback (most recent call last):
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\prefect\engine.py", line 422, in retrieve_flow_then_begin_flow_run
else await load_flow_from_flow_run(flow_run, client=client)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\prefect\client\utilities.py", line 100, in with_injected_client
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\prefect\deployments\deployments.py", line 317, in load_flow_from_flow_run
flow = await run_sync_in_worker_thread(load_flow_from_entrypoint, str(import_path))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\prefect\utilities\asyncutils.py", line 136, in run_sync_in_worker_thread
return await anyio.to_thread.run_sync(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code(Hide Addresses)\python-3.11.9-embed-amd64\Lib\site-packages\prefect\flows.py", line 1677, in load_flow_from_entrypoint
raise MissingFlowError(
prefect.exceptions.MissingFlowError: Flow function with name 'ClassificationModelFlow' not found in 'ml_pipeline\train_flow.pyc'.
Beta Was this translation helpful? Give feedback.
All reactions