Taragolis commented on code in PR #36393:
URL: https://github.com/apache/airflow/pull/36393#discussion_r1435669740
##########
airflow/providers/amazon/aws/operators/ecs.py:
##########
@@ -45,21 +46,18 @@
from airflow.models import TaskInstance
from airflow.utils.context import Context
-DEFAULT_CONN_ID = "aws_default"
-
-class EcsBaseOperator(BaseOperator):
+class EcsBaseOperator(AwsBaseOperator[EcsHook]):
"""This is the base operator for all Elastic Container Service
operators."""
- def __init__(self, *, aws_conn_id: str | None = DEFAULT_CONN_ID, region:
str | None = None, **kwargs):
- self.aws_conn_id = aws_conn_id
- self.region = region
+ aws_hook_class = EcsHook
+
+ def __init__(self, **kwargs):
super().__init__(**kwargs)
- @cached_property
- def hook(self) -> EcsHook:
- """Create and return an EcsHook."""
- return EcsHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+ @property
+ def _hook_parameters(self) -> dict[str, Any]:
+ return {**super()._hook_parameters}
Review Comment:
```suggestion
```
Redundant for Thin-wrapped hooks
##########
airflow/providers/amazon/aws/sensors/ecs.py:
##########
@@ -45,18 +44,17 @@ def _check_failed(current_state, target_state,
failure_states, soft_fail: bool)
raise AirflowException(message)
-class EcsBaseSensor(BaseSensorOperator):
+class EcsBaseSensor(AwsBaseSensor[EcsHook]):
"""Contains general sensor behavior for Elastic Container Service."""
- def __init__(self, *, aws_conn_id: str | None = DEFAULT_CONN_ID, region:
str | None = None, **kwargs):
- self.aws_conn_id = aws_conn_id
- self.region = region
+ aws_hook_class = EcsHook
+
+ def __init__(self, **kwargs):
super().__init__(**kwargs)
- @cached_property
- def hook(self) -> EcsHook:
- """Create and return an EcsHook."""
- return EcsHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+ @property
+ def _hook_parameters(self) -> dict[str, Any]:
+ return {**super()._hook_parameters}
Review Comment:
```suggestion
```
##########
airflow/providers/amazon/aws/sensors/ecs.py:
##########
@@ -45,18 +44,17 @@ def _check_failed(current_state, target_state,
failure_states, soft_fail: bool)
raise AirflowException(message)
-class EcsBaseSensor(BaseSensorOperator):
+class EcsBaseSensor(AwsBaseSensor[EcsHook]):
"""Contains general sensor behavior for Elastic Container Service."""
- def __init__(self, *, aws_conn_id: str | None = DEFAULT_CONN_ID, region:
str | None = None, **kwargs):
- self.aws_conn_id = aws_conn_id
- self.region = region
+ aws_hook_class = EcsHook
+
+ def __init__(self, **kwargs):
Review Comment:
I guess ``__init__`` constructor could be removed
##########
airflow/providers/amazon/aws/operators/ecs.py:
##########
@@ -45,21 +46,18 @@
from airflow.models import TaskInstance
from airflow.utils.context import Context
-DEFAULT_CONN_ID = "aws_default"
-
-class EcsBaseOperator(BaseOperator):
+class EcsBaseOperator(AwsBaseOperator[EcsHook]):
"""This is the base operator for all Elastic Container Service
operators."""
- def __init__(self, *, aws_conn_id: str | None = DEFAULT_CONN_ID, region:
str | None = None, **kwargs):
- self.aws_conn_id = aws_conn_id
- self.region = region
+ aws_hook_class = EcsHook
+
+ def __init__(self, **kwargs):
Review Comment:
I guess `__init__` constructor could be removed
--
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]