diff --git a/python_modules/dagster/dagster/_core/execution/context/invocation.py b/python_modules/dagster/dagster/_core/execution/context/invocation.py index 49adc714175ff..2fe58e73cb7a7 100644 --- a/python_modules/dagster/dagster/_core/execution/context/invocation.py +++ b/python_modules/dagster/dagster/_core/execution/context/invocation.py @@ -408,6 +408,10 @@ def bind( def unbind(self): self._bound_properties = None + @property + def is_bound(self) -> bool: + return self._bound_properties is not None + @property def execution_properties(self) -> RunlessExecutionProperties: return self._execution_properties diff --git a/python_modules/dagster/dagster_tests/core_tests/test_op_invocation.py b/python_modules/dagster/dagster_tests/core_tests/test_op_invocation.py index 257889340910f..136c20c626f41 100644 --- a/python_modules/dagster/dagster_tests/core_tests/test_op_invocation.py +++ b/python_modules/dagster/dagster_tests/core_tests/test_op_invocation.py @@ -1390,12 +1390,12 @@ async def main(): def assert_context_unbound(context: RunlessOpExecutionContext): # to assert that the context is correctly unbound after op invocation - assert context.bound_properties is None + assert not context.is_bound def assert_context_bound(context: RunlessOpExecutionContext): # to assert that the context is correctly bound during op invocation - assert context.bound_properties is not None + assert context.is_bound def assert_execution_properties_cleared(context: RunlessOpExecutionContext):