huggingface / huggingface_hub

The official Python client for the Huggingface Hub.
https://huggingface.co/docs/huggingface_hub
Apache License 2.0
2.02k stars 531 forks source link

Print correct webhook url when running in Spaces #2298

Closed Wauplin closed 4 months ago

Wauplin commented 4 months ago

When using WebhooksServer, the webhook URLs are printed in the logs so that users can configure them in their settings. However, when running in a Space the URL looks like this:

Webhooks are correctly setup and ready to use:
  - POST http://localhost:7860/webhooks/update_leaderboard
  - POST http://localhost:7860/webhooks/update_queue
Go to https://huggingface.co/settings/webhooks to setup your webhooks.

This PR fixes this by looking at the SPACE_HOST variable (if running in a Space). Logs should now show something like

Webhooks are correctly setup and ready to use:
  - POST http://open-llm-leaderboard-open-llm-leaderboard.hf.space/webhooks/update_leaderboard
  - POST http://open-llm-leaderboard-open-llm-leaderboard.hf.space/webhooks/update_queue
Go to https://huggingface.co/settings/webhooks to setup your webhooks.

cc @clefourrier who's using it for the Open LLM Leaderboard

HuggingFaceDocBuilderDev commented 4 months ago

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.

Wauplin commented 4 months ago

Thanks for the review :)