diff --git a/python_modules/dagster/dagster/_core/definitions/declarative_automation/operators/boolean_operators.py b/python_modules/dagster/dagster/_core/definitions/declarative_automation/operators/boolean_operators.py index d3371d110fa8e..53325ea89d847 100644 --- a/python_modules/dagster/dagster/_core/definitions/declarative_automation/operators/boolean_operators.py +++ b/python_modules/dagster/dagster/_core/definitions/declarative_automation/operators/boolean_operators.py @@ -2,6 +2,8 @@ from collections.abc import Sequence from typing import TYPE_CHECKING, Union +from typing_extensions import TypeIs + import dagster._check as check from dagster._annotations import public from dagster._core.definitions.asset_key import T_EntityKey @@ -11,6 +13,9 @@ BuiltinAutomationCondition, ) from dagster._core.definitions.declarative_automation.automation_context import AutomationContext +from dagster._core.definitions.declarative_automation.operators.dep_operators import ( + DepsAutomationCondition, +) from dagster._record import copy, record from dagster._serdes.serdes import whitelist_for_serdes @@ -18,6 +23,33 @@ from dagster._core.definitions.asset_selection import AssetSelection +def _has_allow_ignore( + condition: AutomationCondition, +) -> TypeIs[ + Union[ + DepsAutomationCondition, + "AndAutomationCondition", + "OrAutomationCondition", + "NotAutomationCondition", + ] +]: + from dagster._core.definitions.declarative_automation.operators.boolean_operators import ( + AndAutomationCondition, + NotAutomationCondition, + OrAutomationCondition, + ) + + return isinstance( + condition, + ( + DepsAutomationCondition, + AndAutomationCondition, + OrAutomationCondition, + NotAutomationCondition, + ), + ) + + @whitelist_for_serdes(storage_name="AndAssetCondition") @record class AndAutomationCondition(BuiltinAutomationCondition[T_EntityKey]): @@ -98,7 +130,7 @@ def allow(self, selection: "AssetSelection") -> "AndAutomationCondition": return copy( self, operands=[ - child.allow(selection) if hasattr(child, "allow") else child + child.allow(selection) if _has_allow_ignore(child) else child for child in self.operands ], ) @@ -118,7 +150,7 @@ def ignore(self, selection: "AssetSelection") -> "AndAutomationCondition": return copy( self, operands=[ - child.ignore(selection) if hasattr(child, "ignore") else child + child.ignore(selection) if _has_allow_ignore(child) else child for child in self.operands ], ) @@ -199,7 +231,7 @@ def allow(self, selection: "AssetSelection") -> "OrAutomationCondition": return copy( self, operands=[ - child.allow(selection) if hasattr(child, "allow") else child + child.allow(selection) if _has_allow_ignore(child) else child for child in self.operands ], ) @@ -219,7 +251,7 @@ def ignore(self, selection: "AssetSelection") -> "OrAutomationCondition": return copy( self, operands=[ - child.ignore(selection) if hasattr(child, "ignore") else child + child.ignore(selection) if _has_allow_ignore(child) else child for child in self.operands ], ) @@ -288,7 +320,7 @@ def allow(self, selection: "AssetSelection") -> "NotAutomationCondition": return copy( self, operand=self.operand.allow(selection) - if hasattr(self.operand, "allow") + if _has_allow_ignore(self.operand) else self.operand, ) @@ -307,6 +339,6 @@ def ignore(self, selection: "AssetSelection") -> "NotAutomationCondition": return copy( self, operand=self.operand.ignore(selection) - if hasattr(self.operand, "ignore") + if _has_allow_ignore(self.operand) else self.operand, ) diff --git a/python_modules/dagster/setup.py b/python_modules/dagster/setup.py index 98f9cefa2d2fe..e68a16937697b 100644 --- a/python_modules/dagster/setup.py +++ b/python_modules/dagster/setup.py @@ -95,7 +95,7 @@ def get_version() -> str: "tabulate", "tomli<3", "tqdm<5", - "typing_extensions>=4.4.0,<5", + "typing_extensions>=4.10.0,<5", 'tzdata; platform_system=="Windows"', "structlog", "sqlalchemy>=1.0,<3",