向实体函数添加附加参数
Adding additional parameters to a solid function
我想在调用实体时添加额外的参数,它继承自另一个实体,例如:
from dagster import pipeline, repository, schedule, solid, InputDefinition, solid
@solid
def hello():
return 1
@solid(
input_defs=[
InputDefinition("name", str),
InputDefinition("age", int),
]
)
def hello2(hello_: int, name: str, age: int):
print(f"Hello {name}, {age+hello_}")
@pipeline
def pipe_2():
x = hello()
y = hello2(x, "Marcus", 20)
@repository
def deploy_docker_repository():
return [pipe_2, my_schedule]
但是当 运行 来自 dagster API grpc 的管道时,我得到以下错误:
dagster.core.errors.DagsterInvalidDefinitionError: In @pipeline pipe_2, received invalid
type <class 'str'> for input "name" (at position 1) in solid invocation "hello2".
Must pass the output from
previous solid invocations or inputs to the composition
function as inputs when invoking solids during composition.
如何修复?
"Marcus"
和20
需要都是其他实体的输出,例如
@solid
def name():
return "Marcus"
@solid
def age():
return 20
@pipeline
def pipe2():
hello2(hello(), name(), age())
否则您可以将它们作为配置传递,即 config_schema
到 hello2
而不是输入。
我想在调用实体时添加额外的参数,它继承自另一个实体,例如:
from dagster import pipeline, repository, schedule, solid, InputDefinition, solid
@solid
def hello():
return 1
@solid(
input_defs=[
InputDefinition("name", str),
InputDefinition("age", int),
]
)
def hello2(hello_: int, name: str, age: int):
print(f"Hello {name}, {age+hello_}")
@pipeline
def pipe_2():
x = hello()
y = hello2(x, "Marcus", 20)
@repository
def deploy_docker_repository():
return [pipe_2, my_schedule]
但是当 运行 来自 dagster API grpc 的管道时,我得到以下错误:
dagster.core.errors.DagsterInvalidDefinitionError: In @pipeline pipe_2, received invalid
type <class 'str'> for input "name" (at position 1) in solid invocation "hello2".
Must pass the output from
previous solid invocations or inputs to the composition
function as inputs when invoking solids during composition.
如何修复?
"Marcus"
和20
需要都是其他实体的输出,例如
@solid
def name():
return "Marcus"
@solid
def age():
return 20
@pipeline
def pipe2():
hello2(hello(), name(), age())
否则您可以将它们作为配置传递,即 config_schema
到 hello2
而不是输入。