Skip to content

Commit 72c53f4

Browse files
authored
[v1.0] Remove Repository class (#3346)
* Remove Repository class + adapt docs * remove fr git_vs_http
1 parent 966df29 commit 72c53f4

File tree

22 files changed

+5
-3409
lines changed

22 files changed

+5
-3409
lines changed

.github/workflows/python-tests.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
python-version: ["3.9", "3.13"]
25-
test_name:
26-
[
27-
"Repository only",
28-
"Everything else",
29-
"Inference only",
30-
"Xet only"
31-
]
25+
test_name: ["Everything else", "Inference only", "Xet only"]
3226
include:
3327
- python-version: "3.13" # LFS not ran on 3.9
3428
test_name: "lfs"
@@ -65,7 +59,7 @@ jobs:
6559
6660
case "${{ matrix.test_name }}" in
6761
68-
"Repository only" | "Everything else" | "Inference only")
62+
"Everything else" | "Inference only")
6963
sudo apt update
7064
sudo apt install -y libsndfile1-dev
7165
;;
@@ -112,13 +106,6 @@ jobs:
112106
113107
case "${{ matrix.test_name }}" in
114108
115-
"Repository only")
116-
# Run repo tests concurrently
117-
PYTEST="$PYTEST ../tests -k 'TestRepository' -n 4"
118-
echo $PYTEST
119-
eval $PYTEST
120-
;;
121-
122109
"Inference only")
123110
# Run inference tests concurrently
124111
PYTEST="$PYTEST ../tests -k 'test_inference' -n 4"

docs/source/cn/_toctree.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@
2020
title: 概览
2121
- local: guides/hf_file_system
2222
title: Hugging Face 文件系统
23-
- title: "concepts"
24-
sections:
25-
- local: concepts/git_vs_http
26-
title: Git vs HTTP 范式
23+

docs/source/cn/concepts/git_vs_http.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

