Skip to content

Conversation

@dabla
Copy link
Contributor

@dabla dabla commented Jan 13, 2026

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Refactored HttpAsyncHook to easily support session based operations.

Instead of having to do this:

    @task(
        retries=3,
        retry_delay=timedelta(seconds=60),
        show_return_value_in_logs=True,
    )
    async def fetch_forms(project_id: int):
        from aiohttp import ClientSession
        from functools import partial

        from airflow.providers.http.hooks.http import HttpAsyncHook

        auth_type = partial(BearerTokenAuth, url="https://localhost/v1/sessions")
        hook = HttpAsyncHook(http_conn_id="http_conn_id", auth_type=auth_type, method="GET")

        async with ClientSession() as session:
            response = await hook.run(
                session=session,
                endpoint=f"v1/projects/{project_id}/forms",
            )
            return await response.json()

You will be able to do this instead:

    @task(
        retries=3,
        retry_delay=timedelta(seconds=60),
        show_return_value_in_logs=True,
    )
    async def fetch_forms(project_id: int):
        from functools import partial

        from airflow.providers.http.hooks.http import HttpAsyncHook

        auth_type = partial(
            BearerTokenAuth, url="https://localhost/v1/sessions"
        )
        hook = HttpAsyncHook(
            http_conn_id="http.odk.acc", auth_type=auth_type, method="GET"
        )

        async with hook.session() as session:
            response = await session.run(
                endpoint=f"v1/projects/{project_id}/forms",
            )
            return await response.json()

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant