Skip to content
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

Remove GithubOperator use in GithubSensor.__init__() #24214

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions airflow/providers/github/sensors/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from github import GithubException

from airflow import AirflowException
from airflow.providers.github.operators.github import GithubOperator
from airflow.providers.github.hooks.github import GithubHook
from airflow.sensors.base import BaseSensorOperator

if TYPE_CHECKING:
Expand Down Expand Up @@ -54,16 +54,15 @@ def __init__(
self.result_processor = result_processor
self.method_name = method_name
self.method_params = method_params
self.github_operator = GithubOperator(
task_id=self.task_id,
github_conn_id=self.github_conn_id,
github_method=self.method_name,
github_method_args=self.method_params,
result_processor=self.result_processor,
)

def poke(self, context: 'Context') -> bool:
return self.github_operator.execute(context=context)
hook = GithubHook(github_conn_id=self.github_conn_id)
github_result = getattr(hook.client, self.method_name)(**self.method_params)

if self.result_processor:
return self.result_processor(github_result)

return github_result


class BaseGithubRepositorySensor(GithubSensor):
Expand Down