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

[Feat] Endpoint configure gating on a repo #2447

Closed
Wauplin opened this issue Aug 14, 2024 · 5 comments
Closed

[Feat] Endpoint configure gating on a repo #2447

Wauplin opened this issue Aug 14, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Wauplin
Copy link
Contributor

Wauplin commented Aug 14, 2024

It's possible to add a gate to a repo programmatically. It's used in the Open LLM Leaderboard for instance (see slack -internal-). It can be done like this:

from huggingface_hub.utils import build_hf_headers, get_session, hf_raise_for_status

headers = build_hf_headers()

r = get_session().put(
    url=f"https://huggingface.co/api/datasets/{repo_id}/settings",
    headers=headers,
    json={"gated": "auto"},
)
hf_raise_for_status(r)

Value can be "auto", "manual" or False.

It would be nice to add it as a new method in HfApi.

@Wauplin Wauplin added the enhancement New feature or request label Aug 14, 2024
@Wauplin Wauplin added the good first issue Good for newcomers label Aug 29, 2024
@WizKnight
Copy link
Contributor

Yeah @Wauplin, this method to add a gate to repo programmatically can give more flexibility to adapt and access control for project needs, plus automating this process can streamline the workflow and reduce the manual effort for evaluation phase.
Let me know if I'm going in the right direction??

@Wauplin
Copy link
Contributor Author

Wauplin commented Aug 30, 2024

Yes, that's exactly the goal! There are two main objectives:

  • automate workflow when many repos are created by a script and needs to be gated (example: for the LLM Leaderboard)
  • automate tests when you need a gated repo to test a feature

@WizKnight
Copy link
Contributor

Alright, I got it.
So how should we move ahead with this?

@Wauplin
Copy link
Contributor Author

Wauplin commented Aug 30, 2024

So what you'll need to do is:

  • add a new method update_repo_settings(self, repo_id: str, *, gated: Optional[Literal["auto", "manual", False]] = None, ...)
  • implement this method. You can take a look at update_repo_visibility as an example.
  • implement some tests in tests/test_hf_api.py. You can check existing tests as an example
  • add a section in docs/source/en/guides/repository.md to mention this feature and how to use it

And that's it! If you have questions just let me know. You can always open a draft PR with only a subset of what I've mentioned above if you want a confirmation you are in the good direction.

hanouticelina pushed a commit that referenced this issue Sep 12, 2024
* [Feature] Update Repo Settings

* resolve merge conflicts

* fix merge issue

* merge issues

* Add `update_repo_settings` function to HfApi

* Add `update_repo_settings` function to HfApi

* Enhance HfApi with `update_repo_settings` function

* Enhance HfApi with `update_repo_settings` function

* Enhance HfApi with `update_repo_settings` function

* Enhance HfApi with `update_repo_settings` function

* Enhance HfApi with `update_repo_settings` function

* Apply suggestions from code review

---------

Co-authored-by: Lucain <lucain@huggingface.co>
Co-authored-by: Lucain Pouget <lucainp@gmail.com>
@Wauplin
Copy link
Contributor Author

Wauplin commented Sep 13, 2024

Closed by #2502. Thanks @WizKnight !

@Wauplin Wauplin closed this as completed Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants