Slackbot
03/15/2024, 10:13 AMMarvin
03/15/2024, 10:13 AMModuleNotFoundError
if the worker's environment is set up differently from the main process or if there are path resolution issues.
Here are a few steps you might consider to troubleshoot this problem:
1. Verify the import path: Ensure that the worker's environment has access to the correct Python path when the worker subprocess starts. While you have verified that the path is added to sys.path
, it's essential to confirm that this happens before you attempt to import the module.
2. Examine subprocess environment: Check if the worker's Python subprocess is inheriting the main process's environment correctly, especially the Python path. It may require explicitly passing sys.path
or using environment variables to manage this.
3. Consider using absolute imports: If you're using relative imports, try switching to absolute imports for more predictable behavior across different environments.
4. Examine worker behavior: Refer to the Prefect documentation to understand how workers are initiated and how to customize worker behavior if necessary. (Refer to links here and here)
5. Check for known issues: Search for similar issues in the Prefect GitHub repository for any known problems or workarounds related to custom module loading with workers. An existing issue about ModuleNotFoundError
when running deployed flows using a custom image was found here, although not directly related to your case, it demonstrates that such issues can arise in specific configurations.
To further assist, you may want to provide a minimal reproduction of the issue and consider opening an issue on the Prefect GitHub repository if it seems like a bug or unhandled edge case with the worker setup.MarcoM
03/15/2024, 10:18 AMMarvin
03/15/2024, 10:18 AMthe error received is the following """Encountered exception during execution:Traceback (most recent call last): File "c:\prefect\venv\Lib\site-packages\prefect\engine.py", line 867, in orchestrate_flow_run result = await flow_call.aresult() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\prefect\venv\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 326, in aresult return await asyncio.wrap_future(self.future) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\prefect\venv\Lib\site-packages\prefect\_internal\concurrency\calls.py", line 351, in _run_sync result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\prefect\prefectflows\customers\wamapi\flows\wamapi_dailyfeeds_instrumentperimeter_dataquality.py", line 27, in wamapi_dailyfeeds_instrumentperimeter res = dataquality.execute() ^^^^^^^^^^^^^^^^^^^^^ File "C:\prefect\prefectflows\data_quality\dataquality.py", line 157, in execute checkpoint = self.get_checkpoint() ^^^^^^^^^^^^^^^^^^^^^ File "C:\prefect\prefectflows