You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vincbeck (via GitHub)" <gi...@apache.org> on 2024/09/04 15:30:21 UTC
Re: [PR] Use base aws classes in AWS Glue DataBrew Operators/Triggers [airflow]
vincbeck commented on code in PR #41848:
URL: https://github.com/apache/airflow/pull/41848#discussion_r1744004674
##########
airflow/providers/amazon/aws/operators/glue_databrew.py:
##########
@@ -47,36 +49,55 @@ class GlueDataBrewStartJobOperator(BaseOperator):
:param deferrable: If True, the operator will wait asynchronously for the job to complete.
This implies waiting for completion. This mode requires aiobotocore module to be installed.
(default: False)
- :param delay: Time in seconds to wait between status checks. Default is 30.
+ :param delay: Time in seconds to wait between status checks. (Deprecated).
+ :param waiter_delay: Time in seconds to wait between status checks. Default is 30.
+ :param waiter_max_attempts: Maximum number of attempts to check for job completion. (default: 60)
:return: dictionary with key run_id and value of the resulting job's run_id.
+
+ :param aws_conn_id: The Airflow connection used for AWS credentials.
+ If this is ``None`` or empty then the default boto3 behaviour is used. If
+ running Airflow in a distributed manner and aws_conn_id is None or
+ empty, then default boto3 configuration would be used (and must be
+ maintained on each worker node).
+ :param region_name: AWS region_name. If not specified then the default boto3 behaviour is used.
+ :param verify: Whether or not to verify SSL certificates. See:
+ https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html
+ :param botocore_config: Configuration dictionary (key-values) for botocore client. See:
+ https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
"""
- template_fields: Sequence[str] = (
+ aws_hook_class = GlueDataBrewHook
+
+ template_fields: Sequence[str] = aws_template_fields(
"job_name",
"wait_for_completion",
- "delay",
- "deferrable",
+ "waiter_delay",
+ "waiter_max_attemptsdeferrable",
)
def __init__(
self,
job_name: str,
wait_for_completion: bool = True,
- delay: int = 30,
+ delay: int | None = None,
+ waiter_delay: int = 30,
+ waiter_max_attempts: int = 60,
deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False),
- aws_conn_id: str | None = "aws_default",
**kwargs,
):
super().__init__(**kwargs)
self.job_name = job_name
self.wait_for_completion = wait_for_completion
+ self.waiter_delay = waiter_delay
+ self.waiter_max_attempts = waiter_max_attempts
self.deferrable = deferrable
- self.delay = delay
- self.aws_conn_id = aws_conn_id
-
- @cached_property
- def hook(self) -> GlueDataBrewHook:
- return GlueDataBrewHook(aws_conn_id=self.aws_conn_id)
+ if delay is not None:
+ warnings.warn(
+ "please use waiter_delay instead of delay.",
Review Comment:
```suggestion
"please use `waiter_delay` instead of delay.",
```
##########
airflow/providers/amazon/aws/triggers/glue_databrew.py:
##########
@@ -27,20 +30,38 @@ class GlueDataBrewJobCompleteTrigger(AwsBaseWaiterTrigger):
:param job_name: Glue DataBrew job name
:param run_id: the ID of the specific run to watch for that job
- :param delay: Number of seconds to wait between two checks. Default is 10 seconds.
- :param max_attempts: Maximum number of attempts to wait for the job to complete. Default is 60 attempts.
+ :param delay: Number of seconds to wait between two checks.(Deprecated).
+ :param waiter_delay: Number of seconds to wait between two checks. Default is 30 seconds.
+ :param max_attempts: Maximum number of attempts to wait for the job to complete.(Deprecated).
+ :param waiter_max_attempts: Maximum number of attempts to wait for the job to complete. Default is 60 attempts.
:param aws_conn_id: The Airflow connection used for AWS credentials.
"""
def __init__(
self,
job_name: str,
run_id: str,
- aws_conn_id: str | None,
- delay: int = 10,
- max_attempts: int = 60,
+ delay: int | None = None,
+ max_attempts: int | None = None,
+ waiter_delay: int = 30,
+ waiter_max_attempts: int = 60,
+ aws_conn_id: str | None = "aws_default",
**kwargs,
):
+ if delay is not None:
+ warnings.warn(
+ "please use waiter_delay instead of delay.",
Review Comment:
```suggestion
"please use `waiter_delay` instead of delay.",
```
##########
airflow/providers/amazon/aws/triggers/glue_databrew.py:
##########
@@ -27,20 +30,38 @@ class GlueDataBrewJobCompleteTrigger(AwsBaseWaiterTrigger):
:param job_name: Glue DataBrew job name
:param run_id: the ID of the specific run to watch for that job
- :param delay: Number of seconds to wait between two checks. Default is 10 seconds.
- :param max_attempts: Maximum number of attempts to wait for the job to complete. Default is 60 attempts.
+ :param delay: Number of seconds to wait between two checks.(Deprecated).
+ :param waiter_delay: Number of seconds to wait between two checks. Default is 30 seconds.
+ :param max_attempts: Maximum number of attempts to wait for the job to complete.(Deprecated).
+ :param waiter_max_attempts: Maximum number of attempts to wait for the job to complete. Default is 60 attempts.
:param aws_conn_id: The Airflow connection used for AWS credentials.
"""
def __init__(
self,
job_name: str,
run_id: str,
- aws_conn_id: str | None,
- delay: int = 10,
- max_attempts: int = 60,
+ delay: int | None = None,
+ max_attempts: int | None = None,
+ waiter_delay: int = 30,
+ waiter_max_attempts: int = 60,
+ aws_conn_id: str | None = "aws_default",
**kwargs,
):
+ if delay is not None:
+ warnings.warn(
+ "please use waiter_delay instead of delay.",
+ AirflowProviderDeprecationWarning,
+ stacklevel=2,
+ )
+ waiter_delay = delay or waiter_delay
+ if max_attempts is not None:
+ warnings.warn(
+ "please use waiter_max_attempts instead of max_attempts.",
Review Comment:
```suggestion
"please use `waiter_max_attempts` instead of max_attempts.",
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org