Repository: huggingface/huggingface_hub

Issue:
Is it possible to make `HF_ENDPOINT` endpoint overridable in environment variable ?
**Is your feature request related to a problem? Please describe.**

 We want to update the endpoint for this library (actually for `datasets`) for hub reasons.
AFAIK, it's actually also necessary for China.

**Describe the solution you'd like**

Something like in `transformers` : https://github.com/huggingface/transformers/blob/main/src/transformers/utils/hub.py#L110
Having the same defaults, just make it overridable with an env variable (other mecanisms are fine, just seems env variable are consistent and easy)

Also `ENDPOINT` and `HUGGINGFACE_CO_URL_HOME` seem to be duplicate names.

**Describe alternatives you've considered**

Current fix, is by monkey patching the relevant variables from external code, which is not ideal for maintenance reasons.

@LysandreJik @osanseviero  ? 

This could be a good opportunity to use the same variables across HF libraries in datasets, I rechecked and it's using `HF_ENDPOINT` actually.


Discussion:
this library does honor `HF_ENDPOINT` as far as i know
#703
I think this call is wrong then, no ? https://github.com/huggingface/huggingface_hub/blob/df4c6d929a6357379ae20558edc609d12876a294/src/huggingface_hub/file_download.py#L174

Defined here: https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/constants.py#L32
Ahh it's not in the released version either ! That's also part of why I was confused it wasn't working.

Maybe the call site I found was not the culprit for the behavior I was observing.

```
pip install -U huggingface_hub
HF_ENDPOINT=http://example.com python -c "from huggingface_hub import HfApi; print(HfApi().endpoint)" #  https://huggingface.co
``` 
Version v0.5.0 should drop in the coming days, hopefully by next Wednesday.

[Delayed] Aiming for a release early next week (early April)
arf yes good catch @Narsil 
From what I understand this seems to be fixed in upstream. Closing. Please comment if the fixes in upstream don't satisfy the requirements.
I think this part was not fixed: https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/constants.py#L32

I think the proposed fix uses `HF_HUB_URL` where the commonly used env variable in `datasets`,  `transformers` seem to be `HF_ENDPOINT`.  and also in this current library 
https://github.com/huggingface/transformers/blob/c595b6e6a90c29242c9dbfeecc5b132fe2e3d1f4/src/transformers/utils/hub.py#L110
https://github.com/huggingface/datasets/blob/8c5f27889657a1a6a7203b2f054bd0ceffce2178/src/datasets/config.py#L24
https://github.com/huggingface/huggingface_hub/blob/9edcb307b720c4eb9994024206ad7b8cfee61b56/src/huggingface_hub/hf_api.py#L469



This override is used in `pyctcdecode` *https://github.com/kensho-technologies/pyctcdecode/blob/09eadf4c3670c94ffc1d84a415c2685e16645b65/pyctcdecode/decoder.py#L764)  for instance which we use in `transformers` for instance (https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/__init__.py#L640)

Making the alignment in names desirable IMHO.

Happy to prepare the PR !
Makes sense to me to align the variable names, indeed. 

Resolving patch:
diff --git a/src/huggingface_hub/constants.py b/src/huggingface_hub/constants.py
--- a/src/huggingface_hub/constants.py
+++ b/src/huggingface_hub/constants.py
@@ -24,7 +24,7 @@
     os.environ.get("HUGGINGFACE_CO_STAGING", "NO").upper() in ENV_VARS_TRUE_VALUES
 )
 
-ENDPOINT = os.getenv("HF_HUB_URL") or (
+ENDPOINT = os.getenv("HF_ENDPOINT") or (
     "https://moon-staging.huggingface.co" if _staging_mode else "https://huggingface.co"
 )
 
diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py
--- a/src/huggingface_hub/hf_api.py
+++ b/src/huggingface_hub/hf_api.py
@@ -466,9 +466,7 @@ def erase_from_credential_store(username=None):
 
 class HfApi:
     def __init__(self, endpoint=None):
-        self.endpoint = (
-            endpoint if endpoint is not None else os.getenv("HF_ENDPOINT", ENDPOINT)
-        )
+        self.endpoint = endpoint if endpoint is not None else ENDPOINT
 
     def login(self, username: str, password: str) -> str:
         """


Test patch: