Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python solid的Core compute多次返回输出_Python_Django_Xml_Dagster - Fatal编程技术网

Python solid的Core compute多次返回输出

Python solid的Core compute多次返回输出,python,django,xml,dagster,Python,Django,Xml,Dagster,我对Dagster很陌生,在文档中找不到我问题的答案 我有两个实体:一个生成从XML文件解析的元组(str,str),另一个只使用元组并将对象存储在数据库中,并设置相应的字段。但是,我遇到了一个错误Core compute for solid多次返回了一个输出。我确信我在设计中犯了根本性的错误。有人能给我解释一下如何以正确的方式设计这个管道,或者让我看看文档中解释这个错误的章节吗 @solid(output_defs=[OutputDefinition(Tuple, 'classificati

我对Dagster很陌生,在文档中找不到我问题的答案

我有两个实体:一个生成从XML文件解析的元组(str,str),另一个只使用元组并将对象存储在数据库中,并设置相应的字段。但是,我遇到了一个错误
Core compute for solid多次返回了一个输出。我确信我在设计中犯了根本性的错误。有人能给我解释一下如何以正确的方式设计这个管道,或者让我看看文档中解释这个错误的章节吗


@solid(output_defs=[OutputDefinition(Tuple, 'classification_data')])
def extract_classification_from_file(context, xml_path: String) -> Tuple:
    context.log.info(f"start")
    root = ET.parse(xml_path).getroot()
    for code_node in root.findall('definition-item'):
        context.log.info(f"{code_node.find('classification-symbol').text} {code_node.find('definition-title').text}")
        yield Output((code_node.find('classification-symbol').text, code_node.find('definition-title').text), 'classification_data')


@solid()
def load_classification(context, classification_data):
    cls = CPCClassification.objects.create(code=classification_data[0], description=classification_data[1]).save()

@pipeline
def define_classification_pipeline():
    load_classification(extract_classification_from_file())

在查看了dagster代码库之后,我发现了你的错误。它证实了我在书中读到的“输出名称必须是唯一的”

考虑到您在for循环中声明输出以及收到的错误,您的输出对象名称可能不是唯一的


更新: 通过打开dagster,我测试了在运行时动态创建输出的想法,如果您在
@solid
之外定义动态代码,效果很好。我确实发现,当试图在
@solid
中构建动态数据,并打算将其输出用作后续
@solid
的实体配置输入时,后续
@solid
没有获取更新的结构。结果是我收到了一个
dagster.core.errors.DagsterInvariantViolationError

下面是我的代码,用于验证在实体外部执行动态数据生成时在运行时产生的动态输出。我猜这可能有点反模式,但如果Dagster还没有达到成熟度水平,可能还没有完全达到你提出的场景。还要注意,我没有处理的是对所有生成的输出对象进行处理

“dagit-f dynamic_output_at_runtime.py-n dynamic_output_at_runtime”
随机输入
从dagster进口(
产出,
输出定义,
执行"管道",,
管道
固体
SystemComputeExecutionContext
)
#为每次执行创建一些动态OutputDefinition列表
开始=1
停止=100
极限=random.randint(1,10)
random_set_of_ints={random.randint(开始、停止)用于范围(限制)内的iter}
输出定义运行时=[OutputDefinition(
name=f'output_{num}'),用于随机集合中的num
@实体(输出定义=输出定义运行时)
def ints_for_all(上下文:SystemComputeExecutionContext):
对于随机整数集合中的num:
out_name=f“output_{num}”
context.log.info(f“输出对象名称:{out\u name}”)
产量输出(数量、输出名称)
@管道
在运行时()定义动态输出:
x=整数表示所有()
打印(x)
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
结果=执行\u管道(运行时动态\u输出\u)
断言结果、成功
me重新运行此管道的结果是每次都有不同的输出产量:

python dynamic_output_at_runtime.py 
_ints_for_all_outputs(output_56=<dagster.core.definitions.composition.InvokedSolidOutputHandle object at 0x7fb899cea160>, output_8=<dagster.core.definitions.composition.InvokedSolidOutputHandle object at 0x7fb899cea198>, output_58=<dagster.core.definitions.composition.InvokedSolidOutputHandle object at 0x7fb899cea1d0>, output_35=<dagster.core.definitions.composition.InvokedSolidOutputHandle object at 0x7fb899cea208>)
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - PIPELINE_START - Started execution of pipeline "dynamic_output_at_runtime".
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - ENGINE_EVENT - Executing steps in process (pid: 9456)
 event_specific_data = {"metadata_entries": [["pid", null, ["9456"]], ["step_keys", null, ["{'ints_for_all.compute'}"]]]}
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - STEP_START - Started execution of step "ints_for_all.compute".
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - INFO - system - a1273816-16b0-439b-ae32-dbd819f65b9a - output object name: output_56
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - STEP_OUTPUT - Yielded output "output_56" of type "Any". (Type check passed).
 event_specific_data = {"intermediate_materialization": null, "step_output_handle": ["ints_for_all.compute", "output_56"], "type_check_data": [true, "output_56", null, []]}
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - INFO - system - a1273816-16b0-439b-ae32-dbd819f65b9a - output object name: output_8
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - STEP_OUTPUT - Yielded output "output_8" of type "Any". (Type check passed).
 event_specific_data = {"intermediate_materialization": null, "step_output_handle": ["ints_for_all.compute", "output_8"], "type_check_data": [true, "output_8", null, []]}
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - INFO - system - a1273816-16b0-439b-ae32-dbd819f65b9a - output object name: output_58
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - STEP_OUTPUT - Yielded output "output_58" of type "Any". (Type check passed).
 event_specific_data = {"intermediate_materialization": null, "step_output_handle": ["ints_for_all.compute", "output_58"], "type_check_data": [true, "output_58", null, []]}
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - INFO - system - a1273816-16b0-439b-ae32-dbd819f65b9a - output object name: output_35
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - STEP_OUTPUT - Yielded output "output_35" of type "Any". (Type check passed).
 event_specific_data = {"intermediate_materialization": null, "step_output_handle": ["ints_for_all.compute", "output_35"], "type_check_data": [true, "output_35", null, []]}
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - STEP_SUCCESS - Finished execution of step "ints_for_all.compute" in 2.17ms.
 event_specific_data = {"duration_ms": 2.166192003642209}
               solid = "ints_for_all"
    solid_definition = "ints_for_all"
            step_key = "ints_for_all.compute"
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - ENGINE_EVENT - Finished steps in process (pid: 9456) in 3.11ms
 event_specific_data = {"metadata_entries": [["pid", null, ["9456"]], ["step_keys", null, ["{'ints_for_all.compute'}"]]]}
2019-11-27 08:33:32 - dagster - DEBUG - dynamic_output_at_runtime - a1273816-16b0-439b-ae32-dbd819f65b9a - PIPELINE_SUCCESS - Finished execution of pipeline "dynamic_output_at_runtime".
python动态输出在运行时.py
_所有输出的整数(输出56=,输出8=,输出58=,输出35=)
2019-11-27 08:33:32-dagster-调试-运行时动态输出-a1273816-16b0-439b-ae32-dbd819f65b9a-管道启动-开始执行管道“运行时动态输出”。
2019-11-27 08:33:32-dagster-调试-运行时动态输出-a1273816-16b0-439b-ae32-dbd819f65b9a-引擎事件-执行过程中的步骤(pid:9456)
事件特定的_数据={“元数据_项”:[[“pid”,null,[“9456”]],[“步骤键”,null,[“{ints_for_all.compute'}”]}
2019-11-27 08:33:32-dagster-调试-运行时动态输出-a1273816-16b0-439b-ae32-dbd819f65b9a-步骤开始-开始执行步骤“所有计算的输入”。
solid=“ints\u表示所有”
solid\u definition=“ints\u代表所有”
step_key=“ints_for_all.compute”
2019-11-27 08:33:32-dagster-信息-系统-a1273816-16b0-439b-ae32-dbd819f65b9a-输出对象名称:output_56
solid=“ints\u表示所有”
solid\u definition=“ints\u代表所有”
step_key=“ints_for_all.compute”
2019-11-27 08:33:32-dagster-调试-运行时动态输出-a1273816-16b0-439b-ae32-dbd819f65b9a-步骤输出-生成“任意”类型的输出“输出”。(类型检查通过)。
事件特定的_数据={“中间_物化”:null,“步骤_输出_句柄”:[“int_for_all.compute”,“output_56”],“type_check_data”:[true,“output_56”,null,[]}
solid=“ints\u表示所有”
solid\u definition=“ints\u代表所有”
step_key=“ints_for_all.compute”
2019-11-27 08:33:32-dagster-信息-系统-a1273816-16b0-439b-ae32-dbd819f65b9a-输出对象名称:output_8
solid=“ints\u表示所有”
solid\u definition=“ints\u代表所有”
step_key=“ints_for_all.compute”
2019-11-27 08:33:32-dagster-调试-运行时动态输出-a1273816-16b0-439b-ae32-dbd819f65b9a-步骤输出-生成“任意”类型的输出“输出”。(类型检查通过)。
事件特定的_数据={“中间_物化”:null,“步骤_输出_句柄”:[“int_for_all.compute”,“output_8”],“type_check_data”:[true,“output_8”,null,[]}
solid=“ints\u表示所有”
solid\u definition=“ints\u代表所有”
step_key=“ints_for_all.compute”
2019-11-27 08:33:32-dagster-信息-系统-a1273816-16b0-439b-ae32-dbd819f65b9a-输出对象名称:OUTPUT58
solid=“ints\u表示所有”
solid\u definition=“ints\u代表所有”
step_key=“ints_for_all.compute”
2019-11-27 08:33:32-dagster-调试-运行时动态输出-a1273816-16b0-439b-ae32-dbd819f65b9a-步骤输出-生成“任意”类型的输出“输出”。(类型检查通过)。
事件特定的_数据={“中间_物化”:null,“步骤_输出_句柄”:[“int_for_all.compute”,“output_58”],“type_check_data”:[true,“output_58”,null,[]}
solid=“ints\u表示所有”
solid\u definition=“ints\u代表所有”
step_key=“ints_for_all.compute”
2019-11-27 08:33:32 -