Hello all. I've run across an issue that I just ca...
# prefect-community
j
Hello all. I've run across an issue that I just can't seem to figure out and I feel like it's probably something really simple. I've structured my project like so.
Copy code
my_module/
  flows/
    my_flow.py
  tasks/
  lib/
     tasks/
       shared_task.py
So in
my_flow.py
I am importing from
my_module.lib.tasks.shared_task.py
where i've created a reusable Task class. But I am unable to register this flow using the prefect command
prefect register --project Test -m <http://my_module.flows.my|my_module.flows.my>_flow
I've tried many different combinations of the
prefect register
command and it just continues to generate a
ModuleNotFoundError: No module named my my_module
However, if I just use
flow.register()
inside of
my_flow.py
and execute it using
python my_module/flows/my_flow.py
it registers just fine.
k
This needs to be a pip installed module such that you can import it. For this structure, you need to add a
setup.py
in the root and then
pip install -e .
. I have an example of a basic
setup.py
here. You need the
___init___.py
files to be picked up though when you pip install
You can also just register with
prefect register --project Test --path my_module/flows/my_flow.py
and it might be easier
upvote 1
I also have this guide that covers how to make the Python module in the first half
j
I have tried using the --path argument with prefect register and it also generates the same ModuleNotFound error so that didnt help
But thank you for the article. I will read through it.
k
Ahh. The article has a link to a repo that will help visualize too.