Repository navigation
Add Hugging Face Provider - #76317
Conversation
|
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.
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:
Happy to review if you pick this up, here or in a follow-up PR. |
Thank you for reaching out and for the support. Currently, I would prefer to finalize the HF provider's public API and focus on the features stated in the mailing list. I've created an issue for the requested feature and will certainly ask for your feedback in a follow up PR. Regards, Parag Ekbote |
… the doc errors, update the wordlist and add tags for get_provider_info.py
- Keep the split name on zero-row artifact splits, so an empty split is not published as `train`. - Drop the `hf://datasets/<repo>` outlet for pull request and non-main pushes in `__init__`, so a mapped task with expanded `push_kwargs` no longer emits the repo-level asset event. - Remove the post-push commit lookups: `push_to_hub` to a dataset repo always returns a `CommitInfo` on datasets>=5.0. - Define `get_ui_field_behaviour` on the hook for Airflow 3.0 and 3.1, which do not read `ui-field-behaviour` from provider.yaml. - Move `asset.py` to `assets/huggingface.py`, drop `tests/__init__.py` and `tests/system/README.md`, and hoist the `re` import. - Use the standard provider changelog template, list `LargeList` in the artifact docs, and apply the prek fixes (license headers, ruff, pyproject ordering, system test segments).
There was a problem hiding this comment.
Pushed the remaining fixes on top (empty split label, PR-push outlets on mapped tasks, get_ui_field_behaviour for 3.0/3.1, assets/ move, changelog template, prek). LGTM, thanks @ParagEkbote! The uv.lock downgrade gets a relock in a follow-up once datasets 5.2.0 clears the cooldown.
`check-provider-yaml-valid` skips `index.rst` pages when it collects the expected how-to guides, so a `how-to-guide` entry pointing at `operators/index.rst` never matches and the static check fails.
`Asset` is not hashable on Airflow 3.0, so the test can't key a dict by the published asset. Pass an outlet-events object with `__getitem__`, as the other publication tests in this module do.
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
Based on the following ASF discuss thread, this PR adds the HF Provider for Apache Airflow. The following tasks need to be completed along with the reviewer comments:
Was generative AI tooling used to co-author this PR?
Codex
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.