-
Notifications
You must be signed in to change notification settings - Fork 613
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
Write Mixins/Integration guide #1362
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.
Overall looks good! I'm not convinced of making this the officially recommended way of integrations though
docs/source/guides/integrations.mdx
Outdated
In most cases, a library already implements its model using a Python class. The class contains the properties of the model | ||
and methods to load, run, train, evaluate,... it. It would be nice to extend the class with the 2 new methods! | ||
|
||
The recommended approach to do so is to use inheritance, and more precisely mixins. A [Mixin](https://stackoverflow.com/a/547714) |
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.
Do we want to make this the official recommended approach? This is more complex/scary than the usually push to hub/download_from_hub with the HTTP endpoints and requires having classes in their libraries
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.
Really nice, I love the link to the guide from the docstring!
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.
I loved the guide, just left some nits
Thank you very much @osanseviero @merveenoyan @stevhliu for the detailed review, it's really appreciated. Apart from all the small suggestions that I will follow (I feel that half of the guide is rewritten, and I'm glad it is the case! 😄), the main question is "do we want to brand that as our recommended way to integration a library"? I think what I'll do is to re-arrange a bit the guide:
|
I think that's a great idea! Having a table concisely describing the pros/cons of both approaches would also be super nice to have |
Good idea! 🔥 |
Co-authored-by: Omar Sanseviero <[email protected]> Co-authored-by: Steven Liu <[email protected]> Co-authored-by: Merve Noyan <[email protected]>
Co-authored-by: Merve Noyan <[email protected]> Co-authored-by: Steven Liu <[email protected]> Co-authored-by: Omar Sanseviero <[email protected]>
Co-authored-by: Steven Liu <[email protected]>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1362 +/- ##
==========================================
- Coverage 84.53% 84.53% -0.01%
==========================================
Files 48 48
Lines 4812 4810 -2
==========================================
- Hits 4068 4066 -2
Misses 744 744
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@osanseviero @stevhliu @merveenoyan Following my last comment, I made some changes to the guide:
Let me know if you have new feedback :) |
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.
Great job and the table is awesome!
This is of course only an example. If you are interested in more complex manipulations (delete remote files, upload | ||
weights on the fly, persist weights locally,...) please refer to the [upload files](./upload) guide. | ||
|
||
### Limitations |
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.
I'd move the Limitations section above the from_pretrained
method. I think it'd be nice to have a full picture of the pros/cons of using this approach before actually trying to implement it.
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.
I understand your point but I think it could be confusing to users -at least with the text I wrote-. If I move the "limitations" section up, the reader would not really have in mind the method signatures/implementation that I already list everything that is missing from it.
What I can do is to add a sentence in the introduction to say "hey, we will see 2 different approaches, each of them have advantages/drawbacks so choose what's best for you". So that when the user reads the first approach he/she already have in mind that there are some limitations (without knowing which ones yet). What do you think?
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.
Great idea! 👍
Co-authored-by: Steven Liu <[email protected]>
@stevhliu Thanks again for the detailed review! I've addressed all of your comments (see above about the limitations section). I think we are close to have a final version to merge :) |
Merging this! |
The table is amazing! 🔥 |
Resolve #1333 (from @NielsRogge 's suggestion in private slack).
This PR adds a new guide page "Integrate any ML framework with the Hub". Contains:
ModelHubMixin
. How to use it?PyTorchHubMixin
: how to use it and how has it been implemented(+ edited some docstrings)
Writing this guide made me realize we can even improve further the
ModelHubMixin
class, especially for cases where we want to delete files from the Hub (when pushing multiple times). This is done separately in the Keras integration to replace training logs. I think we update change this once #1352 is implemented.(Note: failing tests are unrelated to this PR)