https://dagster.io/ logo
Title
s

Simon

03/28/2023, 3:07 PM
Hi Dagster team! I was wondering if there's a way to use aliased Ops in a
GraphDefinition
?
GraphDefinition(node_defs=[someop.alias("foo")], ...)
doesn't work, it results in the following exception
AttributeError: 'PendingNodeInvocation' object has no attribute '__name__'
This seems to be the same as this issue from end of 2021 https://github.com/dagster-io/dagster/issues/5603 I also tried this
GraphDefinition(node_defs=[NodeInvocation(name="wait", alias="testalias")], ...)
but this also doesn't work, it results in
dagster._core.errors.DagsterInvalidDefinitionError: Invalid item in node list: NodeInvocation
Is there a way to make this work?
s

sean

03/28/2023, 8:34 PM
Hmm looks like you’ll need to use the decorator for now, but this bug has been there a long time so I am taking it on to fix for next week.
❤️ 1
s

Simon

03/29/2023, 11:23 AM
@sean Thanks! I just did some more digging and it seems that
node_defs
only contains Ops. In case of one Op that's aliased several times in one graph I only see that Op once in
graph_def.node_defs
when using
@graph
. So aliased Ops don't show up in there. Then I did some more prodding and it seems the aliasing is done as part of
dependencies
where they are added as
NodeInvocation
as keys of the dict and then they can be referenced in other values in the dependencies dict, like so
{NodeInvocation(name="op_name", alias="fooalias"): {}, "bar": {"after": DependencyDefinition("fooalias")}
I didn't expect that the aliasing would need to be done as part of the
dependencies
config, that's a bit surprising to me. In any case, given how this currently works I'm not sure the bug is correct, although it might be useful to come up with a better/clearer way to do this. Alternatively if the current way is fine it would be good to mention this in the
Graphdefinition.dependencies
docs.
Moved/copied the above comment here https://github.com/dagster-io/dagster/issues/5603#issuecomment-1490783354 so that's it's tracked/visible for others, figured that'd be better than keeping this in Slack.
🙏 1