-
Notifications
You must be signed in to change notification settings - Fork 570
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
List branches and tags from a repo #1276
Conversation
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clean PR, love it!
@@ -2449,6 +2449,41 @@ def test_request_space_hardware(self, post_mock: Mock) -> None: | |||
) | |||
|
|||
|
|||
class ListRepoRefsTest(unittest.TestCase): | |||
@classmethod | |||
@with_production_testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart to only define it on the setUpClass
for it to act on all subsequent methods. I wonder if it wouldn't be cleaner to put it on the class itself so that it's very clear that it should affect the entire class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I did that as a workaround because
@with_production_testing
class ListRepoRefsTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
was not working for me 😢
But I have to admit my debug time on that was approximately 30s, just the time to try some possibilities and take the first one that worked 🙄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha in that case we can also keep it there, it was just a nit, to be fair.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just left a small nit on naming
src/huggingface_hub/hf_api.py
Outdated
target_commit: str | ||
|
||
@classmethod | ||
def from_dict(cls, data: Dict) -> "RefInfo": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're not just overriding the init from dataclass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(dont remember the best practice in Python dataclasses)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep why not. Best practice depends on your use case I guess.
Here the GitRefs
will never be initialized by someone else than use from server-side data so it makes sense to put it in the init. It's not good practice when you force the users to have your data format as input instead of letting the default dataclass constructor. (at least IMO)
Resolve #1260 (cc @antoche).
List branches, tags and "converts" from a repo on the Hub. Implemented, tested and documented the
list_repo_refs
method +RepoRefs
data structure.I did not document extensively what the
convert
ref is as I don't expect much usage of this inhfh
(see docs)