-
I'm trying to do a very simple thing, but I'm a bit stucked with it. Probably I'm misunderstanding something. I have a simple Python file defining and registering a flow, and I want to import a function from another file # project/task.py
import prefect
from prefect import Flow, task
from utils import do_something
@task
def test_task():
logger = prefect.context.get("logger")
result = do_something()
logger.info(f"Result: {result}")
with Flow("test-task") as flow:
test_task()
flow.register(project_name="testing") # project/utils.py
def do_something():
return 2+2 Then I execute the following command to register the flow: python task.py This kind of import would normally work executing a Python script, but when running the flow with prefect, I get the following error:
How can I fix this? As this looks very basic stuff, I would be happy if you just send me a link to the documentation or to another related issue where I can find more information about my issue, I did search in the docs and in Github, but I didn't find anything. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Just after sending this question I found the solution to my problem. I was executing the agent in the
Also I think it could be a good practice to create a Sorry for opening this discussion, I will mark it as answered; but feel free to correct me if I said something wrong. |
Beta Was this translation helpful? Give feedback.
Just after sending this question I found the solution to my problem.
I was executing the agent in the
$HOME
directory instead of the project folder. So I found two possible options:--import-path /path/to/project
flag to the agent command.Also I think it could be a good practice to create a
setup.py
file and install my own project, but I didn't try that yet.Sorry for opening this discussion, I will mark it as answered; but feel free to correct me if I said something wrong.