Repository navigation
Description
Description
Thanks for this, nice to see a Hugging Face provider coming in!
One suggestion for the hook: add native async variants of the metadata calls, so they can be used from async tasks and triggers without blocking the event loop. Deferrable operators aren't needed for this, async methods on the hook are enough.
HfApi itself is sync only, but huggingface_hub already ships what's needed: huggingface_hub.utils.get_async_session() returns the configured httpx.AsyncClient that AsyncInferenceClient uses, and the Hub endpoints behind the current methods are plain REST calls:
| Hook method | HfApi call |
Endpoint |
|---|---|---|
get_dataset_info |
dataset_info |
GET /api/datasets/{repo_id}[/revision/{revision}] |
find_commit_by_marker |
list_repo_refs |
GET /api/datasets/{repo_id}/refs?include_prs=1 |
find_commit_by_marker |
list_repo_commits |
GET /api/datasets/{repo_id}/commits/{revision} (paginated) |
Something along these lines:
from urllib.parse import quote
from huggingface_hub import DatasetInfo, constants
from huggingface_hub.utils import build_hf_headers, get_async_session, hf_raise_for_status
from airflow.providers.common.compat.connection import get_async_connection
async def aget_dataset_info(self, repo_id: str, revision: str | None = None) -> DatasetInfo:
connection = await get_async_connection(self.huggingface_conn_id, hook=self)
url = f"{constants.ENDPOINT}/api/datasets/{repo_id}"
if revision:
url += f"/revision/{quote(revision, safe='')}"
async with get_async_session() as client:
response = await client.get(url, headers=build_hf_headers(token=connection.password))
hf_raise_for_status(response)
return DatasetInfo(**response.json())Two things to watch for:
- The token has to come from
get_async_connection(common.compat): calling the syncget_token()/get_connection()inside a coroutine blocks the event loop and can deadlock on the supervisor channel. - Building
DatasetInfo/GitCommitInfofrom the JSON (asHfApidoes internally) keeps the async methods returning the same types as the sync ones, so_commit_is_completeand the marker matching can be shared between both paths.
load_dataset and push_to_hub can stay sync, since datasets has no async API and those are file transfers anyway. When Inference Endpoints are added later, AsyncInferenceClient would give the async side of that for free.
Happy to review if you pick this up, here or in a follow-up PR.
Originally posted by @dabla in #76317 (comment)
Use case/motivation
No response
Related issues
No response
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
Activity
Priyeshshrivastav commentedon Nov 5, 2026
Hi @ParagEkbote,
I went through the issue and your ongoing Hugging Face provider PR.
I'd be interested in contributing to the async metadata methods once the provider's public API is finalized.
I have experience with Python, async programming, backend development, and API integration. I'd be happy to help implement
aget_dataset_info()andafind_commit_by_marker(), along with tests ensuring compatibility with the existing synchronous methods.Please let me know when this work is ready for community contributions. I'd be glad to help!
Thanks!
ParagEkbote commentedon Nov 12, 2026
Thanks for your interest in contributing for the hf provider. The provider is now open for community contributions
A few things to keep in mind before opening the PR:
ASF contribution guidelines: Please follow the Apache Airflow contributing guidelines including the project's coding conventions, testing requirements, licensing expectations and Code of Conduct.
AI-assisted development: If you use AI coding tools, please follow the ASF Generative Tooling Guidance. In particular, ensure that you understand and have personally reviewed all submitted code.
Please open a PR against the Apache Airflow repository and link it to this issue
Regards,
Parag Ekbote
Anurag-S1ngh commentedon Nov 14, 2026
Hi, I'm working on this. I'll add async variants of the metadata calls (aget_dataset_info, afind_commit_by_marker) with tests.