amoghrajesh commented on code in PR #53393:
URL: https://github.com/apache/airflow/pull/53393#discussion_r2275947577
##########
task-sdk/src/airflow/sdk/definitions/_internal/abstractoperator.py:
##########
@@ -31,13 +31,13 @@
import methodtools
from airflow.configuration import conf
+from airflow.sdk.api.datamodels._generated import WeightRule
Review Comment:
I do not love this import pattern, IDK if its feasible to add it to lazy
imports and have the usage be: `from airflow.sdk import WeightRule`?
##########
devel-common/src/tests_common/test_utils/compat.py:
##########
@@ -63,7 +63,6 @@
# Compatibility for Airflow < 3.1
from airflow.utils.xcom import XCOM_RETURN_KEY # type:
ignore[no-redef,attr-defined]
-
Review Comment:
nit: clear up this diff.
##########
airflow-core/src/airflow/configuration.py:
##########
@@ -202,6 +203,28 @@ def retrieve_configuration_description(
return base_configuration_description
+class WeightRule(str, Enum):
+ """Weight rules."""
+
+ DOWNSTREAM = "downstream"
+ UPSTREAM = "upstream"
+ ABSOLUTE = "absolute"
+
+ @classmethod
+ def is_valid(cls, weight_rule: str) -> bool:
+ """Check if weight rule is valid."""
+ return weight_rule in cls.all_weight_rules()
+
+ @methodtools.lru_cache(maxsize=None)
+ @classmethod
+ def all_weight_rules(cls) -> set[str]:
+ """Return all weight rules."""
+ return set(cls.__members__.values())
+
+ def __str__(self) -> str:
+ return self.value
Review Comment:
I'm ok with keeping it as well, although I really do not love that its
defined in `airflow.configuration`, maybe we could move it elsewhere? I do not
have a proposal at the moment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]