Skip to content

Instantly share code, notes, and snippets.

@Arqentum
Created October 5, 2023 17:45
Show Gist options
  • Select an option

  • Save Arqentum/3724d7d57ffdac8d254d38a2a09cc42b to your computer and use it in GitHub Desktop.

Select an option

Save Arqentum/3724d7d57ffdac8d254d38a2a09cc42b to your computer and use it in GitHub Desktop.
#Airflow custom dag execution schedule
def _skipcondition(execution_date, **_):
first_valid_friday = datetime(2021, 4, 9)
return (execution_date - first_valid_friday).days % 14 == 0
with DAG(dag_id='fortnightSchedule',default_args = default_args, schedule_interval = "0 17 * * 5", catchup=False) as dag:
check_valid_friday = ShortCircuitOperator(
task_id="check_if_correct_friday",
python_callable=_skipcondition,
provide_context=True,
)
rest_of_tasks = DummyOperator(
task_id="dependent_dummy",
)
check_valid_friday >> rest_of_tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment