【问题标题】:In luigi what is the difference between the function requires and the @requires mark?在 luigi 中,函数 requires 和 @requires 标记有什么区别?
【发布时间】:2020-09-16 06:34:19
【问题描述】:

当指定任务时,一些任务是这样的

class aclass(luigi.Task):
    def requres(self):
        return [anotherTask]

别人喜欢

@requires(anotherTask)
class aclass(luigi.Task):
    ....something

有什么区别?为什么要使用一个而不是另一个?

【问题讨论】:

    标签: python luigi


    【解决方案1】:

    在定义def requires(self): 时,您需要返回一个任务实例列表,并将它们的参数传递给它们。如果您有很多具有相同参数的任务,则意味着大量样板。

    使用装饰器@requires,您不必重新定义参数,也不必传递它们,luigi 会为您完成。

    https://luigi.readthedocs.io/en/stable/api/luigi.util.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-12
      • 2018-02-02
      • 2021-03-19
      • 2017-12-20
      • 1970-01-01
      • 2018-01-22
      • 2013-10-10
      • 1970-01-01
      相关资源
      最近更新 更多