简体   繁体   English

Airflow XCOM 拉不渲染

[英]Airflow XCOM pull is not rendering

I have a custom operator where in the argument list I am using xcom_pull to get values from XCOM.我有一个自定义运算符,在参数列表中我使用 xcom_pull 从 XCOM 获取值。 But it is not rendering to actual value instead it remains as the string.但它没有呈现为实际值,而是保留为字符串。

download= CustomSparkSubmitOperator(
    task_id='download',
    spark_args=command_func(
        env, application,
        '%s/spark_args' % key,
        ['--input_file', "{{ ti.xcom_pull('set_parameters', key='input_file') }}",
         '--output_file', "{{ ti.xcom_pull('set_parameters', key='output_file') }}"
         ],
    provide_context=True,
    dag=dag)

The operator returns the following output:运算符返回以下 output:

spark-submit --deploy-mode cluster..... --input_file "{{ ti.xcom_pull('set_parameters', key='input_file') }}" --output_file "{{ ti.xcom_pull('set_parameters', key='output_file') }}"

I was able to fix the problem of XCOM values not rendering when using as an argument in my CustomSparkSubmitEMROperator.在我的 CustomSparkSubmitEMROperator 中用作参数时,我能够解决 XCOM 值不呈现的问题。 Internally the operator inherits the EMROperators.在内部,操作员继承了 EMROperators。 For example例如

class CustomSparkSubmitEMROperator(EmrAddStepsOperator, EmrStepSensor):

So I needed to add the below template_fields as shown below所以我需要添加下面的template_fields,如下所示

template_fields = ('job_flow_id', 'steps')

After adding the above lines the XCOM values where properly rendered and was able to see the correct values in the resultant spark-submit command添加上述行后,XCOM 值正确呈现并能够在生成的 spark-submit 命令中看到正确的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM