Add async support in `apache-airflow-client`
Description
Currently, the apache-airflow-client package (generated from the openapi-generator-cli) uses the default urllib3 client, which does not support async operations.
The proposed feature is to generate and package async client code in the apache-airflow-client package, in addition to the existing synchronous client code.
Ideally, this should not alter the synchronous interface to ensure this is not a breaking change.
Use case/motivation
Async client usage is particularly helpful for users who either:
- Need to perform independent API operations in a single process (such as a bulk "pause dags" operation).
- Manage multiple Airflow instances, and require multi-plexing requests across instances (e.g. a management script which updates the same Airflow variables across multiple Airflow instances at once).
- This is a situation I'm currently using async api calls for, but with httpx2 directly, rather than with the official Apache Airflow python client. It would be really nice to have the additional type safety the official client offers, and I'm sure this would benefit others as well.
As noted above, urllib3 is the current client used in the client generation tool, but the upcoming release of openapi-generator-cli version 7.26.0 will support for generating code which uses httpx2 under the hood. httpx2 supports both sync and async operations. Additionally, the openapi-generator-cli has configuration options to generate code with both sync and async code in the same output package.
Both the httpx2 and async code generation config options are described here: https://openapi-generator.tech/docs/generators/python/#config-options
Related issues
Tangentially related: https://github.com/apache/airflow/issues/70522
- context:
httpxis apparently no longer actively maintained, and Pydantic'shttpx2is the replacement that appears to have taken the designation as the python community's "accepted" replacement.
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: apache/airflow