|
| 1 | +# Copyright 2019 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# [START composer_quickstart] |
| 16 | +import datetime |
| 17 | + |
| 18 | +import airflow |
| 19 | +from airflow.operators import bash_operator |
| 20 | + |
| 21 | +YESTERDAY = datetime.datetime.now() - datetime.timedelta(days=1) |
| 22 | + |
| 23 | +default_args = { |
| 24 | + 'owner': 'Composer Example', |
| 25 | + 'depends_on_past': False, |
| 26 | + 'email': [''], |
| 27 | + 'email_on_failure': False, |
| 28 | + 'email_on_retry': False, |
| 29 | + 'retries': 1, |
| 30 | + 'retry_delay': datetime.timedelta(minutes=5), |
| 31 | + 'start_date': YESTERDAY, |
| 32 | +} |
| 33 | + |
| 34 | +with airflow.DAG( |
| 35 | + 'composer_sample_dag', |
| 36 | + 'catchup=False', |
| 37 | + default_args=default_args, |
| 38 | + schedule_interval=datetime.timedelta(days=1)) as dag: |
| 39 | + |
| 40 | + # Print the dag_run id from the Airflow logs |
| 41 | + print_dag_run_conf = bash_operator.BashOperator( |
| 42 | + task_id='print_dag_run_conf', bash_command='echo {{ dag_run.id }}') |
| 43 | +# [END composer_quickstart] |
0 commit comments