-
Notifications
You must be signed in to change notification settings - Fork 572
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
Changes from 9 commits
1aa664a
5c78379
ccbd583
1bec939
792af11
da18a5a
17deae2
a82b09d
b871f3d
8fd2f74
1953d2a
c2c61a4
b179f67
7eff5e3
684d822
d11e626
275c757
9c933ca
f1704e3
79fc043
19e82fc
e642740
a1898e6
f5351f7
d05d083
12b47cd
0e82e9e
30196f4
801c560
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,9 +204,12 @@ def setUpClass(cls): | |
def setUp(self) -> None: | ||
self.repo_path = Path(tempfile.mkdtemp()) | ||
self.REPO_NAME = repo_name() | ||
url = self._api.create_repo( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When adding some changes, if you have to change tests, that's a red flag to watch out! As you're just adding a warning, nothing should change in any existing tests. It's ok if current tests depend on |
||
repo_id=f"{USER}/{self.REPO_NAME}", token=self._token | ||
) | ||
self.repo = Repository( | ||
self.repo_path / self.REPO_NAME, | ||
clone_from=f"{USER}/{self.REPO_NAME}", | ||
clone_from=url, | ||
use_auth_token=self._token, | ||
git_user="ci", | ||
git_email="ci@dummy.com", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,16 +81,19 @@ def setUp(self): | |
logger.info( | ||
f"Does {WORKING_REPO_DIR} exist: {os.path.exists(WORKING_REPO_DIR)}" | ||
) | ||
|
||
self.REPO_NAME = repo_name() | ||
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", | ||
repo_id=f"{USER}/{self.REPO_NAME}", | ||
token=self._token, | ||
) | ||
# skip creation of repository for clone from test | ||
if self.shortDescription() != "SKIP CREATION": | ||
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", | ||
repo_id=f"{USER}/{self.REPO_NAME}", | ||
token=self._token, | ||
) | ||
|
||
def tearDown(self): | ||
try: | ||
|
@@ -140,6 +143,19 @@ def test_clone_from_space(self): | |
use_auth_token=self._token, | ||
) | ||
|
||
def test_clone_from_deprecation_warning(self): | ||
"""SKIP CREATION""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would remove this docstring as the name of the test is already great 🔥 |
||
with pytest.raises( | ||
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, | ||
repo_type="dataset", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: feel free to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did it because there was two of those tests, one was for model repository and one was for dataset repository. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that given the behaviour you're changing is ok to just cover one case |
||
) | ||
|
||
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" | ||
|
@@ -437,9 +453,15 @@ def test_clone_with_endpoint(self): | |
|
||
@retry_endpoint | ||
def test_clone_with_repo_name_and_org(self): | ||
repo_url = self._api.create_repo( | ||
token=self._token, | ||
repo_id=f"valid_org/{self.REPO_NAME}", | ||
repo_type="dataset", | ||
) | ||
|
||
clone = Repository( | ||
f"{WORKING_REPO_DIR}/{self.REPO_NAME}", | ||
clone_from=f"valid_org/{self.REPO_NAME}", | ||
clone_from=repo_url, | ||
use_auth_token=self._token, | ||
git_user="ci", | ||
git_email="ci@dummy.com", | ||
|
@@ -455,7 +477,7 @@ def test_clone_with_repo_name_and_org(self): | |
|
||
Repository( | ||
f"{WORKING_REPO_DIR}/{self.REPO_NAME}", | ||
clone_from=f"valid_org/{self.REPO_NAME}", | ||
clone_from=repo_url, | ||
use_auth_token=self._token, | ||
git_user="ci", | ||
git_email="ci@dummy.com", | ||
|
@@ -1698,6 +1720,11 @@ def test_clone_with_endpoint(self): | |
|
||
@retry_endpoint | ||
def test_clone_with_repo_name_and_org(self): | ||
self._api.create_repo( | ||
token=self._token, | ||
repo_id=f"valid_org/{self.REPO_NAME}", | ||
repo_type="dataset", | ||
) | ||
clone = Repository( | ||
f"{WORKING_DATASET_DIR}/{self.REPO_NAME}", | ||
clone_from=f"valid_org/{self.REPO_NAME}", | ||
|
@@ -1761,7 +1788,7 @@ def test_clone_with_repo_name_and_no_namespace(self): | |
self.assertRaises( | ||
OSError, | ||
Repository, | ||
f"{WORKING_DATASET_DIR}/{self.REPO_NAME}", | ||
f"{WORKING_REPO_DIR}/{self.REPO_NAME}", | ||
clone_from=self.REPO_NAME, | ||
repo_type="dataset", | ||
use_auth_token=self._token, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's change this to v0.11., as 0.9 is already the next release, that way we have 2 releases before deprecating