【问题标题】:No value for arguement in function call函数调用中的参数没有值
【发布时间】:2019-12-04 01:44:58
【问题描述】:

我对 Python 很陌生,正在通过Dagster hello tutorial 工作

我在教程中设置了以下内容

import csv

from dagster import execute_pipeline, execute_solid, pipeline, solid


@solid
def hello_cereal(context):
    # Assuming the dataset is in the same directory as this file
    dataset_path = 'cereal.csv'
    with open(dataset_path, 'r') as fd:
        # Read the rows in using the standard csv library
        cereals = [row for row in csv.DictReader(fd)]

    context.log.info(
        'Found {n_cereals} cereals'.format(n_cereals=len(cereals))
    )

    return cereals


@pipeline
def hello_cereal_pipeline():
    hello_cereal()

但是 pylint 显示

参数无值

消息。

我错过了什么?

当我尝试执行管道时,我得到以下信息

D:\python\dag>dagster 管道执行 -f hello_cereal.py -n hello_cereal_pipeline 2019-11-25 14:47:09 - dagster - 调试 - hello_cereal_pipeline - 96c575ae-0b7d-49cb-abf4-ce998865ebb3 - PIPELINE_START - 开始执行管道 “hello_cereal_pipeline”。 2019-11-25 14:47:09 - dagster - 调试 - hello_cereal_pipeline - 96c575ae-0b7d-49cb-abf4-ce998865ebb3 - ENGINE_EVENT - 执行过程中的步骤 (pid: 11684) event_specific_data = {"metadata_entries": [["pid", null, ["11684"]], ["step_keys", null, ["{'hello_cereal.compute'}"]]]} 2019-11-25 14:47:09 - dagster - 调试 - hello_cereal_pipeline - 96c575ae-0b7d-49cb-abf4-ce998865ebb3 - STEP_START - 开始执行 步骤“hello_cereal.compute”。 固体=“你好谷物” solid_definition = "hello_cereal" step_key = "hello_cereal.compute" 2019-11-25 14:47:10 - dagster - 错误 - hello_cereal_pipeline - 96c575ae-0b7d-49cb-abf4-ce998865ebb3 - STEP_FAILURE - 执行 步骤“hello_cereal.compute”失败。 cls_name = "FileNotFoundError" 固体=“你好谷物” solid_definition = "hello_cereal" step_key = "hello_cereal.compute"

文件 "c:\users\kirst\appdata\local\programs\python\python38-32\lib\site-packages\dagster\core\errors.py", 第 114 行,在 user_code_error_boundary 产生文件“c:\users\kirst\appdata\local\programs\python\python38-32\lib\site-packages\dagster\core\engine\engine_inprocess.py”, 第 621 行,在 _user_event_sequence_for_step_compute_fn 对于 gen 中的事件:文件“c:\users\kirst\appdata\local\programs\python\python38-32\lib\site-packages\dagster\core\execution\plan\compute.py”, 第 75 行,在 _execute_core_compute 对于_yield_compute_results(compute_context,inputs,compute_fn)中的step_output:文件 "c:\users\kirst\appdata\local\programs\python\python38-32\lib\site-packages\dagster\core\execution\plan\compute.py", 第 52 行,在 _yield_compute_results 中 对于 user_event_sequence 中的事件:文件“c:\users\kirst\appdata\local\programs\python\python38-32\lib\site-packages\dagster\core\definitions\decorators.py”, 第 418 行,在计算中 结果 = fn(context, **kwargs) 文件“hello_cereal.py”,第 10 行,在 hello_cereal 使用 open(dataset_path, 'r') 作为 fd:

2019-11-25 14:47:10 - dagster - 调试 - hello_cereal_pipeline - 96c575ae-0b7d-49cb-abf4-ce998865ebb3 - ENGINE_EVENT - 完成的步骤 处理中 (pid: 11684) in 183ms event_specific_data = {"metadata_entries": [["pid", null, ["11684"]], ["step_keys", null, [“{'hello_cereal.compute'}”]]]} 2019-11-25 14:47:10 - dagster - 错误 - hello_cereal_pipeline - 96c575ae-0b7d-49cb-abf4-ce998865ebb3 - PIPELINE_FAILURE - 执行管道“hello_cereal_pipeline” 失败了。

[更新] 从 Rahul 的评论中,我意识到我没有复制整个示例。 当我更正我收到 FileNotFoundError 时

【问题讨论】:

  • 你运行了这个例子吗? github.com/dagster-io/dagster/blob/…
  • 从代码中我看到有一个open() 调用了一个名为cereal.csv 的文件。你能确认一个名为cereal.csv的文件在你运行代码的地方吗?

标签: python-3.x dagster


【解决方案1】:

回答关于为什么您会收到“无参数值”pylint 消息的原始问题 -

这是因为管道函数调用在构造函数中不包含任何参数,而@solid 函数已定义参数。这是 dagster 有意为之的,可以通过在模块的开头或带有 pylint 消息的行的右侧添加以下行来忽略它。请注意,将 python 注释放在模块开头会告诉 pylint 忽略模块中的任何警告实例,而将注释放在行内告诉 pylint 仅忽略该警告实例。

# pylint: disable=no-value-for-parameter 

最后,您也可以在 .pylintrc 文件中添加类似的忽略语句,但我建议您不要这样做,因为这将是项目全局的,您可能会错过真正的问题。

希望这会有所帮助!

【讨论】:

  • 所以该行可能如下所示:` hello_cereal() # pylint: disable=no-value-for-parameter`
【解决方案2】:

请检查您使用的数据集(csv 文件)是否与您的代码文件在同一目录中。这可能就是为什么你得到了

FileNotFoundError 错误

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-10
    相关资源
    最近更新 更多