Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function
- from airflow.operators.python_operator import PythonOperator
- from airflow.models import DAG
- from datetime import datetime, timedelta
- from pprint import pprint
- seven_days_ago = datetime.combine(datetime.today() - timedelta(7),
- datetime.min.time())
- args = {
- 'owner': 'airflow',
- 'start_date': seven_days_ago,
- }
- dag = DAG(dag_id='python_test', default_args=args)
- def print_context(ds, **kwargs):
- pprint(kwargs)
- print(ds)
- return 'Whatever you return gets printed in the logs'
- run_this = PythonOperator(
- task_id='print',
- provide_context=True,
- python_callable=print_context,
- dag=dag)
- run_this = PythonOperator(
- task_id='print',
- provide_context=True,
- python_callable=simple_test.print_context,
- dag=dag)
- my_dag1.py
- my_dag2.py
- package1/__init__.py
- package1/functions.py
- └── airflow/dags # root airflow dags folder where all dags live
- └── my_dags # git repo project root
- ├── my_dags # python src root (usually named same as project)
- │ ├── my_test_globals.py # file I want to import
- │ ├── dag_in_package.py
- │ └── dags
- │ └── dag_in_subpackage.py
- ├── README.md # also setup.py, LICENSE, etc here
- └── dag_in_project_root.py
- from my_dags.my_dags import my_test_globals
- └── airflow/dags # root airflow dags folder where all dags live
- └── my_dags # git repo project root & python src root
- ├── my_test_globals.py # file I want to import
- ├── dag_in_package.py
- ├── dags
- │ └── dag_in_subpackage.py
- ├── README.md # also setup.py, LICENSE, etc here
- └── dag_in_project_root.py
- from my_dags import my_test_globals
Add Comment
Please, Sign In to add comment