何时在气流中创建自定义操作员?

发布于 2025-02-13 04:45:04 字数 325 浏览 0 评论 0原文

因此,在某些用例中,我想检查文件的大小,并且是否超过可配置值的大小(根据业务规则更改文件类型),我们将返回true/false作为返回值。这只是添加一些上下文的用例,而不是我的问题。问题是“何时决定创建客户操作员,而与仅使用Python Collable,因为它试图完成是很小的任务,

  1. 方面,可重复使用的可重复性增长(
  2. 在使用操作员单阶级责任和更好的测试(单位测试操作员)
  3. 的可维护性
  4. 更好 )运营商预期的一些未来复杂性,

因此您认为使用自定义操作员比使用Python Callable的简单Pythontonerator更好?

So there is a use case where I want to check the size of file and if it more than the size of a configurable value (changes per file type as per business rule) , we would return true/false as a return value. This is just a use case to add some context and not exactly my question. Question is 'when to decide to create a customer operator vs just using python callable as it is trying to accomplish is small task

  1. there is reusability gain in terms of using operator
  2. Single class responsibility and better testing (unit test of operator )
  3. Better maintainability
  4. There are some future complexity expected in the operator

So do you think it is better to use a custom operator than a simple pythonoperator with python callable ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

能否归途做我良人 2025-02-20 04:45:04

我将从一个python callable开始,以启动一些有效的东西。或者,您可以将其封装在Python脚本/文件中,以便您可以在气流之外进行对其进行测试。这本身就是通过仅用于编排而不包含业务逻辑的气流来分离责任。

I would start with a python callable to start something small that works. Or you can encapsulate this in a python script/file so you can unit test it outside of airflow. This itself is a separation of responsibility by using airflow only for orchestration and not to contain business logic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文