Mourad Hamou-Mamar
10/18/2021, 8:27 AMparent_path = Path(__file__).resolve().parent
sys.path.append(os.path.relpath(parent_path))
My structure looks like this :
.
├── flow.py
├── functions
│ ├── function_mapping
│ │ ├── function_a.py
│ │ └── function_b.py
│ └── function_transform
│ ├── function_c.py
│ └── function_d.py
└── task
├── mapping
│ └── task_a.py
└── transform
├── task_b.py
└── task_c.py
In my flow.py, I import my task doing :
# in flow.py
from task.mapping.task_a import task_a
And it works for the task
module. But in my task when I try to use my functions, it doesnt find them :
# in task_a.py
from functions.function_mapping.function_a import function_a
I always get the error message : ModuleNotFoundError: No module named 'functions'
I don't get why it wouldnt find my functions
module since I make the import from the root directory and this last one is added to sys.path.
If anyone have any idea about how I could make it work or what should I try to debug this situation, it would be greatly appreciated.
Thanks everyone in advance.Anna Geller
@task
def pull_your_repo(repo_url:str):
pygit2.clone_repository(url=repo_url, path="your_module")
@task
def use_cloned_module():
import <http://your_module.XYZ|your_module.XYZ>
pass # your code using the module
#1 would be the recommended approach.Anna Geller
import sys
print(sys.path)
Mourad Hamou-Mamar
10/18/2021, 9:01 AMAnna Geller
prefect agent local start -p /Your/path/to/extra/module
Anna Geller
flow.run_config = LocalRun(working_dir="/path/to/working-directory")
Mourad Hamou-Mamar
10/18/2021, 9:41 AMAnna Geller
Mourad Hamou-Mamar
10/18/2021, 11:48 AMMourad Hamou-Mamar
10/18/2021, 11:53 AMAnna Geller
Anna Geller
Mourad Hamou-Mamar
10/18/2021, 2:24 PMMourad Hamou-Mamar
10/18/2021, 2:25 PMAnna Geller
Kevin Kho