草庐IT

python - Airflow :将 {{ ds }} 作为参数传递给 PostgresOperator

我想使用执行日期作为我的sql文件的参数:我试过了dt='{{ds}}'s3_to_redshift=PostgresOperator(task_id='s3_to_redshift',postgres_conn_id='redshift',sql='s3_to_redshift.sql',params={'file':dt},dag=dag)但它不起作用。 最佳答案 dt='{{ds}}'不起作用,因为Jinja(Airflow中使用的模板引擎)不处理整个Dag定义文件。对于每个Operator都有Jinja将处理的字段,它们是运

python - Airflow 没有以 airflow_home 目录中的目录命名的模块

我正在使用virtualenv。我正在尝试使用DAG文件夹中的包。airflow_home目录的当前状态是:airflow_home/airflow.cfgairflow_home/airflow.dbairflow_home/dags/__init__.pyairflow_home/dags/hello_world.pyairflow_home/dags/support/inner.pyairflow_home/dags/support/__init__.pyhello_world.py有代码:fromdatetimeimportdatetimefromairflowimportDA

python - Apache Airflow DAG 无法导入本地模块

我似乎不明白如何将模块导入apacheairflowDAG定义文件。例如,我想这样做是为了能够创建一个库,该库可以使具有类似设置的任务声明变得不那么冗长。这是我能想到的最简单的例子,它重现了这个问题:我修改了Airflow教程(https://airflow.apache.org/tutorial.html#recap)以简单地导入一个模块并从该模块运行一个定义。像这样:目录结构:-dags/--__init__.py--lib.py--tutorial.py教程.py:"""CodethatgoesalongwiththeAirflowlocatedat:http://airflow

python - airflow trigger_dag execution_date 是第二天,为什么?

最近我对Airflow进行了太多测试,以至于execution_date有一个问题运行时airflowtrigger_dag.我了解到execution_date不是我们第一次从here想到的:AirflowwasdevelopedasasolutionforETLneeds.IntheETLworld,youtypicallysummarizedata.So,ifIwanttosummarizedatafor2016-02-19,Iwoulddoitat2016-02-20midnightGMT,whichwouldberightafteralldatafor2016-02-19be

python - 如何在 Airflow 中运行 bash 脚本文件

我有一个bash脚本,它创建了一个我想在Airflow中运行的文件(如果它不存在),但是当我尝试时它失败了。我该怎么做?#!/bin/bash#create_file.shfile=filename.txtif[!-e"$file"];thentouch"$file"fiif[!-w"$file"];thenechocannotwriteto$fileexit1fi下面是我在Airflow中的调用方式:create_command="""./scripts/create_file.sh"""t1=BashOperator(task_id='create_file',bash_comma

python - 如何在 Airflow 中运行 bash 脚本文件

我有一个bash脚本,它创建了一个我想在Airflow中运行的文件(如果它不存在),但是当我尝试时它失败了。我该怎么做?#!/bin/bash#create_file.shfile=filename.txtif[!-e"$file"];thentouch"$file"fiif[!-w"$file"];thenechocannotwriteto$fileexit1fi下面是我在Airflow中的调用方式:create_command="""./scripts/create_file.sh"""t1=BashOperator(task_id='create_file',bash_comma

python - 运行简单的 Airflow BashOperator 时出现 TemplateNotFound 错误

我正在尝试编写我们的第一个AirflowDAG,当我尝试使用命令airflowlist_tasksorderwarehouse列出任务时出现以下错误:Traceback(mostrecentcalllast):File"/usr/local/lib/python2.7/site-packages/airflow/models.py",line2038,inresolve_template_filessetattr(self,attr,env.loader.get_source(env,content)[0])File"/usr/local/lib/python2.7/site-pack

python - 运行简单的 Airflow BashOperator 时出现 TemplateNotFound 错误

我正在尝试编写我们的第一个AirflowDAG,当我尝试使用命令airflowlist_tasksorderwarehouse列出任务时出现以下错误:Traceback(mostrecentcalllast):File"/usr/local/lib/python2.7/site-packages/airflow/models.py",line2038,inresolve_template_filessetattr(self,attr,env.loader.get_source(env,content)[0])File"/usr/local/lib/python2.7/site-pack

airflow v2.6.0 Docker Compose 部署

文章目录物料准备镜像构建与启动物料准备相关部署文件git地址https://github.com/itnoobzzy/EasyAirflow.git项目文件目录如下:配置文件及对应目录airflow容器化部署需要将dag和logs以及plugin挂载,同时需要将配置文件airflow.cfg挂载至容器内部。下载完后执行如下命令配置airflow.cfg配置文件:cpEasyAirflowcpconfig/default_airflow.cfgairflow.cfg#修改airflow.cfg中的数据库等相关配置信息vimairflow.cfg这里主要需要修改四个地方:将executor修改为C

redis - 请求中的 Airflow CROSSSLOT 键不会使用 AWS ElastiCache 散列到相同的插槽错误

我在AWSECS上运行apache-airflow1.8.1,我有一个AWSElastiCache集群(redis3.2.4),运行2个分片/2个节点,启用了多可用区(集群redis引擎)。我已经验证Airflow可以毫无问题地访问集群的主机/端口。这是日志:ThuJul2001:39:21UTC2017-Checkingforredis(endpoint:redis://xxxxxx.xxxxxx.clustercfg.usw2.cache.amazonaws.com:6379)connectivityThuJul2001:39:21UTC2017-Connectedtoredis(