Hi, I encounter an issue and I can't figure it out...
# ask-community
p
Hi, I encounter an issue and I can't figure it out what is wrong here in my deployment. MissingFlowError
Flow function with name 'get_data' not found in 'C:\\Users\\user\\AppData\\Local\\Temp\\tmpqxiu24xa\\myrepo-main\\src\\providers\\provider\\service.py'.
AttributeError: module '__prefect_loader_2609343467472__' has no attribute 'get_data'
Copy code
@flow
def get_data() -> None:
    task_to_get_data()

if __name__ == "__main__":
  get_data.from_source(
          source=GitRepository(
          url=repo_url,
          credentials=credentials_block,
          branch="main",
      ),
          entrypoint="src/providers/provider/service.py:get_data",
      ).deploy(
          name="get_data",
          work_pool_name="managed-pool",
          image="prefecthq/prefect:3-python3.11",
          build=None,
          push=None,
          cron="0 0 * * *",
      )
This is a deployment with a work pool from prefect cloud. Does anyone had the same or a simular issue? On prefect 3.1.12 python -c "from src.poviders.provider.service import main" yields no errors
n
Copy code
AttributeError: module '__prefect_loader_2609343467472__' has no attribute 'get_data'
this error is pretty strange to me are you trying to run this from a jupyter notebook or
ipython
session by chance? if not, can you share the whole stack trace?
p
No I run the python script from vscode via debug mode. Here is the full traceback when running the script without debug mode:
Traceback (most recent call last):
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\flows.py", line 1807, in load_flow_from_entrypoint
flow: Flow[P, Any] = import_object(entrypoint)  # pyright: ignore[reportRedeclaration]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\utilities\importtools.py", line 236, in import_object
return getattr(module, object_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module '__prefect_loader_2280946239728__' has no attribute 'main'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\\System\\bitbucket\\user\\myrepo\\src\\providers\\provider\\service.py", line 164, in <module>
deploy_flow(
File "D:\\System\\bitbucket\\user\\myrepo\\src\\providers\\provider\\service.py", line 87, in deploy_flow
flow.from_source(
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\utilities\asyncutils.py", line 353, in coroutine_wrapper
return run_coro_as_sync(ctx_call())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\utilities\asyncutils.py", line 209, in run_coro_as_sync
return call.result()
^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 330, in result
return self.future.result(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 193, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\concurrent\futures\_base.py", line 401, in __get_result
raise self._exception
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 403, in _run_async
result = await coro
^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\utilities\asyncutils.py", line 190, in coroutine_wrapper
return await task
^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\utilities\asyncutils.py", line 343, in ctx_call
result = await async_fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\flows.py", line 1064, in from_source
await from_async.wait_for_call_in_new_thread(
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\_internal\concurrency\api.py", line 160, in wait_for_call_in_new_thread
return call.result()
^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 330, in result
return self.future.result(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 184, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\concurrent\futures\_base.py", line 401, in __get_result
raise self._exception
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 364, in _run_sync
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\miniconda3\envs\py11\Lib\site-packages\prefect\flows.py", line 1809, in load_flow_from_entrypoint
raise MissingFlowError(
prefect.exceptions.MissingFlowError: Flow function with name 'main' not found in 'C:\\Users\\user\\AppData\\Local\\Temp\\tmp3_yfbxw4\\myrepo-main\\src\\providers\\provider\\service.py'.
n
hmm. does the same problem happen outside of debug mode? im suspicious that debug mode might create some ephemeral sandbox python context (not sure) where we don't have a "real" module to point at, since this is a placeholder module we use in certain interactive contexts
Copy code
__prefect_loader_{id}__
p
Yes the problem persists also outside of debug mode.
The weird thing is I have pretty much the same setup for another python file in the same directory as my initial deployment and it strangly had no issues and got deployed. But for any other python file I tried I get this error.
I have created an issue in github: https://github.com/PrefectHQ/prefect/issues/16887