我想更改特定气流DAG的dag_concurrency
参数。似乎在airflow.cfg
中有一个全局dag_concurrency
参数,但是是否可以为不同的dag设置不同的值?
我试图在DAG代码的SSHExecuteOperator
任务中添加一个并发参数,但是并发值仍然在DAG详细信息中显示标准参数(16)。
from airflow import DAG
from datetime import datetime, timedelta
from airflow.contrib.hooks.ssh_hook import SSHHook
from airflow.contrib.operators.ssh_execute_operator import SSHExecuteOperator
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime.now(),
'email': ['exceptions@airflow.com'],
'email_on_failure': True,
'retries': 0
}
#server must be changed to point to the correct environment
sshHookEtl = SSHHook(conn_id='SSH__airflow@myserver')
with DAG(
'ed_data_quality_20min-v1.6.6',
default_args=default_args,
schedule_interval="0,20,40 * * * *",
dagrun_timeout=timedelta(hours=24)) as dag:
(
dag
>> SSHExecuteOperator(
task_id='run_remote_ed_data_quality_20min',
bash_command='bash /opt/scripts/shell/EXEC_ED_DATA_QUALITY_20MIN.sh ',
ssh_hook=sshHookEtl,
retries=0,
concurrency=1,
dag=dag)
)
我找到了解决办法。我没有在正确的地方添加并发参数。它应该直接作为
DAG
对象的属性添加,而不是作为任务SSHExecuteOperator
的属性添加。以下是新代码:好吧… 您可以just set对象上的
concurrency
。 在BaseOperator
对象上还有一个task_concurrency
。在SSHExectorOperator
或BaseOperator
任务上没有concurrency
参数或字段。相关问题 更多 >
编程相关推荐