Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefect ModuleNotFoundError when running from UI

Tags:

python

prefect

I'm following the Prefect tutorial available at: https://docs.prefect.io/core/tutorial/01-etl-before-prefect.html. The code can be downloaded from the git: https://github.com/PrefectHQ/prefect/tree/master/examples/tutorial

The tutorials have a dependency to aircraftlib which is a directory under tutorials. I can execute the Flows through the terminal with:

python 02_etl_...

and it executes perfectly!

I've created a project, and added the Flow to that project. Through the Prefect Server UI I can run the Flow, but it fails with the error message:

State Message: Failed to load and execute Flow's environment: ModuleNotFoundError("No module named 'aircraftlib'")

How should I handle the dependency when executing the Flows through the Prefect Server UI?

like image 479
Carl Rynegardh Avatar asked Sep 14 '20 09:09

Carl Rynegardh


1 Answers

This depends partially on the type of Flow Storage and Agent you are using. Since you are running with Prefect Server, I assume you are using Local Storage + a Local Agent; in this case, you need to make sure the aircraftlib directory is on your local importable Python PATH. There are a few ways of doing this:

  • run your Prefect Agent in the tutorial directory; your Local Agent's path will then be inherited by the flows it submits
  • manually add the tutorial/ directory to your global python path (I don't recommend this)
  • add the tutorial/ directory to your Agent's path with the -p CLI flag; for example: prefect agent start -p ~/Developer/prefect/examples/tutorial (this is the approach I recommend)
like image 175
chriswhite Avatar answered Oct 07 '22 10:10

chriswhite