How to import external scripts in a Airflow DAG with Python?
I needed insert the following script inside at the top of ren.py
:
import sys, os
from airflow.models import Variable
DAGBAGS_DIR = Variable.get('DAGBAGS_DIR')
sys.path.append(DAGBAGS_DIR + '/bi/inbound_layer/')
This way I make available the current folder packages.
Apache Airflow DAG cannot import local module
Adding the sys path again worked for me,
import sys
sys.path.insert(0,os.path.abspath(os.path.dirname(__file__)))
Related Topics
Get Discord User Id from Username
Check If Value from One Dataframe Exists in Another Dataframe
Get the Row(S) Which Have the Max Value in Groups Using Groupby
How to Add List into a New Column in CSV - Python
Filter Df When Values Matches Part of a String in Pyspark
Using SQL Server Stored Procedures from Python (Pyodbc)
How to Pass Variables from Python Script to Bash Script
Python - Having Trouble Opening a File With Spaces
How to Put a Space Between Two String Items in Python
How to Divide Each Column of Pandas Dataframe by a Series
How to Check All Versions of Python Installed on Osx and Centos
Fast Way to Split Column into Multiple Rows in Pandas
How to Get Maximum Length of Each Column in the Data Frame Using Pandas Python
Find the Index of the First Digit in a String