Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HfApi.endpoint should be configurable in Repository #808

Closed
SBrandeis opened this issue Mar 30, 2022 · 6 comments · Fixed by #815
Closed

HfApi.endpoint should be configurable in Repository #808

SBrandeis opened this issue Mar 30, 2022 · 6 comments · Fixed by #815
Labels
API enhancement New feature or request

Comments

@SBrandeis
Copy link
Contributor

user = HfApi().whoami(self.huggingface_token)

We should be able to pass arguments to HfApi() from Repository

@SBrandeis SBrandeis added the enhancement New feature or request label Mar 30, 2022
@adrinjalali
Copy link
Contributor

@SBrandeis could you please explain further what the usecase is, and share a bit of code which would use the arguments? It helps with designing the API.

@SBrandeis
Copy link
Contributor Author

I'm using huggingface_hub in AutoTrain to handle repo creation / cloning

My local version of AutoTrain uses a local version of the HF Hub to store and manipulate repos. The URL of the local HF Hub is not https://huggingface.co but rather http://localhost:PORT

Currently huggingface_hub assumes the URL to the HF Hub is https://huggingface.co, and I have to implement ugly hacks as the one following to make it work:

import os
import huggingface_hub

# I have to override ENDPOINT
HF_HUB_URL = "http://localhost:PORT"
huggingface_hub.constants.ENDPOINT = HF_HUB_URL
huggingface_hub.hf_api.ENDPOINT = HF_HUB_URL
huggingface_hub.repository.ENDPOINT = HF_HUB_URL

# Even worse:
clone_url = f"http://user:{hf_token}@{HF_HUB_URL[len('http://'):]}/datasets/user/dataset_name"
repo = huggingface_hub.Repository(local_dir=".", clone_from=clone_url, use_auth_token=hf_token)

I would like to be able to configure the URL of the HF Hub when using huggingface_hub

@SBrandeis
Copy link
Contributor Author

SBrandeis commented Mar 31, 2022

I'm happy to open a PR if it makes sense to add this to the library

@LysandreJik
Copy link
Member

It's a reasonable asumption which would also unblock on-prem efforts as seen in #650 and huggingface/transformers#15514

@LysandreJik
Copy link
Member

Related to #798

@adrinjalali
Copy link
Contributor

Looks quite reasonable to me. Happy to review the PR if you're kind enough to open one @SBrandeis :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants