Hi guys, I have a question about organizing my pre...
# ask-community
i
Hi guys, I have a question about organizing my prefect tasks. I have two python files. One of them is "main.py" where I defined the flow and a few tasks, and the second one is called "mytasks.py" in which I defined just one task. They're both located on my gitlab repository and at the same root level. I imported task from mytasks.py in my "main.py" file. However, when I try to run that flow on Docker agent, it gives me an error saying that there is no module called "mytasks" . Can you help me with this?
g
The agent needs to be able to execute the
from mytasks import foo
commands that are at the top of the flow. Usually this means installing your code locally as an editable package with
pip install -e .
. https://prefect-community.slack.com/archives/CL09KU1K7/p1628583203100000 for more info and examples.
i
"Usually this means installing your code locally as an editable package with
pip install -e .
"<- Does it mean that I have to write Dockerfile and add this command ?
g
That's what we do yeah (we run a standard agent not a docker one though)
i
Yeah, I started local agent and everything worked. But when I specify GitLab storage, I get this error
Failed to load and execute Flow's environment: ImportError('Unable to import gitlab, please ensure you have installed the gitlab extra',)
g
Have you run (or added to your Dockerfile) this?
Copy code
pip install "prefect[gitlab]"
i
Yes, I did. It works fine when I don't use Gitlab
Maybe I missed something.
Requirement already satisfied: prefect[gitlab]
<- This is the output of pip install "prefect[gitlab]". However, when using local agent with tasks stored in Gitlab, my flow fails with the error above.
s
If you use Gitlab storage only the target flow file is checked out, not the entire repository, so you won't be able to import tasks. If you need additional files use the Git storage mechanism (which checks the entire repo out) or build your flows using Docker storage.
k
You might be starting the agent with a different Python environment than the one that contains Gitlab?
i
Thank you guys! It worked with Git storage.