如何避免因未将参数传递给 Celery Bound 方法而导致的 Pylint 错误?

问题描述

该项目旨在通过 REST API 为机器学习模型提供服务。这是 celery 任务声明,以及用于检查函数是否在示例输入上运行的单元测试。

@celery.task(bind=True)
def run_prediction(self,inpath: str) -> pandas.DataFrame:
    '''
    :param inpath File location of the input feature
    '''
    # Do a lot of stuffs
    return output # type:pandas.DataFrame

if __name__=='__main__':
    # Do a unit test with a sample inpath
    pred:pandas.DataFrame=run_prediction(inpath=sample_inpath)

run_prediction 函数可以作为独立的普通函数触发,无需关心 celery,也可以作为异步方法与 celery 提供的 apply_async 一起触发。 (我没想到它具有独立函数功能,因此对此进行任何解释都会很棒。)

但主要问题是当我通过 pylint(2.5.3 版)检查代码时,它抛出一个错误一个警告,两者都说同样的话。

model_utility.py:92:34: W0613: Unused argument 'self' (unused-argument)
model_utility.py:188:4: E1120: No value for argument 'self' in function call (no-value-for-parameter)

这是否意味着 pylint 不知道如何调用函数?我可以更新代码以获得来自 pylint 的 10/10 吗?或者我应该改变一些关于 pylint 本身的东西吗?

如果这对讨论很重要,请使用我的编辑器 (Atom) 中的包 pylint 作为参考。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)