-
Notifications
You must be signed in to change notification settings - Fork 16.4k
uniformize getting hook through cached property in aws sensors #29001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| from typing import TYPE_CHECKING, Sequence | ||
|
|
||
| from airflow.compat.functools import cached_property | ||
| from airflow.exceptions import AirflowException | ||
| from airflow.providers.amazon.aws.hooks.glue import GlueJobHook | ||
| from airflow.sensors.base import BaseSensorOperator | ||
|
|
@@ -61,10 +62,13 @@ def __init__( | |
| self.errored_states: list[str] = ["FAILED", "STOPPED", "TIMEOUT"] | ||
| self.next_log_token: str | None = None | ||
|
|
||
| @cached_property | ||
| def hook(self): | ||
| return GlueJobHook(aws_conn_id=self.aws_conn_id) | ||
|
||
|
|
||
| def poke(self, context: Context): | ||
| hook = GlueJobHook(aws_conn_id=self.aws_conn_id) | ||
| self.log.info("Poking for job run status :for Glue Job %s and ID %s", self.job_name, self.run_id) | ||
| job_state = hook.get_job_state(job_name=self.job_name, run_id=self.run_id) | ||
| job_state = self.hook.get_job_state(job_name=self.job_name, run_id=self.run_id) | ||
| job_failed = False | ||
|
|
||
| try: | ||
|
|
@@ -80,7 +84,7 @@ def poke(self, context: Context): | |
| return False | ||
| finally: | ||
| if self.verbose: | ||
| self.next_log_token = hook.print_job_logs( | ||
| self.next_log_token = self.hook.print_job_logs( | ||
| job_name=self.job_name, | ||
| run_id=self.run_id, | ||
| job_failed=job_failed, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.