Skip to content

Commit

Permalink
fix: throw error when alias method is used on inkoved solids (#2672)
Browse files Browse the repository at this point in the history
fix #2670
  • Loading branch information
iKintosh authored Jul 6, 2020
1 parent 68ee026 commit bfbf490
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python_modules/dagster/dagster/core/definitions/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,19 @@ def __getitem__(self, idx):
)
)

def alias(self, _):
raise DagsterInvariantViolationError(
'In {source} {name}, attempted to call alias method for {cls}. This object '
'represents the output "{out}" from the already invoked solid "{solid}". Consider '
'checking the location of parentheses.'.format(
source=current_context().source,
name=current_context().name,
cls=self.__class__.__name__,
solid=self.solid_name,
out=self.output_name,
)
)


class InputMappingNode(object):
def __init__(self, input_def):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,3 +620,15 @@ def uninvoked_aliased_solid_pipeline():
add_one(return_one.alias('something'))

execute_pipeline(uninvoked_aliased_solid_pipeline)


def test_alias_on_invoked_solid_fails():
with pytest.raises(
DagsterInvariantViolationError, match=r'.*Consider checking the location of parentheses.'
):

@pipeline
def alias_on_invoked_solid_pipeline():
return_one().alias('something')

execute_pipeline(alias_on_invoked_solid_pipeline)

0 comments on commit bfbf490

Please # to comment.