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

Implement webhooks API #2209

Merged
merged 49 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
29fba21
first draft for discussion
lappemic Apr 9, 2024
f40dead
Restyling + reintroduce webhook secret + WatchedItem to dataclass
lappemic Apr 9, 2024
2b6923f
Added webhook apis to __init__.py
lappemic Apr 9, 2024
4a3b39e
Added WEBHOOK_DOMAIN_T as constant
lappemic Apr 9, 2024
41ddf72
Updated update_webhook docstring
lappemic Apr 9, 2024
41eba5c
lint
Wauplin Apr 16, 2024
3630451
Merge branch 'main' into implement_webhooks_api
Wauplin Apr 16, 2024
76ae78e
style
Wauplin Apr 16, 2024
1e71c45
style
Wauplin Apr 16, 2024
331f0b4
style
Wauplin Apr 16, 2024
c6987cc
style
Wauplin Apr 16, 2024
63f904b
style
Wauplin Apr 16, 2024
e547e7e
Add Webhook dataclass as return value and update docstrings'
lappemic Apr 25, 2024
7edebf8
Update links to Webhook definition in docstrings
lappemic Apr 25, 2024
6e8a6bd
Update docstring style
lappemic Apr 25, 2024
ae577f5
Update token typing and description
lappemic Apr 25, 2024
f7e4aee
Update token typing and description to newest version
lappemic Apr 25, 2024
d81b850
Rename Webhook dataclass to WebhookInfo"
lappemic Apr 26, 2024
ad0e92b
Add WebhookInfo dataclass to huggingface_hub/__init__.py
lappemic Apr 26, 2024
f886b3c
Add import statements in examples
lappemic Apr 26, 2024
790ddd1
Update WebhookInfo references and standardize wording
lappemic Apr 26, 2024
bd47e24
Merge branch 'main' into implement_webhooks_api
Wauplin Apr 29, 2024
6c254cb
Add WebhookWatchedItem to huggingface_hub/__init__.py
lappemic Apr 30, 2024
9bb82f2
Apply suggestions: Args kw-only, all (not necessary) args optional
lappemic Apr 30, 2024
6454915
Apply suggestion: Add WebhookWatchedItem as import in example
lappemic Apr 30, 2024
4d4cd02
Merge branch 'implement_webhooks_api' of github.com:lappemic/huggingf…
lappemic Apr 30, 2024
7479fc4
Fix JSON parsing and dataclass serialization issues
lappemic May 2, 2024
1fd289e
Reorder args for consistency
lappemic May 2, 2024
1a6a6dd
Fix typo
lappemic May 2, 2024
d810422
Fix TypeError in update_webhook by ensuring watched is iterable and d…
lappemic May 2, 2024
a721107
Add tests
lappemic May 2, 2024
76764ee
Update args order in WebhookInfo dataclass
lappemic May 2, 2024
2bf2e8e
Merge branch 'main' into implement_webhooks_api
lappemic May 2, 2024
2c9a59f
Rename .../webhooks_server.md to .../webhooks.md
lappemic May 6, 2024
a1d40da
Apply suggestions
lappemic May 6, 2024
772758b
Fix commit issue
lappemic May 6, 2024
751d14a
Add 'Managing Webhooks' section to docs
lappemic May 6, 2024
a5ca94d
Update _redirects.yml
lappemic May 6, 2024
f80a033
Update _toctree.yml
lappemic May 6, 2024
ac92f3c
Update package_reference with WebhookInfo and WatchedWebhookInfo
lappemic May 6, 2024
910e209
Fix typos in hf_api.md
lappemic May 6, 2024
157a42b
Merge branch 'main' into implement_webhooks_api
lappemic May 6, 2024
fc19ec1
Update _toctree.yml
lappemic May 6, 2024
25cf4c0
Update _toctree.yml and _redirects.yml
lappemic May 7, 2024
05f0208
Update titles in guides/webhooks.md
lappemic May 7, 2024
c2cf626
Format and rephrase guides/webhooks`
lappemic May 7, 2024
e60bbc8
switch docs sections + fix code quality
Wauplin May 24, 2024
6910d07
test dicts as well
Wauplin May 24, 2024
6bb269c
Merge branch 'main' into implement_webhooks_api
Wauplin May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
"create_pull_request",
"create_repo",
"create_tag",
"create_webhook",
lappemic marked this conversation as resolved.
Show resolved Hide resolved
"dataset_info",
"delete_branch",
"delete_collection",
Expand All @@ -178,8 +179,11 @@
"delete_space_storage",
"delete_space_variable",
"delete_tag",
"delete_webhook",
"disable_webhook",
"duplicate_space",
"edit_discussion_comment",
"enable_webhook",
"file_exists",
"get_collection",
"get_dataset_tags",
Expand All @@ -193,6 +197,7 @@
"get_space_runtime",
"get_space_variables",
"get_token_permission",
"get_webhook",
"grant_access",
"like",
"list_accepted_access_requests",
Expand All @@ -210,6 +215,7 @@
"list_repo_refs",
"list_repo_tree",
"list_spaces",
"list_webhooks",
"merge_pull_request",
"model_info",
"move_repo",
Expand Down Expand Up @@ -237,6 +243,7 @@
"update_collection_metadata",
"update_inference_endpoint",
"update_repo_visibility",
"update_webhook",
"upload_file",
"upload_folder",
"whoami",
Expand Down Expand Up @@ -629,6 +636,7 @@ def __dir__():
create_pull_request, # noqa: F401
create_repo, # noqa: F401
create_tag, # noqa: F401
create_webhook, # noqa: F401
dataset_info, # noqa: F401
delete_branch, # noqa: F401
delete_collection, # noqa: F401
Expand All @@ -641,8 +649,11 @@ def __dir__():
delete_space_storage, # noqa: F401
delete_space_variable, # noqa: F401
delete_tag, # noqa: F401
delete_webhook, # noqa: F401
disable_webhook, # noqa: F401
duplicate_space, # noqa: F401
edit_discussion_comment, # noqa: F401
enable_webhook, # noqa: F401
file_exists, # noqa: F401
get_collection, # noqa: F401
get_dataset_tags, # noqa: F401
Expand All @@ -656,6 +667,7 @@ def __dir__():
get_space_runtime, # noqa: F401
get_space_variables, # noqa: F401
get_token_permission, # noqa: F401
get_webhook, # noqa: F401
grant_access, # noqa: F401
like, # noqa: F401
list_accepted_access_requests, # noqa: F401
Expand All @@ -673,6 +685,7 @@ def __dir__():
list_repo_refs, # noqa: F401
list_repo_tree, # noqa: F401
list_spaces, # noqa: F401
list_webhooks, # noqa: F401
merge_pull_request, # noqa: F401
model_info, # noqa: F401
move_repo, # noqa: F401
Expand Down Expand Up @@ -700,6 +713,7 @@ def __dir__():
update_collection_metadata, # noqa: F401
update_inference_endpoint, # noqa: F401
update_repo_visibility, # noqa: F401
update_webhook, # noqa: F401
upload_file, # noqa: F401
upload_folder, # noqa: F401
whoami, # noqa: F401
Expand Down
3 changes: 3 additions & 0 deletions src/huggingface_hub/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def _as_int(value: Optional[str]) -> Optional[int]:
DiscussionStatusFilter = Literal["all", "open", "closed"]
DISCUSSION_STATUS: Tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionStatusFilter)

# Webhook subscription types
WEBHOOK_DOMAIN_T = Literal["repo", "discussions"]

# default cache
default_home = os.path.join(os.path.expanduser("~"), ".cache")
HF_HOME = os.path.expanduser(
Expand Down
Loading
Loading