Repository: huggingface/huggingface_hub
Pull request #733 (2022-03-02 15:29:54)

MNT deprecate name and organization in favor of repo_id
Fixes https://github.com/huggingface/huggingface_hub/issues/706

Tests and deprecations on other methods to be added if we're okay with the approach.

cc @LysandreJik @osanseviero 

adrinjalali: This is now ready for another review!
adrinjalali: I'm not sure if the failed CI is related to this PR.
adrinjalali: Test failing with

```
E           requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://moon-staging.huggingface.co/api/repos/create - You don't have the rights to create a model under this namespace
```

on:

```py
    def test_push_to_hub(self):
        REPO_NAME = repo_name("PUSH_TO_HUB")
        model = DummyModel()
        model.push_to_hub(
            repo_path_or_name=f"{WORKING_REPO_DIR}/{REPO_NAME}",
            api_endpoint=ENDPOINT_STAGING,
            use_auth_token=self._token,
            git_user="ci",
            git_email="ci@dummy.com",
            config={"num": 7, "act": "gelu_fast"},
        )
```

I'm not sure how to fix this. @julien-c seems to have written the test.
adrinjalali: @LysandreJik if you're happy with the changes, please feel free to merge.
LysandreJik: Resolved conflicts, will merge when tests pass

Patch:
diff --git a/docs/hub/adding-a-library.md b/docs/hub/adding-a-library.md
index d21b299c..92684ca0 100644
--- a/docs/hub/adding-a-library.md
+++ b/docs/hub/adding-a-library.md
@@ -115,7 +115,7 @@ The `create_repo` method creates a repository on the Hub. Use the `name` paramet
 
 ```python
 >>> from huggingface_hub import create_repo
->>> create_repo(name="test-model")
+>>> create_repo(repo_id="test-model")
 'https://huggingface.co/lysandre/test-model'
 ```
 
diff --git a/docs/hub/adding-a-model.md b/docs/hub/adding-a-model.md
index 62c342bc..d82d6883 100644
--- a/docs/hub/adding-a-model.md
+++ b/docs/hub/adding-a-model.md
@@ -215,8 +215,7 @@ First we need to instantiate the `HfApi` class, which holds all of the magic:
 Afterwards we can run the `create_repo` function, specifying a number of settings and options for our new repository:
 ```python
 >>> api.create_repo(
->>>   name = "dummy", # The name of our repository
->>>   organization = None, # The namespace of the expected repository. Automatically grabs your logged-in profile name
+>>>   repo_id = "dummy", # The name of our repository, by default under your user
 >>>   private = False, # Whether the repo should be public or private
 >>>   repo_type = "model" # The type of repository, such as "model", "space", "dataset"
 >>> )
diff --git a/docs/hub/endpoints.md b/docs/hub/endpoints.md
index 2b315749..960eca45 100644
--- a/docs/hub/endpoints.md
+++ b/docs/hub/endpoints.md
@@ -21,8 +21,8 @@ We have open endpoints that you can use to retrieve information from the Hub as
 | /api/spaces     GET                                                          	| Get information from all Spaces in the Hub. You can specify additional parameters to have more specific results.   - `search`: Filter based on substrings for repos and their usernames, such as `resnet` or `microsoft` - `author`: Filter models by an author or organization, such as `huggingface` or `microsoft` - `filter`: Filter based on tags, such as `text-classification` or `spacy`. - `sort`: Property to use when sorting, such as `downloads` or `author`.  - `direction`: Direction in which to sort, such as `-1` for descending, and anything else for ascending. - `limit`: Limit the number of models fetched.  - `full`: Whether to fetch most model data, such as all tags, the files, etc.  - `config`: Whether to also fetch the repo config. 	| `list_models()`                   	| ```params= {   "search":"search", "author":"author", "filter":"filter", "sort":"sort", "direction":"direction", "limit":"limit", "full":"full", "config":"config"}``` 	|   	|
 | /api/spaces/{repo_id}   /api/spaces/{repo_id}/revision/{revision}    GET     	| Get all information for a specific model.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              	| `model_info(repo_id, revision)`   	| ```headers = { "authorization" :  "Bearer $token" }```                                                                                                                	|   	|
 | /api/metrics     GET                                                         	| Get information from all metrics in the Hub.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           	| `list_metrics()`                  	|                                                                                                                                                                       	|   	|
-| /api/repos/create     POST                                                   	| Create a repository. It's a model repo by default.   -         type: Type of repo (datasets or spaces; model by default).   - name: Name of repo.   - organization: Name of organization. -   - private: Whether the repo is private.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  	| `create_repo()`                   	| ```headers = { authorization :  "Bearer $token" }```  ```json= {"type":"type", "name":"name", "organization":"organization", "private":"private"}```                  	|   	|
-| /api/repos/delete    DELETE                                                  	| Delete a repository. It's a model repo by default.   -         type: Type of repo (datasets or spaces; model by default).   - name: Name of repo.   - organization: Name of organization.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              	| `delete_repo()`                   	| ```headers = { "authorization" :  "Bearer $token" }```  ```json= {"type":"type", "name":"name", "organization":"organization"}```                                     	|   	|
+| /api/repos/create     POST                                                   	| Create a repository. It's a model repo by default.   -         type: Type of repo (datasets or spaces; model by default).   - name: Name of repo.   - organization: Name of organization. -   - private: Whether the repo is private.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  	| `create_repo()`                   	| ```headers = { authorization :  "Bearer $token" }```  ```json= {"type":"type", "repo_id":"repo_id", "private":"private"}```                  	|   	|
+| /api/repos/delete    DELETE                                                  	| Delete a repository. It's a model repo by default.   -         type: Type of repo (datasets or spaces; model by default).   - name: Name of repo.   - organization: Name of organization.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              	| `delete_repo()`                   	| ```headers = { "authorization" :  "Bearer $token" }```  ```json= {"type":"type", "repo_id":"repo_id"}```                                     	|   	|
 | /api/repos/{type}/{repo_id}/settings   PUT                                   	| Update repo visibility.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                	| `update_repo_visibility()`        	| ```headers = { "authorization" :  "Bearer $token" }```  ```json= {"private":"private"}```                                                                             	|   	|
 | /api/repos/move POST                                                         	| Move a repository (rename within same namespace or transfer from user to organization).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 	| `move_repo()`                     	| ```headers = { "authorization" :  "Bearer $token" }```    ```json= {"fromRepo" : "namespace/repo_name", "toRepo" : "namespace2/repo_name2"}```                        	|   	|
 | /api/{type}/{repo_id}/upload/{revision}/{path_in_repo}    POST               	| Upload a file to a specific repository.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                	| `upload_file()`                   	| ```headers = { "authorization" :  "Bearer $token" }```  ```"data"="bytestream"```                                                                                     	|   	|
diff --git a/docs/hub/how-to-upstream.md b/docs/hub/how-to-upstream.md
index 965919ad..c9a6d883 100644
--- a/docs/hub/how-to-upstream.md
+++ b/docs/hub/how-to-upstream.md
@@ -89,13 +89,13 @@ Pass the full repository ID to `delete_repo`. The full repository ID looks like
 ```python
 >>> from huggingface_hub import get_full_repo_name, delete_repo
 >>> name = get_full_repo_name(repo_name)
->>> delete_repo(name=name)
+>>> delete_repo(repo_id=name)
 ```
 
 Delete a dataset repository by adding the `repo_type` parameter:
 
 ```python
->>> delete_repo(name=REPO_NAME, repo_type="dataset")
+>>> delete_repo(repo_id=REPO_NAME, repo_type="dataset")
 ```
 
 ### Change repository visibility
@@ -128,7 +128,7 @@ The `clone_from` parameter clones a repository from a Hugging Face model ID to a
 Easily combine the `clone_from` parameter with `create_repo` to create and clone a repository:
 
 ```python
->>> repo_url = create_repo(name="repo_name")
+>>> repo_url = create_repo(repo_id="repo_name")
 >>> repo = Repository(local_dir="repo_local_path", clone_from=repo_url)
 ```
 
diff --git a/docs/hub/tutorial-add-library.md b/docs/hub/tutorial-add-library.md
index c2bb0e6d..af9f3ed2 100644
--- a/docs/hub/tutorial-add-library.md
+++ b/docs/hub/tutorial-add-library.md
@@ -115,7 +115,7 @@ The `create_repo` method creates a repository on the Hub. Use the `name` paramet
 
 ```python
 >>> from huggingface_hub import create_repo
->>> create_repo(name="test-model")
+>>> create_repo(repo_id="test-model")
 'https://huggingface.co/lysandre/test-model'
 ```
 
diff --git a/src/huggingface_hub/commands/user.py b/src/huggingface_hub/commands/user.py
index 806176c3..2ef666a4 100644
--- a/src/huggingface_hub/commands/user.py
+++ b/src/huggingface_hub/commands/user.py
@@ -244,9 +244,11 @@ class RepoCreateCommand(BaseUserCommand):
             exit(1)
 
         if self.args.type in REPO_TYPES_URL_PREFIXES:
-            repo_id = REPO_TYPES_URL_PREFIXES[self.args.type] + repo_id
+            prefixed_repo_id = REPO_TYPES_URL_PREFIXES[self.args.type] + repo_id
+        else:
+            prefixed_repo_id = repo_id
 
-        print(f"You are about to create {ANSI.bold(repo_id)}")
+        print(f"You are about to create {ANSI.bold(prefixed_repo_id)}")
 
         if not self.args.yes:
             choice = input("Proceed? [Y/n] ").lower()
@@ -254,10 +256,10 @@ class RepoCreateCommand(BaseUserCommand):
                 print("Abort")
                 exit()
         try:
+
             url = self._api.create_repo(
-                self.args.name,
+                repo_id=repo_id,
                 token=token,
-                organization=self.args.organization,
                 repo_type=self.args.type,
                 space_sdk=self.args.space_sdk,
             )
diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py
index c53938db..135cd7fa 100644
--- a/src/huggingface_hub/hf_api.py
+++ b/src/huggingface_hub/hf_api.py
@@ -52,6 +52,33 @@ USERNAME_PLACEHOLDER = "hf_user"
 logger = logging.get_logger(__name__)
 
 
+# TODO: remove after deprecation period is over (v0.7)
+def _validate_repo_id_deprecation(repo_id, name, organization):
+    """Returns (name, organization) from the input."""
+    if not (repo_id or name):
+        raise ValueError(
+            "No name provided. Please pass `repo_id` with a valid repository name."
+        )
+
+    if repo_id and (name or organization):
+        raise ValueError(
+            "Only pass `repo_id` and leave deprecated `name` and "
+            "`organization` to be None."
+        )
+    elif name or organization:
+        warnings.warn(
+            "`name` and `organization` input arguments are deprecated and "
+            "will be removed in v0.7. Pass `repo_id` instead.",
+            FutureWarning,
+        )
+    else:
+        if "/" in repo_id:
+            organization, name = repo_id.split("/")
+        else:
+            organization, name = None, repo_id
+    return name, organization
+
+
 def repo_type_and_id_from_hf_id(hf_id: str):
     """
     Returns the repo type and ID from a huggingface.co URL linking to a repository
@@ -998,34 +1025,47 @@ class HfApi:
 
     def create_repo(
         self,
-        name: str,
+        repo_id: str = None,
         token: Optional[str] = None,
         organization: Optional[str] = None,
         private: Optional[bool] = None,
         repo_type: Optional[str] = None,
         exist_ok=False,
-        lfsmultipartthresh: Optional[int] = None,
         space_sdk: Optional[str] = None,
+        name: str = None,
     ) -> str:
-        """
-        HuggingFace git-based system, used for models, datasets, and spaces.
+        """Create an empty repo on the HuggingFace Hub.
 
-        Call HF API to create a whole repo.
+        Args:
+            repo_id: A namespace (user or an organization) and a repo name
+                seperated by a ``/``.
 
-        Params:
-            private: Whether the model repo should be private (requires a paid huggingface.co account)
+                .. versionadded: 0.4.0
+
+            token: An authentication token [1]_.
 
-            repo_type: Set to :obj:`"dataset"` or :obj:`"space"` if uploading to a dataset or space, :obj:`None` or :obj:`"model"` if uploading to a model. Default is :obj:`None`.
+            private: Whether the model repo should be private.
 
-            exist_ok: Do not raise an error if repo already exists
+            repo_type: Set to :obj:`"dataset"` or :obj:`"space"` if uploading
+                to a dataset or space, :obj:`None` or :obj:`"model"` if
+                uploading to a model. Default is :obj:`None`.
 
-            lfsmultipartthresh: Optional: internal param for testing purposes.
+            exist_ok: If ``True``, do not raise an error if repo already
+                exists.
 
-            space_sdk: Choice of SDK to use if repo_type is "space". Can be "streamlit", "gradio", or "static".
+            space_sdk: Choice of SDK to use if repo_type is "space". Can be
+                "streamlit", "gradio", or "static".
 
         Returns:
             URL to the newly created repo.
+
+        References:
+            .. [1] https://huggingface.co/settings/tokens
+
+        Reference
         """
+        name, organization = _validate_repo_id_deprecation(repo_id, name, organization)
+
         path = f"{self.endpoint}/api/repos/create"
         if token is None:
             token = self._validate_or_retrieve_token()
@@ -1088,8 +1128,8 @@ class HfApi:
                 "Ignoring provided space_sdk because repo_type is not 'space'."
             )
 
-        if lfsmultipartthresh is not None:
-            json["lfsmultipartthresh"] = lfsmultipartthresh
+        if getattr(self, "_lfsmultipartthresh", None):
+            json["lfsmultipartthresh"] = self._lfsmultipartthresh
         r = requests.post(
             path,
             headers={"authorization": f"Bearer {token}"},
@@ -1115,18 +1155,36 @@ class HfApi:
 
     def delete_repo(
         self,
-        name: str,
+        repo_id: str = None,
         token: Optional[str] = None,
         organization: Optional[str] = None,
         repo_type: Optional[str] = None,
+        name: str = None,
     ):
-        """
-        HuggingFace git-based system, used for models, datasets, and spaces.
-
-        Call HF API to delete a whole repo.
+        """Delete a repo from the HuggingFace Hub.
 
         CAUTION(this is irreversible).
+
+        Args:
+            repo_id: A namespace (user or an organization) and a repo name
+                seperated by a ``/``.
+
+                .. versionadded: 0.4.0
+
+            token: An authentication token [1]_.
+
+            repo_type: Set to :obj:`"dataset"` or :obj:`"space"` if uploading
+                to a dataset or space, :obj:`None` or :obj:`"model"` if
+                uploading to a model. Default is :obj:`None`.
+
+        Returns:
+            None
+
+        References:
+            .. [1] https://huggingface.co/settings/tokens
         """
+        name, organization = _validate_repo_id_deprecation(repo_id, name, organization)
+
         path = f"{self.endpoint}/api/repos/delete"
         if token is None:
             token = self._validate_or_retrieve_token()
@@ -1183,18 +1241,40 @@ class HfApi:
 
     def update_repo_visibility(
         self,
-        name: str,
-        private: bool,
+        repo_id: str = None,
+        private: bool = False,
         token: Optional[str] = None,
         organization: Optional[str] = None,
         repo_type: Optional[str] = None,
+        name: str = None,
     ) -> Dict[str, bool]:
-        """
-        Update the visibility setting of a repository.
+        """Update the visibility setting of a repository.
+
+        Args:
+            repo_id: A namespace (user or an organization) and a repo name
+                seperated by a ``/``.
+
+                .. versionadded: 0.4.0
+
+            private: Whether the model repo should be private.
+
+            token: An authentication token [1]_.
+
+            repo_type: Set to :obj:`"dataset"` or :obj:`"space"` if uploading
+                to a dataset or space, :obj:`None` or :obj:`"model"` if
+                uploading to a model. Default is :obj:`None`.
+
+        Returns:
+            The HTTP response in json.
+
+        References:
+            .. [1] https://huggingface.co/settings/tokens
         """
         if repo_type not in REPO_TYPES:
             raise ValueError("Invalid repo type")
 
+        name, organization = _validate_repo_id_deprecation(repo_id, name, organization)
+
         if token is None:
             token = self._validate_or_retrieve_token()
         elif not self._is_valid_token(token):
diff --git a/src/huggingface_hub/hub_mixin.py b/src/huggingface_hub/hub_mixin.py
index 3a1cce5c..f1ee52f9 100644
--- a/src/huggingface_hub/hub_mixin.py
+++ b/src/huggingface_hub/hub_mixin.py
@@ -255,11 +255,12 @@ class ModelHubMixin:
 
         # If no URL is passed and there's no path to a directory containing files, create a repo
         if repo_url is None and not os.path.exists(repo_path_or_name):
-            repo_name = Path(repo_path_or_name).name
+            repo_id = Path(repo_path_or_name).name
+            if organization:
+                repo_id = f"{organization}/{repo_id}"
             repo_url = HfApi(endpoint=api_endpoint).create_repo(
-                repo_name,
+                repo_id=repo_id,
                 token=token,
-                organization=organization,
                 private=private,
                 repo_type=None,
                 exist_ok=True,
diff --git a/src/huggingface_hub/keras_mixin.py b/src/huggingface_hub/keras_mixin.py
index 19e71aca..ac25d410 100644
--- a/src/huggingface_hub/keras_mixin.py
+++ b/src/huggingface_hub/keras_mixin.py
@@ -292,11 +292,12 @@ def push_to_hub_keras(
 
     # If no URL is passed and there's no path to a directory containing files, create a repo
     if repo_url is None and not os.path.exists(repo_path_or_name):
-        repo_name = Path(repo_path_or_name).name
+        repo_id = Path(repo_path_or_name).name
+        if organization:
+            repo_id = f"{organization}/{repo_id}"
         repo_url = HfApi(endpoint=api_endpoint).create_repo(
-            repo_name,
+            repo_id=repo_id,
             token=token,
-            organization=organization,
             private=private,
             repo_type=None,
             exist_ok=True,
diff --git a/src/huggingface_hub/repository.py b/src/huggingface_hub/repository.py
index d4565c19..46f17229 100644
--- a/src/huggingface_hub/repository.py
+++ b/src/huggingface_hub/repository.py
@@ -373,7 +373,7 @@ class Repository:
 
         If specifying a `clone_from`:
         will clone an existing remote repository, for instance one
-        that was previously created using ``HfApi().create_repo(name=repo_name)``.
+        that was previously created using ``HfApi().create_repo(repo_id=repo_name)``.
         ``Repository`` uses the local git credentials by default, but if required, the ``huggingface_token``
         as well as the git ``user`` and the ``email`` can be explicitly specified.
         If `clone_from` is used, and the repository is being instantiated into a non-empty directory,
@@ -538,17 +538,16 @@ class Repository:
                 valid_organisations = [org["name"] for org in whoami_info["orgs"]]
 
                 if namespace is not None:
-                    repo_url += f"{namespace}/"
+                    repo_id = f"{namespace}/{repo_id}"
                 repo_url += repo_id
 
                 repo_url = repo_url.replace("https://", f"https://user:{token}@")
 
                 if namespace == user or namespace in valid_organisations:
                     api.create_repo(
-                        repo_id,
+                        repo_id=repo_id,
                         token=token,
                         repo_type=self.repo_type,
-                        organization=namespace,
                         exist_ok=True,
                         private=self.private,
                     )


Test patch:
diff --git a/tests/test_hf_api.py b/tests/test_hf_api.py
index 4db0bd11..44df1014 100644
--- a/tests/test_hf_api.py
+++ b/tests/test_hf_api.py
@@ -14,12 +14,14 @@
 
 
 import os
+import re
 import shutil
 import subprocess
 import tempfile
 import time
 import unittest
 import uuid
+import warnings
 from io import BytesIO
 
 import pytest
@@ -42,6 +44,7 @@ from huggingface_hub.hf_api import (
     MetricInfo,
     ModelInfo,
     ModelSearchArguments,
+    _validate_repo_id_deprecation,
     erase_from_credential_store,
     read_from_credential_store,
     repo_type_and_id_from_hf_id,
@@ -172,6 +175,104 @@ class HfApiCommonTestWithLogin(HfApiCommonTest):
         cls._token = cls._api.login(username=USER, password=PASS)
 
 
+@retry_endpoint
+def test_repo_id_no_warning():
+    # tests that passing repo_id as positional arg doesn't raise any warnings
+    # for {create, delete}_repo and update_repo_visibility
+    api = HfApi(endpoint=ENDPOINT_STAGING)
+    token = api.login(username=USER, password=PASS)
+    REPO_NAME = repo_name("crud")
+
+    args = [
+        ("create_repo", {}),
+        ("update_repo_visibility", {"private": False}),
+        ("delete_repo", {}),
+    ]
+
+    for method, kwargs in args:
+        with warnings.catch_warnings(record=True) as record:
+            getattr(api, method)(
+                REPO_NAME, token=token, repo_type=REPO_TYPE_MODEL, **kwargs
+            )
+        assert not len(record)
+
+
+def test_validate_repo_id_deprecation():
+    with pytest.warns(FutureWarning, match="input arguments are deprecated"):
+        name, org = _validate_repo_id_deprecation(
+            repo_id=None, name="repo", organization="org"
+        )
+        assert name == "repo" and org == "org"
+
+    with warnings.catch_warnings(record=True) as record:
+        name, org = _validate_repo_id_deprecation(
+            repo_id="org/repo", name=None, organization=None
+        )
+        assert name == "repo" and org == "org"
+    assert not len(record)
+
+    with pytest.raises(ValueError, match="leave deprecated"):
+        _validate_repo_id_deprecation(
+            repo_id="repo_id", name="name", organization="organization"
+        )
+
+
+@retry_endpoint
+def test_name_org_deprecation_warning():
+    # test that the right warning is raised when passing name to
+    # {create, delete}_repo and update_repo_visibility
+    api = HfApi(endpoint=ENDPOINT_STAGING)
+    token = api.login(username=USER, password=PASS)
+    REPO_NAME = repo_name("crud")
+
+    args = [
+        ("create_repo", {}),
+        ("update_repo_visibility", {"private": False}),
+        ("delete_repo", {}),
+    ]
+
+    for method, kwargs in args:
+        with pytest.warns(
+            FutureWarning,
+            match=re.escape("`name` and `organization` input arguments are deprecated"),
+        ):
+            getattr(api, method)(
+                name=REPO_NAME, token=token, repo_type=REPO_TYPE_MODEL, **kwargs
+            )
+
+
+@retry_endpoint
+def test_name_org_deprecation_error():
+    # tests that the right error is raised when passing both name and repo_id
+    # to {create, delete}_repo and update_repo_visibility
+    api = HfApi(endpoint=ENDPOINT_STAGING)
+    token = api.login(username=USER, password=PASS)
+    REPO_NAME = repo_name("crud")
+
+    args = [
+        ("create_repo", {}),
+        ("update_repo_visibility", {"private": False}),
+        ("delete_repo", {}),
+    ]
+
+    for method, kwargs in args:
+        with pytest.raises(
+            ValueError,
+            match=re.escape("Only pass `repo_id`"),
+        ):
+            getattr(api, method)(
+                repo_id="test",
+                name=REPO_NAME,
+                token=token,
+                repo_type=REPO_TYPE_MODEL,
+                **kwargs,
+            )
+
+    for method, kwargs in args:
+        with pytest.raises(ValueError, match="No name provided"):
+            getattr(api, method)(token=token, repo_type=REPO_TYPE_MODEL, **kwargs)
+
+
 class HfApiEndpointsTest(HfApiCommonTestWithLogin):
     def test_whoami(self):
         info = self._api.whoami(token=self._token)
@@ -184,57 +285,63 @@ class HfApiEndpointsTest(HfApiCommonTestWithLogin):
     @retry_endpoint
     def test_create_update_and_delete_repo(self):
         REPO_NAME = repo_name("crud")
-        self._api.create_repo(name=REPO_NAME, token=self._token)
+        self._api.create_repo(repo_id=REPO_NAME, token=self._token)
         res = self._api.update_repo_visibility(
-            name=REPO_NAME, token=self._token, private=True
+            repo_id=REPO_NAME, token=self._token, private=True
         )
         self.assertTrue(res["private"])
         res = self._api.update_repo_visibility(
-            name=REPO_NAME, token=self._token, private=False
+            repo_id=REPO_NAME, token=self._token, private=False
         )
         self.assertFalse(res["private"])
-        self._api.delete_repo(name=REPO_NAME, token=self._token)
+        self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
 
     @retry_endpoint
     def test_create_update_and_delete_model_repo(self):
         REPO_NAME = repo_name("crud")
         self._api.create_repo(
-            name=REPO_NAME, token=self._token, repo_type=REPO_TYPE_MODEL
+            repo_id=REPO_NAME, token=self._token, repo_type=REPO_TYPE_MODEL
         )
         res = self._api.update_repo_visibility(
-            name=REPO_NAME, token=self._token, private=True, repo_type=REPO_TYPE_MODEL
+            repo_id=REPO_NAME,
+            token=self._token,
+            private=True,
+            repo_type=REPO_TYPE_MODEL,
         )
         self.assertTrue(res["private"])
         res = self._api.update_repo_visibility(
-            name=REPO_NAME, token=self._token, private=False, repo_type=REPO_TYPE_MODEL
+            repo_id=REPO_NAME,
+            token=self._token,
+            private=False,
+            repo_type=REPO_TYPE_MODEL,
         )
         self.assertFalse(res["private"])
         self._api.delete_repo(
-            name=REPO_NAME, token=self._token, repo_type=REPO_TYPE_MODEL
+            repo_id=REPO_NAME, token=self._token, repo_type=REPO_TYPE_MODEL
         )
 
     @retry_endpoint
     def test_create_update_and_delete_dataset_repo(self):
         DATASET_REPO_NAME = dataset_repo_name("crud")
         self._api.create_repo(
-            name=DATASET_REPO_NAME, token=self._token, repo_type=REPO_TYPE_DATASET
+            repo_id=DATASET_REPO_NAME, token=self._token, repo_type=REPO_TYPE_DATASET
         )
         res = self._api.update_repo_visibility(
-            name=DATASET_REPO_NAME,
+            repo_id=DATASET_REPO_NAME,
             token=self._token,
             private=True,
             repo_type=REPO_TYPE_DATASET,
         )
         self.assertTrue(res["private"])
         res = self._api.update_repo_visibility(
-            name=DATASET_REPO_NAME,
+            repo_id=DATASET_REPO_NAME,
             token=self._token,
             private=False,
             repo_type=REPO_TYPE_DATASET,
         )
         self.assertFalse(res["private"])
         self._api.delete_repo(
-            name=DATASET_REPO_NAME, token=self._token, repo_type=REPO_TYPE_DATASET
+            repo_id=DATASET_REPO_NAME, token=self._token, repo_type=REPO_TYPE_DATASET
         )
 
     @retry_endpoint
@@ -243,14 +350,14 @@ class HfApiEndpointsTest(HfApiCommonTestWithLogin):
         with pytest.raises(ValueError, match=r"No space_sdk provided.*"):
             self._api.create_repo(
                 token=self._token,
-                name=SPACE_REPO_NAME,
+                repo_id=SPACE_REPO_NAME,
                 repo_type=REPO_TYPE_SPACE,
                 space_sdk=None,
             )
         with pytest.raises(ValueError, match=r"Invalid space_sdk.*"):
             self._api.create_repo(
                 token=self._token,
-                name=SPACE_REPO_NAME,
+                repo_id=SPACE_REPO_NAME,
                 repo_type=REPO_TYPE_SPACE,
                 space_sdk="asdfasdf",
             )
@@ -258,27 +365,27 @@ class HfApiEndpointsTest(HfApiCommonTestWithLogin):
         for sdk in SPACES_SDK_TYPES:
             SPACE_REPO_NAME = space_repo_name(sdk)
             self._api.create_repo(
-                name=SPACE_REPO_NAME,
+                repo_id=SPACE_REPO_NAME,
                 token=self._token,
                 repo_type=REPO_TYPE_SPACE,
                 space_sdk=sdk,
             )
             res = self._api.update_repo_visibility(
-                name=SPACE_REPO_NAME,
+                repo_id=SPACE_REPO_NAME,
                 token=self._token,
                 private=True,
                 repo_type=REPO_TYPE_SPACE,
             )
             self.assertTrue(res["private"])
             res = self._api.update_repo_visibility(
-                name=SPACE_REPO_NAME,
+                repo_id=SPACE_REPO_NAME,
                 token=self._token,
                 private=False,
                 repo_type=REPO_TYPE_SPACE,
             )
             self.assertFalse(res["private"])
             self._api.delete_repo(
-                name=SPACE_REPO_NAME, token=self._token, repo_type=REPO_TYPE_SPACE
+                repo_id=SPACE_REPO_NAME, token=self._token, repo_type=REPO_TYPE_SPACE
             )
 
     @retry_endpoint
@@ -290,7 +397,7 @@ class HfApiEndpointsTest(HfApiCommonTestWithLogin):
 
         for repo_type in [REPO_TYPE_MODEL, REPO_TYPE_DATASET, REPO_TYPE_SPACE]:
             self._api.create_repo(
-                name=REPO_NAME,
+                repo_id=REPO_NAME,
                 token=self._token,
                 repo_type=repo_type,
                 space_sdk="static",
@@ -312,7 +419,7 @@ class HfApiEndpointsTest(HfApiCommonTestWithLogin):
                 repo_type=repo_type,
             )
             self._api.delete_repo(
-                name=NEW_REPO_NAME, token=self._token, repo_type=repo_type
+                repo_id=NEW_REPO_NAME, token=self._token, repo_type=repo_type
             )
 
 
@@ -362,7 +469,7 @@ class HfApiUploadFileTest(HfApiCommonTestWithLogin):
     @retry_endpoint
     def test_upload_file_path(self):
         REPO_NAME = repo_name("path")
-        self._api.create_repo(token=self._token, name=REPO_NAME)
+        self._api.create_repo(token=self._token, repo_id=REPO_NAME)
         try:
             self._api.upload_file(
                 path_or_fileobj=self.tmp_file,
@@ -383,12 +490,12 @@ class HfApiUploadFileTest(HfApiCommonTestWithLogin):
         except Exception as err:
             self.fail(err)
         finally:
-            self._api.delete_repo(name=REPO_NAME, token=self._token)
+            self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
 
     @retry_endpoint
     def test_upload_file_fileobj(self):
         REPO_NAME = repo_name("fileobj")
-        self._api.create_repo(name=REPO_NAME, token=self._token)
+        self._api.create_repo(repo_id=REPO_NAME, token=self._token)
         try:
             with open(self.tmp_file, "rb") as filestream:
                 self._api.upload_file(
@@ -410,12 +517,12 @@ class HfApiUploadFileTest(HfApiCommonTestWithLogin):
         except Exception as err:
             self.fail(err)
         finally:
-            self._api.delete_repo(name=REPO_NAME, token=self._token)
+            self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
 
     @retry_endpoint
     def test_upload_file_bytesio(self):
         REPO_NAME = repo_name("bytesio")
-        self._api.create_repo(name=REPO_NAME, token=self._token)
+        self._api.create_repo(repo_id=REPO_NAME, token=self._token)
         try:
             filecontent = BytesIO(b"File content, but in bytes IO")
             self._api.upload_file(
@@ -437,12 +544,12 @@ class HfApiUploadFileTest(HfApiCommonTestWithLogin):
         except Exception as err:
             self.fail(err)
         finally:
-            self._api.delete_repo(name=REPO_NAME, token=self._token)
+            self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
 
     @retry_endpoint
     def test_upload_file_conflict(self):
         REPO_NAME = repo_name("conflict")
-        self._api.create_repo(name=REPO_NAME, token=self._token)
+        self._api.create_repo(repo_id=REPO_NAME, token=self._token)
         try:
             filecontent = BytesIO(b"File content, but in bytes IO")
             self._api.upload_file(
@@ -475,12 +582,12 @@ class HfApiUploadFileTest(HfApiCommonTestWithLogin):
         except Exception as err:
             self.fail(err)
         finally:
-            self._api.delete_repo(name=REPO_NAME, token=self._token)
+            self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
 
     @retry_endpoint
     def test_upload_buffer(self):
         REPO_NAME = repo_name("buffer")
-        self._api.create_repo(name=REPO_NAME, token=self._token)
+        self._api.create_repo(repo_id=REPO_NAME, token=self._token)
         try:
             buffer = BytesIO()
             buffer.write(self.tmp_file_content.encode())
@@ -503,12 +610,12 @@ class HfApiUploadFileTest(HfApiCommonTestWithLogin):
         except Exception as err:
             self.fail(err)
         finally:
-            self._api.delete_repo(name=REPO_NAME, token=self._token)
+            self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
 
     @retry_endpoint
     def test_delete_file(self):
         REPO_NAME = repo_name("delete")
-        self._api.create_repo(token=self._token, name=REPO_NAME)
+        self._api.create_repo(token=self._token, repo_id=REPO_NAME)
         try:
             self._api.upload_file(
                 path_or_fileobj=self.tmp_file,
@@ -529,7 +636,7 @@ class HfApiUploadFileTest(HfApiCommonTestWithLogin):
         except Exception as err:
             self.fail(err)
         finally:
-            self._api.delete_repo(name=REPO_NAME, token=self._token)
+            self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
 
     def test_get_full_repo_name(self):
         repo_name_with_no_org = self._api.get_full_repo_name("model", token=self._token)
@@ -949,10 +1056,10 @@ class HfApiPrivateTest(HfApiCommonTestWithLogin):
     def setUp(self) -> None:
         super().setUp()
         self.REPO_NAME = repo_name("private")
-        self._api.create_repo(name=self.REPO_NAME, token=self._token, private=True)
+        self._api.create_repo(repo_id=self.REPO_NAME, token=self._token, private=True)
 
     def tearDown(self) -> None:
-        self._api.delete_repo(name=self.REPO_NAME, token=self._token)
+        self._api.delete_repo(repo_id=self.REPO_NAME, token=self._token)
 
     def test_model_info(self):
         shutil.rmtree(os.path.dirname(HfFolder.path_token))
@@ -1012,7 +1119,7 @@ class HfLargefilesTest(HfApiCommonTest):
         )
 
     def tearDown(self):
-        self._api.delete_repo(name=self.REPO_NAME_LARGE_FILE, token=self._token)
+        self._api.delete_repo(repo_id=self.REPO_NAME_LARGE_FILE, token=self._token)
 
     def setup_local_clone(self, REMOTE_URL):
         REMOTE_URL_AUTH = REMOTE_URL.replace(
@@ -1033,11 +1140,12 @@ class HfLargefilesTest(HfApiCommonTest):
 
     @retry_endpoint
     def test_end_to_end_thresh_6M(self):
+        self._api._lfsmultipartthresh = 6 * 10**6
         REMOTE_URL = self._api.create_repo(
-            name=self.REPO_NAME_LARGE_FILE,
+            repo_id=self.REPO_NAME_LARGE_FILE,
             token=self._token,
-            lfsmultipartthresh=6 * 10**6,
         )
+        self._api._lfsmultipartthresh = None
         self.setup_local_clone(REMOTE_URL)
 
         subprocess.run(
@@ -1087,11 +1195,12 @@ class HfLargefilesTest(HfApiCommonTest):
     @retry_endpoint
     def test_end_to_end_thresh_16M(self):
         # Here we'll push one multipart and one non-multipart file in the same commit, and see what happens
+        self._api._lfsmultipartthresh = 16 * 10**6
         REMOTE_URL = self._api.create_repo(
-            name=self.REPO_NAME_LARGE_FILE,
+            repo_id=self.REPO_NAME_LARGE_FILE,
             token=self._token,
-            lfsmultipartthresh=16 * 10**6,
         )
+        self._api._lfsmultipartthresh = None
         self.setup_local_clone(REMOTE_URL)
 
         subprocess.run(
diff --git a/tests/test_hubmixin.py b/tests/test_hubmixin.py
index 2f95331d..e2f5178c 100644
--- a/tests/test_hubmixin.py
+++ b/tests/test_hubmixin.py
@@ -133,4 +133,4 @@ class HubMixingTest(HubMixingCommonTest):
         )
         self.assertEqual(model_info.modelId, f"{USER}/{REPO_NAME}")
 
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
diff --git a/tests/test_keras_integration.py b/tests/test_keras_integration.py
index 7b9cc3ad..092dafcb 100644
--- a/tests/test_keras_integration.py
+++ b/tests/test_keras_integration.py
@@ -169,7 +169,7 @@ class HubMixingTestKeras(unittest.TestCase):
         )
         self.assertEqual(model_info.modelId, f"{USER}/{REPO_NAME}")
 
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
 
 
 @require_tf
@@ -327,7 +327,7 @@ class HubKerasSequentialTest(HubMixingTestKeras):
         )
         self.assertEqual(model_info.modelId, f"{USER}/{REPO_NAME}")
 
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
 
     @retry_endpoint
     def test_push_to_hub_model_card_build(self):
@@ -347,7 +347,7 @@ class HubKerasSequentialTest(HubMixingTestKeras):
         )
         self.assertTrue("README.md" in [f.rfilename for f in model_info.siblings])
         self.assertTrue("model.png" in [f.rfilename for f in model_info.siblings])
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
 
     @retry_endpoint
     def test_push_to_hub_model_card_plot_false(self):
@@ -367,7 +367,7 @@ class HubKerasSequentialTest(HubMixingTestKeras):
             f"{USER}/{REPO_NAME}",
         )
         self.assertFalse("model.png" in [f.rfilename for f in model_info.siblings])
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
 
     @retry_endpoint
     def test_push_to_hub_tensorboard(self):
@@ -394,7 +394,7 @@ class HubKerasSequentialTest(HubMixingTestKeras):
         self.assertTrue(
             "logs/tensorboard.txt" in [f.rfilename for f in model_info.siblings]
         )
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
 
     @retry_endpoint
     def test_override_tensorboard(self):
@@ -437,7 +437,7 @@ class HubKerasSequentialTest(HubMixingTestKeras):
             "logs/tensorboard.txt" in [f.rfilename for f in model_info.siblings]
         )
 
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
 
     @retry_endpoint
     def test_push_to_hub_model_kwargs(self):
@@ -464,7 +464,7 @@ class HubKerasSequentialTest(HubMixingTestKeras):
         from_pretrained_keras(f"{WORKING_REPO_DIR}/{REPO_NAME}")
         self.assertRaises(ValueError, msg="Exception encountered when calling layer*")
 
-        self._api.delete_repo(name=f"{REPO_NAME}", token=self._token)
+        self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
 
 
 @require_tf
diff --git a/tests/test_repository.py b/tests/test_repository.py
index 463fc8ae..fbfc7449 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -79,7 +79,9 @@ class RepositoryTest(RepositoryCommonTest):
             f"Does {WORKING_REPO_DIR} exist: {os.path.exists(WORKING_REPO_DIR)}"
         )
         self.REPO_NAME = repo_name()
-        self._repo_url = self._api.create_repo(name=self.REPO_NAME, token=self._token)
+        self._repo_url = self._api.create_repo(
+            repo_id=self.REPO_NAME, token=self._token
+        )
         self._api.upload_file(
             path_or_fileobj=BytesIO(b"some initial binary data: \x00\x01"),
             path_in_repo="random_file.txt",
@@ -89,18 +91,18 @@ class RepositoryTest(RepositoryCommonTest):
 
     def tearDown(self):
         try:
-            self._api.delete_repo(name=f"{USER}/{self.REPO_NAME}", token=self._token)
+            self._api.delete_repo(repo_id=f"{USER}/{self.REPO_NAME}", token=self._token)
         except requests.exceptions.HTTPError:
             pass
 
         try:
-            self._api.delete_repo(name=self.REPO_NAME, token=self._token)
+            self._api.delete_repo(repo_id=self.REPO_NAME, token=self._token)
         except requests.exceptions.HTTPError:
             pass
 
         try:
             self._api.delete_repo(
-                name=self.REPO_NAME, token=self._token, organization="valid_org"
+                repo_id=f"valid_org/{self.REPO_NAME}", token=self._token
             )
         except requests.exceptions.HTTPError:
             pass
@@ -170,7 +172,7 @@ class RepositoryTest(RepositoryCommonTest):
     def test_init_clone_in_nonempty_non_linked_git_repo(self):
         # Create a new repository on the HF Hub
         temp_repo_url = self._api.create_repo(
-            name=f"{self.REPO_NAME}-temp", token=self._token
+            repo_id=f"{self.REPO_NAME}-temp", token=self._token
         )
         self._api.upload_file(
             path_or_fileobj=BytesIO(b"some initial binary data: \x00\x01"),
@@ -188,7 +190,7 @@ class RepositoryTest(RepositoryCommonTest):
             EnvironmentError, Repository, WORKING_REPO_DIR, clone_from=temp_repo_url
         )
 
-        self._api.delete_repo(name=f"{self.REPO_NAME}-temp", token=self._token)
+        self._api.delete_repo(repo_id=f"{self.REPO_NAME}-temp", token=self._token)
 
     @retry_endpoint
     def test_init_clone_in_nonempty_linked_git_repo_with_token(self):
@@ -553,7 +555,7 @@ class RepositoryTest(RepositoryCommonTest):
 
         with open(pathlib.Path(repo.local_dir) / "file.bin", "r") as f:
             content = f.read()
-            self.assertEquals(content, "Bin file")
+            self.assertEqual(content, "Bin file")
 
     @retry_endpoint
     def test_is_tracked_upstream(self):
@@ -1472,20 +1474,19 @@ class RepositoryDatasetTest(RepositoryCommonTest):
             f"Does {WORKING_DATASET_DIR}/{self.REPO_NAME} exist: {os.path.exists(f'{WORKING_DATASET_DIR}/{self.REPO_NAME}')}"
         )
         self._api.create_repo(
-            token=self._token, name=self.REPO_NAME, repo_type="dataset"
+            token=self._token, repo_id=self.REPO_NAME, repo_type="dataset"
         )
 
     def tearDown(self):
         try:
             self._api.delete_repo(
-                name=self.REPO_NAME, token=self._token, repo_type="dataset"
+                repo_id=self.REPO_NAME, token=self._token, repo_type="dataset"
             )
         except requests.exceptions.HTTPError:
             try:
                 self._api.delete_repo(
-                    name=self.REPO_NAME,
+                    repo_id=f"valid_org/{self.REPO_NAME}",
                     token=self._token,
-                    organization="valid_org",
                     repo_type="dataset",
                 )
             except requests.exceptions.HTTPError:
diff --git a/tests/test_snapshot_download.py b/tests/test_snapshot_download.py
index 28a29003..8efd0c14 100644
--- a/tests/test_snapshot_download.py
+++ b/tests/test_snapshot_download.py
@@ -63,7 +63,7 @@ class SnapshotDownloadTests(unittest.TestCase):
         self.third_commit_hash = repo.git_head_hash()
 
     def tearDown(self) -> None:
-        self._api.delete_repo(name=REPO_NAME, token=self._token)
+        self._api.delete_repo(repo_id=REPO_NAME, token=self._token)
         shutil.rmtree(REPO_NAME)
 
     def test_download_model(self):