diff --git a/python_modules/dagster/dagster/core/definitions/composition.py b/python_modules/dagster/dagster/core/definitions/composition.py index d7ff71ed0d66e..3c8e89a0f6193 100644 --- a/python_modules/dagster/dagster/core/definitions/composition.py +++ b/python_modules/dagster/dagster/core/definitions/composition.py @@ -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): diff --git a/python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_composition.py b/python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_composition.py index a598fbfb6364e..735dd1bc4a617 100644 --- a/python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_composition.py +++ b/python_modules/dagster/dagster_tests/core_tests/definitions_tests/test_composition.py @@ -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)