Created
May 2, 2019 09:03
-
-
Save vastus/61a6dfd2a335d2dcf8e5e5cecbafdd27 to your computer and use it in GitHub Desktop.
Airflow cluster policy
This file contains 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
"""Local Airflow settings (policy)""" | |
from datetime import timedelta | |
from airflow.models import TaskInstance | |
DEFAULT_EXECUTION_TIMEOUT = timedelta(hours=48) | |
def policy(task: TaskInstance) -> None: | |
"""Alter tasks before they get run. | |
:param task: task instance that will be executed | |
""" | |
print("cluster policy got task", task) # debug | |
if hasattr(task, "execution_timeout") and not task.execution_timeout: | |
print("Setting execution timeout on task '{} ({})' to '{}'.".format( | |
task.task_id, | |
task.task_type, | |
DEFAULT_EXECUTION_TIMEOUT | |
)) | |
task.execution_timeout = DEFAULT_EXECUTION_TIMEOUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment