Skip to content

Commit 14565f0

Browse files
Wauplinhanouticelina
authored andcommitted
[v1.0] Remove Repository class (#3346)
* Remove Repository class + adapt docs * remove fr git_vs_http
1 parent dd9d996 commit 14565f0

File tree

22 files changed

+5
-3379
lines changed

22 files changed

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

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 & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -172,82 +172,3 @@ that you should be aware of. For example, you can't transfer your repo to anothe
172172
>>> from huggingface_hub import move_repo
173173
>>> move_repo(from_id="Wauplin/cool-model", to_id="huggingface/cool-model")
174174
```
175-
176-
## Manage a local copy of your repository
177-
178-
All the actions described above can be done using HTTP requests. However, in some cases you might be interested in having
179-
a local copy of your repository and interact with it using the Git commands you are familiar with.
180-
181-
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).
182-
183-
> [!WARNING]
184-
> [`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).
185-
186-
### Use a local repository
187-
188-
Instantiate a [`Repository`] object with a path to a local repository:
189-
190-
```py
191-
>>> from huggingface_hub import Repository
192-
>>> repo = Repository(local_dir="<path>/<to>/<folder>")
193-
```
194-
195-
### Clone
196-
197-
The `clone_from` parameter clones a repository from a Hugging Face repository ID to a local directory specified by the `local_dir` argument:
198-
199-
```py
200-
>>> from huggingface_hub import Repository
201-
>>> repo = Repository(local_dir="w2v2", clone_from="facebook/wav2vec2-large-960h-lv60")
202-
```
203-
204-
`clone_from` can also clone a repository using a URL:
205-
206-
```py
207-
>>> repo = Repository(local_dir="huggingface-hub", clone_from="https://huggingface.co/facebook/wav2vec2-large-960h-lv60")
208-
```
209-
210-
You can combine the `clone_from` parameter with [`create_repo`] to create and clone a repository:
211-
212-
```py
213-
>>> repo_url = create_repo(repo_id="repo_name")
214-
>>> repo = Repository(local_dir="repo_local_path", clone_from=repo_url)
215-
```
216-
217-
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.
218-
219-
```py
220-
>>> repo = Repository(
221-
... "my-dataset",
222-
... clone_from="<user>/<dataset_id>",
223-
... token=True,
224-
... repo_type="dataset",
225-
... git_user="MyName",
226-
... git_email="me@cool.mail"
227-
... )
228-
```
229-
230-
### Branch
231-
232-
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`:
233-
234-
```py
235-
>>> from huggingface_hub import Repository
236-
>>> repo = Repository(local_dir="huggingface-hub", clone_from="<user>/<dataset_id>", revision='branch1')
237-
>>> repo.git_checkout("branch2")
238-
```
239-
240-
### Pull
241-
242-
[`~Repository.git_pull`] allows you to update a current local branch with changes from a remote repository:
243-
244-
```py
245-
>>> from huggingface_hub import Repository
246-
>>> repo.git_pull()
247-
```
248-
249-
Set `rebase=True` if you want your local commits to occur after your branch is updated with the new commits from the remote:
250-
251-
```py
252-
>>> repo.git_pull(rebase=True)
253-
```

0 commit comments

Comments
 (0)