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

[CLI] Support tag management (create, list, delete) #2141

Closed
Wauplin opened this issue Mar 22, 2024 · 3 comments · Fixed by #2172
Closed

[CLI] Support tag management (create, list, delete) #2141

Wauplin opened this issue Mar 22, 2024 · 3 comments · Fixed by #2172
Assignees
Labels
CLI good first issue Good for newcomers

Comments

@Wauplin
Copy link
Contributor

Wauplin commented Mar 22, 2024

Requested in #960 (comment).

Similar to #1655 (branch management from CLI)

@bilgehanertan
Copy link
Contributor

I would like to take this issue, but I have some questions about it.

To my understanding, I will be using api.create_tag, api.delete_tag, yet there is no specific list_tag API endpoint. There are only api.get_dataset_tags and api.get_model_tags which seem to be returning pre-defined valid model/dataset tags. How can I implement the list functionality?

@Wauplin
Copy link
Contributor Author

Wauplin commented Mar 29, 2024

Hi @bilgehanertan, thanks again for proposing your contribution on this topic!

To list tags, branches and PR references, you can use list_repo_refs like this:

>>> from huggingface_hub import list_repo_refs
>>> list_repo_refs("bigcode/the-stack", repo_type="dataset")
GitRefs(
    branches=[
        GitRefInfo(name='main', ref='refs/heads/main', target_commit='349a71353fd5868fb90b593ef09e311379da498a'),
        GitRefInfo(name='v1.2', ref='refs/heads/v1.2', target_commit='5d3ecf104981e98be039c6b397ed479916fcd767'),
        GitRefInfo(name='v1.1.a1', ref='refs/heads/v1.1.a1', target_commit='f9826b862d1567f3822d3d25649b0d6d22ace714')
    ],
    converts=[
        GitRefInfo(name='parquet', ref='refs/convert/parquet', target_commit='2b04cb882b107dd808e084c70c08383fa2f342f4')
    ],
    tags=[
        GitRefInfo(name='v1.0', ref='refs/tags/v1.0', target_commit='c37a8cd1e382064d8aced5e05543c5f7753834da'),
        GitRefInfo(name='v1.1', ref='refs/tags/v1.1', target_commit='20984ef8dc055c571093bf4b6235233ac6cb4596'),
        GitRefInfo(name='v1.2', ref='refs/tags/v1.2', target_commit='93fc1897d4405b5bfdd5ffaccadfc690f3fd198c')
    ],
    pull_requests=None
)

@bilgehanertan
Copy link
Contributor

Hi @bilgehanertan, thanks again for proposing your contribution on this topic!

To list tags, branches and PR references, you can use list_repo_refs like this:

>>> from huggingface_hub import list_repo_refs
>>> list_repo_refs("bigcode/the-stack", repo_type="dataset")
GitRefs(
    branches=[
        GitRefInfo(name='main', ref='refs/heads/main', target_commit='349a71353fd5868fb90b593ef09e311379da498a'),
        GitRefInfo(name='v1.2', ref='refs/heads/v1.2', target_commit='5d3ecf104981e98be039c6b397ed479916fcd767'),
        GitRefInfo(name='v1.1.a1', ref='refs/heads/v1.1.a1', target_commit='f9826b862d1567f3822d3d25649b0d6d22ace714')
    ],
    converts=[
        GitRefInfo(name='parquet', ref='refs/convert/parquet', target_commit='2b04cb882b107dd808e084c70c08383fa2f342f4')
    ],
    tags=[
        GitRefInfo(name='v1.0', ref='refs/tags/v1.0', target_commit='c37a8cd1e382064d8aced5e05543c5f7753834da'),
        GitRefInfo(name='v1.1', ref='refs/tags/v1.1', target_commit='20984ef8dc055c571093bf4b6235233ac6cb4596'),
        GitRefInfo(name='v1.2', ref='refs/tags/v1.2', target_commit='93fc1897d4405b5bfdd5ffaccadfc690f3fd198c')
    ],
    pull_requests=None
)

Got it! I will be starting it asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants