简体   繁体   English

如何在运行后删除所有 Xcom?

[英]How to delete all Xcom after a run?

I am kind of new to airflow and I can not seem to find a way to delete all my Xcom after a run.我对 airflow 有点陌生,我似乎找不到在运行后删除所有 Xcom 的方法。 I found the bash command airflow clear, but this deleted task instances as well and I just want the Xcom cleared.我发现 bash 命令 airflow 清除了,但是这个删除的任务实例也很清楚,我只想清除 Xcom。 Any help is welcomed.欢迎任何帮助。 Thanks!谢谢!

Update:更新:

clear_xcom_operator = SqliteOperator(
    task_id="clear_Xcom",
    sqlite_conn_id="sqlite_default",
    sql="delete from xcom where dag_id='dumper'",
    retries=0,
    dag=dag,
)

I am doing this but I get the error:我正在这样做,但我得到了错误:

sqlite3.OperationalError: no such table: xcom sqlite3.OperationalError:没有这样的表:xcom

Any ideas?有任何想法吗?

I am not aware of a functionality to clear XCOM that is provided out of the box.我不知道开箱即用的清除 XCOM 的功能。 Probably, the only ways is to manipulate the backend database directly, by deleting the entries in the xcom table based on dag_id .可能,唯一的方法是直接操作后端数据库,通过删除基于dag_idxcom表中的条目。

XCOM is not meant to exchange large amounts of data between tasks. XCOM 并不是要在任务之间交换大量数据。 So, if space considerations is the reason for deleting XCOM values, a better solution would be to avoid using XCOM and write out the data to a shared storage.因此,如果空间考虑是删除 XCOM 值的原因,更好的解决方案是避免使用 XCOM 并将数据写入共享存储。

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

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