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

fix: airflow sensor tasks, add timeout in request call #148

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 6 additions & 4 deletions ext/scheduler/airflow/__lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def execute(self, context):


class OptimusAPIClient:
def __init__(self, optimus_host):
def __init__(self, optimus_host, timeout):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would require changes in other places as well, otherwise this will result in
missing required positional argument: 'timeout'

self.host = self._add_connection_adapter_if_absent(optimus_host)
self.timeout = timeout

def _add_connection_adapter_if_absent(self, host):
if host.startswith("http://") or host.startswith("https://"):
Expand All @@ -88,7 +89,7 @@ def get_job_run(self, project_name: str, job_name: str, start_date: str, end_dat
'end_date': end_date,
'downstream_project_name': downstream_project_name,
'downstream_job_name': downstream_job_name
})
}, timeout=self.timeout)
self._raise_error_if_request_failed(response)
return response.json()

Expand Down Expand Up @@ -192,6 +193,7 @@ def __init__(
upstream_optimus_project: str,
upstream_optimus_namespace: str,
upstream_optimus_job: str,
timeout: int,
BitWielderSumit marked this conversation as resolved.
Show resolved Hide resolved
*args,
**kwargs) -> None:
kwargs['mode'] = kwargs.get('mode', 'reschedule')
Expand All @@ -201,8 +203,8 @@ def __init__(
self.upstream_optimus_project = upstream_optimus_project
self.upstream_optimus_namespace = upstream_optimus_namespace
self.upstream_optimus_job = upstream_optimus_job
self._optimus_client = OptimusAPIClient(optimus_hostname)
self._upstream_optimus_client = OptimusAPIClient(upstream_optimus_hostname)
self._optimus_client = OptimusAPIClient(optimus_hostname, timeout)
self._upstream_optimus_client = OptimusAPIClient(upstream_optimus_hostname, timeout)

def poke(self, context):
job_cron_iter = croniter(context.get("dag").schedule_interval, context.get('execution_date'))
Expand Down