Hub Python Library documentation

huggingface_hub v2.0으로 마이그레이션

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

huggingface_hub v2.0으로 마이그레이션

huggingface_hub v2.0은 HTTP 의존성을 httpx2로 대체하고, 더 이상 사용되지 않는 1.x API를 제거합니다. HTTP 클라이언트와 예외는 이제 별도의 패키지에서 제공됩니다.

huggingface_hub v1.x(v1.30.0부터)과 v2.x를 모두 지원하기 위해 huggingface_hub.utils에서 HTTP 모듈을 가져옵니다:

from huggingface_hub.utils import get_session, httpx

try:
    response = get_session().get("https://huggingface.co/api/models/gpt2")
    response.raise_for_status()
except httpx.HTTPError:
    ...

set_client_factory() 또는 set_async_client_factory()에 대한 커스텀 클라이언트를 생성할 때에도 동일한 import를 사용하세요. 기존 HTTP 패키지의 클라이언트와 예외는 httpx2의 것과 구별되며, 서로 교환하여 사용할 수 없습니다.

httpx2는 기본적으로 운영 체제의 인증서 신뢰 저장소를 사용합니다. SSL_CERT_FILE 또는 SSL_CERT_DIR로 구성된 사용자 지정 CA 번들은 여전히 지원됩니다. 로깅 구성은 이전 로거 이름 대신 httpx2와 httpcore2를 대상으로 해야 합니다. 자세한 내용은 업스트림 마이그레이션 가이드를 참조하세요.

oauth 추가 항목은 이제 httpx2 지원을 위해 authlib>=1.8.0을 요구합니다.

비추천 API 제거

  • upload_large_folder 또는 HfApi.upload_large_folder 대신 upload_folder를 사용하세요.
  • duplicate_space, request_space_storage, delete_space_storage 대신 duplicate_repo, set_space_volumes, delete_space_volumes를 사용하세요.
  • repo_type_and_id_from_hf_id 대신 parse_hf_uri를, model_name=... 대신 list_models(search=...)를 사용하세요.
  • create_repo와 duplicate_repo에서 space_storage 대신 space_volumes를 사용하세요.
  • PROTECTED 또는 type="protected" 대신 InferenceEndpointType.AUTHENTICATED 또는 type="authenticated"를 사용하세요.
  • stop_sequences=... 대신 text_generation(stop=...)를 사용하고, boolean 대신 토큰 문자열 또는 None을 InferenceClient에 전달하세요.
  • hf를 huggingface-cli 대신 사용하세요. hf repo와 hf repo-files delete는 각각 hf repos와 hf repos delete-files로 대체되었습니다.
  • hf upload-large-folder 대신 hf upload를, 저장소 생성 및 복제 시 --storage 대신 --volume를, 그리고 hf jobs ps --filter 대신 --status 또는 --label를 사용하세요.
  • hf skills add 및 hf skills update의 비추천 --claude 옵션이 제거되었습니다. Skills는 Claude Code에 자동으로 설치됩니다.

자세한 내용은 httpx2 프로젝트, httpx2 문서, httpx에서 httpx2로의 전환 가이드, 그리고 huggingface_hub 전환 계획을 참고하세요.

Update on GitHub