Skip to content

Instantly share code, notes, and snippets.

@antweiss
Created April 27, 2023 19:22
Show Gist options
  • Save antweiss/60f08f6b16c27cf56bf198934afe5643 to your computer and use it in GitHub Desktop.
Save antweiss/60f08f6b16c27cf56bf198934afe5643 to your computer and use it in GitHub Desktop.
from airflow.operators.python_operator import ShortCircuitOperator
from airflow.operators.dummy_operator import DummyOperator
from airflow.models import DAG
import airflow.utils.helpers
from airflow.operators.bash_operator import BashOperator
import random
args = {
'owner': 'antweiss',
'start_date': airflow.utils.dates.days_ago(0)
}
dag = DAG(dag_id='weather_operator', default_args=args)
def randbool():
return bool(random.getrandbits(1))
continuer = ShortCircuitOperator(
task_id='cont', python_callable=randbool, dag=dag)
show_weather = BashOperator(
task_id='show_weather',
bash_command='curl wttr.in/israel',
dag=dag
)
continuer.set_downstream(show_weather)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment