Created
October 5, 2023 17:45
-
-
Save Arqentum/3724d7d57ffdac8d254d38a2a09cc42b to your computer and use it in GitHub Desktop.
#Airflow custom dag execution schedule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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