Created
June 5, 2023 22:25
-
-
Save naturalett/f344337924a86788a09a03e069dc71c1 to your computer and use it in GitHub Desktop.
Airflow running bash tasks on AWS Batch Operator
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
from datetime import datetime, timedelta | |
from airflow import DAG | |
from airflow.operators.bash import BashOperator | |
from airflow.providers.amazon.aws.operators.batch import AwsBatchOperator | |
NUM_TASKS = 500 | |
default_args = { | |
'owner': 'airflow', | |
'depends_on_past': False, | |
'email': ['admin@admin.com'], | |
'email_on_failure': True, | |
'email_on_retry': False, | |
'retries': 1, | |
'retry_delay': timedelta(minutes=5), | |
} | |
batch_params = ["date"] | |
with DAG( | |
'bash_tasks_batch', | |
default_args=default_args, | |
start_date=datetime(2021, 1, 1), | |
schedule_interval=None, | |
catchup=False | |
) as dag: | |
# for i in range(0, NUM_TASKS): | |
AwsBatchOperator( | |
job_name=f'bash_tasks_batch', | |
task_id=f'bash_tasks_batch', | |
array_properties={ "size": NUM_TASKS}, | |
job_definition='getting-started', | |
job_queue='getting-started', | |
overrides={'command': batch_params} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment