dinigo opened a new issue #8527:
URL: https://github.com/apache/airflow/issues/8527


   I generate some dags from json config file. It's a common use case arround. 
When I load this config file I have to write the whole path (seen in many blog 
posts and SO answers). If I try a relative path the expansion is made in 
relation to another path
   
   If in my `/opt/airflow/dags/mydags_reppo/mydag_file.py` I was to use:
   ```python
   config_path = os.path.abspath('config.json')
   with open(config_path,'r') as file:
     config = file.read()
   ```
   Airflow will throw the following error:
   ```
   No such file or directory '/opt/airflow/config.json'
   ```
   I could trick it using something like
   ```
   base_dags_path = os.getenv('AIRFLOW__CORE__DAGS_FOLDER', 
conf.get('core','dags_folder'))
   config_path = f'{base_dags_path}/mydags_repo/config.json'
   # read file from config_path
   ```
   But maybe there's an easier way, or maybe the way airflow expands the path 
can be changed


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to