Return a shared HfApi instance tagged with transformers's library info. Routing Hub calls (create_repo, create_commit, snapshot_download, ...) through this instance ensures the library_name/library_version are reported consistently to the Hub.
()
| 74 | |
| 75 | |
| 76 | def hf_api() -> HfApi: |
| 77 | """Return a shared HfApi instance tagged with transformers's library info. |
| 78 | |
| 79 | Routing Hub calls (create_repo, create_commit, snapshot_download, ...) through this |
| 80 | instance ensures the library_name/library_version are reported consistently to the Hub. |
| 81 | """ |
| 82 | global _hf_api |
| 83 | if _hf_api is None: |
| 84 | _hf_api = HfApi( |
| 85 | library_name="transformers", |
| 86 | library_version=__version__, |
| 87 | ) |
| 88 | return _hf_api |
| 89 | |
| 90 | |
| 91 | class DownloadKwargs(TypedDict, total=False): |
no outgoing calls
no test coverage detected