Import modules from Airflow

Question:

Need help importing modules from dags.
I have a dag, next to which in the same folder is my python script.
For some reason airflow does not see this file and it shows import error.

enter image description here

Below you can see that status_dict.by is next to my dag.

enter image description here

I partially solved the problem by creating a commons package and importing my python scripts.
To create a common I use the following code:

from setuptools import setup, find_packages

setup(name='commons', version='0.0.6', author='Alexander Brezhnev', author_email='[email protected]',
      packages=find_packages())

Can someone tell me how to use scripts in the dag that are in the same folder with the current dag?

I’m trying to import a python script from a dag, but I’m getting an import error.

That helped:
enter image description here

Asked By: Ragnarok-039

||

Answers:

Did you try to add __init__.py file in your SQL folder? I remember that I faced a similar error a few years ago with an Airflow docker image and managed to fix it that way.

Answered By: strider
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.