Skip to content

Commit 848d459

Browse files
authored
Merge pull request #162 from facultyai/datasets-mv-fix
Make `datasets.mv` do nothing if source and destination are the same
2 parents fa0337f + 659352e commit 848d459

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

faculty/datasets/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ def mv(source_path, destination_path, project_id=None, object_client=None):
334334
project_id = project_id or get_context().project_id
335335
object_client = object_client or ObjectClient(get_session())
336336

337+
if source_path == destination_path:
338+
return
339+
337340
cp(
338341
source_path,
339342
destination_path,

tests/datasets/test_init.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,16 @@ def test_mv(mocker, mock_client):
439439
)
440440

441441

442+
def test_mv_identical_source_and_destination(mocker, mock_client):
443+
cp_mock = mocker.patch("faculty.datasets.cp")
444+
rm_mock = mocker.patch("faculty.datasets.rm")
445+
446+
datasets.mv("source-path", "source-path", project_id=PROJECT_ID)
447+
448+
cp_mock.assert_not_called()
449+
rm_mock.assert_not_called()
450+
451+
442452
def test_etag(mocker, mock_client):
443453
object_mock = mocker.Mock()
444454
object_mock.etag = "test-etag"

0 commit comments

Comments
 (0)