docs/source/cn/guides/repository.md

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -156,91 +156,3 @@ GitRefs(
156156
>>> from huggingface_hub import move_repo
157157
>>> move_repo(from_id="Wauplin/cool-model", to_id="huggingface/cool-model")
158158
```
159-
160-
## 管理存储库的本地副本
161-
162-
上述所有操作都可以通过HTTP请求完成。然而,在某些情况下,您可能希望在本地拥有存储库的副本,并使用您熟悉的Git命令与之交互。
163-
164-
[`Repository`] 类允许您使用类似于Git命令的函数与Hub上的文件和存储库进行交互。它是对Git和Git-LFS方法的包装,以使用您已经了解和喜爱的Git命令。在开始之前,请确保已安装Git-LFS(请参阅[此处](https://git-lfs.github.com/)获取安装说明)。
165-
166-
### 使用本地存储库
167-
168-
使用本地存储库路径实例化一个 [`Repository`] 对象:
169-
170-
请运行以下代码:
171-
172-
```py
173-
>>> from huggingface_hub import Repository
174-
>>> repo = Repository(local_dir="<path>/<to>/<folder>")
175-
```
176-
177-
### 克隆
178-
179-
`clone_from`参数将一个存储库从Hugging Face存储库ID克隆到由 `local_dir`参数指定的本地目录:
180-
181-
请运行以下代码:
182-
183-
```py
184-
>>> from huggingface_hub import Repository
185-
>>> repo = Repository(local_dir="w2v2", clone_from="facebook/wav2vec2-large-960h-lv60")
186-
```
187-
`clone_from`还可以使用URL克隆存储库:
188-
189-
请运行以下代码:
190-
191-
```py
192-
>>> repo = Repository(local_dir="huggingface-hub", clone_from="https://huggingface.co/facebook/wav2vec2-large-960h-lv60")
193-
```
194-
195-
你可以将`clone_from`参数与[`create_repo`]结合使用,以创建并克隆一个存储库:
196-
197-
请运行以下代码:
198-
199-
```py
200-
>>> repo_url = create_repo(repo_id="repo_name")
201-
>>> repo = Repository(local_dir="repo_local_path", clone_from=repo_url)
202-
```
203-
204-
当你克隆一个存储库时,通过在克隆时指定`git_user``git_email`参数,你还可以为克隆的存储库配置Git用户名和电子邮件。当用户提交到该存储库时,Git将知道提交的作者是谁。
205-
206-
请运行以下代码:
207-
208-
```py
209-
>>> repo = Repository(
210-
... "my-dataset",
211-
... clone_from="<user>/<dataset_id>",
212-
... token=True,
213-
... repo_type="dataset",
214-
... git_user="MyName",
215-
... git_email="me@cool.mail"
216-
... )
217-
```
218-
219-
### 分支
220-
221-
分支对于协作和实验而不影响当前文件和代码非常重要。使用[`~Repository.git_checkout`]来在不同的分支之间切换。例如,如果你想从 `branch1`切换到 `branch2`
222-
223-
请运行以下代码:
224-
225-
```py
226-
>>> from huggingface_hub import Repository
227-
>>> repo = Repository(local_dir="huggingface-hub", clone_from="<user>/<dataset_id>", revision='branch1')
228-
>>> repo.git_checkout("branch2")
229-
```
230-
231-
### 拉取
232-
233-
[`~Repository.git_pull`] 允许你使用远程存储库的更改更新当前本地分支:
234-
235-
请运行以下代码:
236-
237-
```py
238-
>>> from huggingface_hub import Repository
239-
>>> repo.git_pull()
240-
```
241-
242-
如果你希望本地的提交发生在你的分支被远程的新提交更新之后,请设置`rebase=True`
243-
244-
```py
245-
>>> repo.git_pull(rebase=True)
246-
```

docs/source/de/_toctree.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,3 @@
3434
title: Integrieren einer Bibliothek
3535
- local: guides/webhooks_server
3636
title: Webhooks server
37-
- title: "Konzeptionelle Anleitungen"
38-
sections:
39-
- local: concepts/git_vs_http
40-
title: Git vs. HTTP-Paradigma

docs/source/de/concepts/git_vs_http.md

Lines changed: 0 additions & 69 deletions
This file was deleted.

docs/source/en/_toctree.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
title: Authentication
5555
- local: package_reference/environment_variables
5656
title: Environment variables
57-
- local: package_reference/repository
58-
title: Managing local and online repositories
5957
- local: package_reference/hf_api
6058
title: Hugging Face Hub API
6159
- local: package_reference/file_download

docs/source/en/guides/repository.md

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -178,85 +178,3 @@ that you should be aware of. For example, you can't transfer your repo to anothe
178178
>>> from huggingface_hub import move_repo
179179
>>> move_repo(from_id="Wauplin/cool-model", to_id="huggingface/cool-model")
180180
```
181-
182-
## Manage a local copy of your repository
183-
184-
All the actions described above can be done using HTTP requests. However, in some cases you might be interested in having
185-
a local copy of your repository and interact with it using the Git commands you are familiar with.
186-
187-
The [`Repository`] class allows you to interact with files and repositories on the Hub with functions similar to Git commands. It is a wrapper over Git and Git-LFS methods to use the Git commands you already know and love. Before starting, please make sure you have Git-LFS installed (see [here](https://git-lfs.github.com/) for installation instructions).
188-
189-
<Tip warning={true}>
190-
191-
[`Repository`] is deprecated in favor of the http-based alternatives implemented in [`HfApi`]. Given its large adoption in legacy code, the complete removal of [`Repository`] will only happen in release `v1.0`. For more details, please read [this explanation page](./concepts/git_vs_http).
192-
193-
</Tip>
194-
195-
### Use a local repository
196-
197-
Instantiate a [`Repository`] object with a path to a local repository:
198-
199-
```py
200-
>>> from huggingface_hub import Repository
201-
>>> repo = Repository(local_dir="<path>/<to>/<folder>")
202-
```
203-
204-
### Clone
205-
206-
The `clone_from` parameter clones a repository from a Hugging Face repository ID to a local directory specified by the `local_dir` argument:
207-
208-
```py
209-
>>> from huggingface_hub import Repository
210-
>>> repo = Repository(local_dir="w2v2", clone_from="facebook/wav2vec2-large-960h-lv60")
211-
```
212-
213-
`clone_from` can also clone a repository using a URL:
214-
215-
```py
216-
>>> repo = Repository(local_dir="huggingface-hub", clone_from="https://huggingface.co/facebook/wav2vec2-large-960h-lv60")
217-
```
218-
219-
You can combine the `clone_from` parameter with [`create_repo`] to create and clone a repository:
220-
221-
```py
222-
>>> repo_url = create_repo(repo_id="repo_name")
223-
>>> repo = Repository(local_dir="repo_local_path", clone_from=repo_url)
224-
```
225-
226-
You can also configure a Git username and email to a cloned repository by specifying the `git_user` and `git_email` parameters when you clone a repository. When users commit to that repository, Git will be aware of the commit author.
227-
228-
```py
229-
>>> repo = Repository(
230-
... "my-dataset",
231-
... clone_from="<user>/<dataset_id>",
232-
... token=True,
233-
... repo_type="dataset",
234-
... git_user="MyName",
235-
... git_email="me@cool.mail"
236-
... )
237-
```
238-
239-
### Branch
240-
241-
Branches are important for collaboration and experimentation without impacting your current files and code. Switch between branches with [`~Repository.git_checkout`]. For example, if you want to switch from `branch1` to `branch2`:
242-
243-
```py
244-
>>> from huggingface_hub import Repository
245-
>>> repo = Repository(local_dir="huggingface-hub", clone_from="<user>/<dataset_id>", revision='branch1')
246-
>>> repo.git_checkout("branch2")
247-
```
248-
249-
### Pull
250-
251-
[`~Repository.git_pull`] allows you to update a current local branch with changes from a remote repository:
252-
253-
```py
254-
>>> from huggingface_hub import Repository
255-
>>> repo.git_pull()
256-
```
257-
258-
Set `rebase=True` if you want your local commits to occur after your branch is updated with the new commits from the remote:
259-
260-
```py
261-
>>> repo.git_pull(rebase=True)
262-
```

0 commit comments

Comments
 (0)