【发布时间】:2022-01-17 10:01:21
【问题描述】:
我正在尝试创建一个继承自 Airflow BaseOperator 的 CustomBaseOperator。 CustomBaseOperator 工作正常,但是当我尝试创建继承自 CustomBaseOperator 的 ChildOperator 时,Airflow 将其视为 CustomBaseOperator。
CustomBaseOperator 有一个如下所示的执行函数:
def make_request(self):
print("Parent request")
def execute(self, context):
self.make_request()
在 Child Operator 中,我重新定义了 make_request:
class ChildOperator(CustomBaseOperator):
@apply_defaults
def make_request(self):
print("Child Request")
每当我运行使用 ChildOperator 的任务时,它都会打印“父请求”,并且图例将其显示为 CustomBaseOperator ... 我的操作员位于“插件”文件夹中的“操作员”文件夹中。我猜在该文件夹中创建自定义运算符时,我只能从“官方”运算符继承。 你知道我怎样才能使继承工作吗?
【问题讨论】:
-
请显示完整的课程代码。 CustomBaseOperator 和 ChildOperator。你写的应该有效,所以其他事情正在发生
标签: python inheritance airflow