-
Notifications
You must be signed in to change notification settings - Fork 556
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
Use dataclasses
for all objects returned by HfApi
#1911
Comments
Hello mario, i would like to do this task, is it possible ? |
Hi @NouamaneELGueddarii! Thanks for proposing yourself! It is possible to take this task yes. Just to be sure we are aligned, the goal is to update a bunch of objects in
def __post_init__(self):
# hack to make BlobLfsInfo backward compatible
self.update(asdict(self))
What I would suggest you is to start working on just 1 or 2 classes and open a PR for them. This way we can iterate on it and answer your questions (if any). What do you think? Thanks in advance! EDIT: based on #1974 (review), I've updated the instructions above to fit better inside the current codebase |
@Wauplin is it fine if I start working on it? I want to start making open source contribution to github. |
Hi @Ahmedniz1, yes it is! Thanks for proposing you. Please refer to #1911 (comment) on how to deal with it.
🚀 🚀 🚀 |
@Wauplin I'll start working at the BlobLfsInfo class first, will make a PR once I get it done. If it is approved I can replicate it for the remaining ones and make another PR. |
Sounds like a plan! |
@Wauplin i will be working on the following class "TransformersInfo". I will make a PR and wait for approval then proceed to work on the others. |
Great! Thanks for confirming @NouamaneELGueddarii! |
@Ahmedniz1, saw it and just reviewed it! Thanks! |
@Ahmedniz1 @NouamaneELGueddarii I have updated the instructions on how to proceed with the issue. I'm sorry about this late change but I realized the previous recommendations were working correctly. I've commented on @Ahmedniz1's PR here (#1974 (review)) and updated the comment above (#1911 (comment)). Hopefully, this will make it easier to integrate new dataclasses while keeping backward compatibility. |
* converted bloblfsinfo from typed_dict to dataclass * updated bloblfs to dataclass * adding post_init to bloblfs class * Update src/huggingface_hub/hf_api.py --------- Co-authored-by: ahmdayyy <ahmednizamani36.com> Co-authored-by: Lucain <[email protected]>
@Wauplin I'm trying to update in the previous PR but it appears to be closed. I can push the updates for other classes(apart from transformerinfo) once the original PR is open again. |
Yes this is expected! You have to checkout to |
Thanks to @NouamaneELGueddarii in #1993, Thanks @Ahmedniz1 and @NouamaneELGueddarii for your contributions on this one! Issue can be closed 🎉 |
Currently, we use
TypedDict
to represent some of the objects' attributes returned by theHfApi
methods. To be consistent, we should only usedataclasses
, as suggested in #1809 (comment):This work can be split in several PRs to make it easier to implement and review.
The text was updated successfully, but these errors were encountered: