Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Deprecate clone_from behavior #952

Merged
merged 29 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1aa664a
deprecate clone_from behavior
merveenoyan Jul 21, 2022
5c78379
added warnings import
merveenoyan Jul 21, 2022
ccbd583
make style
merveenoyan Jul 21, 2022
1bec939
added test
merveenoyan Jul 21, 2022
792af11
added repo creation to test setups
merveenoyan Jul 21, 2022
da18a5a
modified test to skip repo creation during setup
merveenoyan Jul 21, 2022
17deae2
fixed remaining of the tests by adding create_repo
merveenoyan Jul 21, 2022
a82b09d
fixed tests
merveenoyan Jul 22, 2022
b871f3d
fixed tests
merveenoyan Jul 22, 2022
8fd2f74
shifted head and added changes on top
merveenoyan Aug 1, 2022
1953d2a
shifted head and added changes on top
merveenoyan Aug 1, 2022
c2c61a4
Revert "shifted head and added changes on top"
merveenoyan Aug 1, 2022
b179f67
Revert "fixed tests"
merveenoyan Aug 1, 2022
7eff5e3
Revert "fixed tests"
merveenoyan Aug 1, 2022
684d822
Revert "fixed remaining of the tests by adding create_repo"
merveenoyan Aug 1, 2022
d11e626
Revert "modified test to skip repo creation during setup"
merveenoyan Aug 1, 2022
275c757
Revert "added repo creation to test setups"
merveenoyan Aug 1, 2022
9c933ca
reverted changes
merveenoyan Aug 1, 2022
f1704e3
updated version
merveenoyan Aug 1, 2022
79fc043
Merge branch 'main' into clone_from_deprecation
Wauplin Aug 18, 2022
19e82fc
expect deprecation for clone_from in tests
Wauplin Aug 18, 2022
e642740
Merge pull request #1 from huggingface/clone_from_deprecation_add_exp…
merveenoyan Aug 29, 2022
a1898e6
Merge branch 'main' into clone_from_deprecation
merveenoyan Aug 29, 2022
f5351f7
make style
merveenoyan Aug 29, 2022
d05d083
Update tests/test_repository.py
Wauplin Aug 29, 2022
12b47cd
Update tests/test_repository.py
Wauplin Aug 29, 2022
0e82e9e
fixed tests
merveenoyan Aug 29, 2022
30196f4
fixed tests
merveenoyan Aug 29, 2022
801c560
make style
merveenoyan Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/huggingface_hub/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import tempfile
import threading
import time
import warnings
from contextlib import contextmanager
from pathlib import Path
from typing import Callable, Dict, Iterator, List, Optional, Tuple, Union
Expand Down Expand Up @@ -655,6 +656,12 @@ def clone_from(self, repo_url: str, use_auth_token: Union[bool, str, None] = Non
" on Hugging Face Hub."
)
else:
warnings.warn(
"Creating a repository through clone_from is deprecated"
"will be removed in v0.11.",
FutureWarning,
)

self.client.create_repo(
repo_id=repo_id,
token=token,
Expand Down
11 changes: 11 additions & 0 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ def test_clone_from_space(self):
use_auth_token=self._token,
)

def test_clone_from_deprecation_warning(self):
with pytest.warns(
FutureWarning,
match="Creating a repository through clone_from is deprecated*",
Wauplin marked this conversation as resolved.
Show resolved Hide resolved
):
Repository(
WORKING_REPO_DIR,
clone_from=f"{USER}/{uuid.uuid4()}",
use_auth_token=self._token,
)

def test_clone_from_model(self):
temp_repo_url = self._api.create_repo(
repo_id=f"{self.REPO_NAME}-temp", token=self._token, repo_type="model"
Expand Down