-
Notifications
You must be signed in to change notification settings - Fork 571
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
Implement webhooks API #2209
Implement webhooks API #2209
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Thanks @lappemic! I didn't have a look yet to your changes but to answer your question:
Also 2 comments about the changes:
|
Thanks for the quick response, @Wauplin!
@dataclass
class WatchedItem:
"""Data structure containing informatin about webhooks watched for updates.
Attributes:
type (`Literal["dataset", "model", "org", "space", "user"]`):
Type of the item to be watched. Can be one of `["dataset", "model", "org", "space", "user"]`.
name (`str`):
Name of the item to be watched. Can be the username, organization name, model name, dataset name or space name.
"""
type: Literal["dataset", "model", "org", "space", "user"]
name: str
Appreciate your guidance and looking forward to your thoughts! |
Yes!
Exactly! That will be easier to use for users downstream
Hmm that's weird. I would assume something's off with the install. Are you using a virtualenv? If no, I'd advice to create a new one (installing Python3.9 or 3.10 in it) and install the dependencies in it. You can check install guidelines here: https://huggingface.co/docs/huggingface_hub/installation#install-with-pip (you'll need an editable install from source in a virtual env) |
Thank you for the feedback! I've updated the PR with the latest commits, according to your suggestions. Regarding the styling issues, I initially followed the steps outlined in the repo's CONTRIBUTING.md without success. Then, I set up a new virtual environment and followed the installation instructions from https://huggingface.co/docs/huggingface_hub/installation#install-with-pip, which worked now. The only difference is the `[dev]' notation. I assume this should not make any difference? Looking forward to your review and approval to continue. |
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.
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.
Thanks for the PR @lappemic! I just reviewed it and made high level comment to it. The structure is good and I think you can continue on that. Sometimes I commented on a specific method but the comment can be applied to all comment.
As you can see, I also pushed commits to fix styling stuff. Make sure not to push changes that are unrelated to your PR, otherwise it makes the review very difficult (I have to "check" if a change is related to your PR or to some styling). If you correctly install the [dev]
dependencies + run make style
, it shouldn't happen. Anyway, let me know if you have questions related to this. And don't forget to git pull
before starting to make changes.
Thanks you very much for the proper review and inputs @Wauplin. I hope to find time to incorporate everything this week. It might take up to next week though. |
Thanks @lappemic! And no worries about the timing, days are always too busy 😄 |
Hey @Wauplin, found some time to implement your feedback. I was not quite sure if As soon as the main changes are alright, i will implement the tests and extend the documentation accordingly. PS. Sorry for the style mess in the previous commits!! 🙈 |
Hi @Wauplin, I have included the changes based on your feedback and fixed some issues in the last commits:
Additionally I verified the return values of Let me know if this looks good or if i can adjust something. Looking forward to your 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 @lappemic! Everything looks good implementation-wise now :) I left minor comments but that's all.
Last but not least, could you add some documentation to let users know about this new feature? Here is what I would do:
- rename https://huggingface.co/docs/huggingface_hub/guides/webhooks_server to https://huggingface.co/docs/huggingface_hub/guides/webhooks
- add a first section about how to manage webhooks: create, list, enable/disable, delete. Basically the same information / examples as in the docstring but more in the form of a user guide.
- move all the current content of Webhooks Server inside a Webhook Server section in the same page
- add a redirection from https://huggingface.co/docs/huggingface_hub/guides/webhooks_server to https://huggingface.co/docs/huggingface_hub/guides/webhooks => I show you this once the rest is done. It is to avoid breaking previous urls. (see _redirects.yml.
In practice it means:
- renaming webhooks_server.md to
webhooks.md
- updating the toctree.yml
- add content in
webhooks.md
- add
WebhookInfo
andWebhookWatchedItem
to the listed dataclasses in the package reference
Please let me know if that's fine for you and if you have any questions. That would make a complete PR for a new feature, from implementation to testing to documenting it. Thanks!
Thanks a lot @Wauplin! I would love to finish this off with the added documentation. I ping you asap it's implemented. |
@Wauplin in the last commits i have
I first was confused about the |
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.
Thanks a ton for the changes @lappemic! I finally reviewed the last detailed and pushed a few modifications in e60bbc8 (mostly to fix code styling in CI + switch the 2 sections in the guide). Looks good now so I'll merge it now. Failing tests in the CIs are unrelated to your PR. Thanks again for the hard work! This is a very nice addition! 🔥
(and sorry for the long delay, I was off in May 🤗)
No worries, well deserved time off i would say! 😄 Thanks a lot for the guidance and help on this @Wauplin! I really enjoyed the process! |
Hey @Wauplin, here's the initial draft for #1808, trying to align with #1905 as you suggested. However, a couple of points are still unclear to me, and I'd love to get your input to ensure the implementation aligns correctly:
secret
parameter represents increate_webhook
andupdate_webhook
methods? Is it intended to be the user token?DOMAIN_T
Literal, would it be appropriate to define it directly within the function signatures?I plan to finalize docstrings, module imports, and tests once we're on the same page regarding these questions.
Thanks a lot for your guidance and feedback!