2

我对 Python 很陌生,正在学习 Dagster hello 教程

我已经从教程中设置了以下内容

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 pipeline execute -f hello_cereal.py -n hello_cereal_pipeline 2019-11-25 14:47:09 - dagster - DEBUG - 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 = “hello_cereal”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 行,在 user_event_sequence 中的事件的 _yield_compute_results 中:文件“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 - 在 183 毫秒内完成的过程中的步骤 (pid: 11684) 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

4

2 回答 2

3

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

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

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

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

希望这个对你有帮助!

于 2019-12-03T17:44:58.857 回答
1

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

FileNotFoundError 错误

于 2019-11-25T06:07:57.583 回答