Python 气流中的辅助功能

Python 气流中的辅助功能,python,airflow,apache-airflow,Python,Airflow,Apache Airflow,气流中的辅助功能应放置在何处?是否应将其添加到插件目录中?我将为我的ETL工作提供一些可重复的代码,如下所示: #create a sub dag containing DROP -> CREATE -> INSERT sub_create_dag = DAG('%s.%s' % (parent_dag_name, child_dag_name), default_args=args) pg_drop = DropPostgresOperator(task_id='drop_{}'

气流中的辅助功能应放置在何处?是否应将其添加到插件目录中?我将为我的ETL工作提供一些可重复的代码,如下所示:

#create a sub dag containing DROP -> CREATE -> INSERT 
sub_create_dag = DAG('%s.%s' % (parent_dag_name, child_dag_name), default_args=args)
pg_drop = DropPostgresOperator(task_id='drop_{}'.format(table), sql="", params={'schema': schema, 'table': table}, postgres_conn_id=args['connection_id'], autocommit=True, dag=sub_create_dag)
pg_create = PostgresOperator(task_id='create_{}'.format(table), sql='{sql_path}/create_{name}.sql'.format(sql_path=sql_path, name=table), postgres_conn_id=args['connection_id'], autocommit=True, dag=sub_create_dag)
pg_insert = PostgresOperator(task_id='insert_{}'.format(table), sql='{sql_path}/insert_{name}.sql'.format(sql_path=sql_path, name=table), postgres_conn_id=args['connection_id'], autocommit=True, dag=sub_create_dag)
pg_drop >> pg_create >> pg_insert
return dag
问题是我会出现如下错误:

File "/usr/local/lib/python2.7/dist-packages/jinja2/loaders.py", line 187, in get_source   
raise TemplateNotFound(template)

我们将两者结合使用。我们已经在plugin文件夹中实现了作为自定义操作符的独立任务,而在DAG文件夹中实现了作为python函数的小函数。 关于错误,这是因为jinja找不到templates文件夹。如果在DAG或plugins文件夹中实现helper函数,则不会出现此错误