Skip to content

Commit 728b59b

Browse files
committed
fix(bulk_writer): preserve remote upload prefixes on Windows
Signed-off-by: VectorPeak <73048950+VectorPeak@users.noreply.github.com>
1 parent fd9b79a commit 728b59b

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

pymilvus/bulk_writer/remote_bulk_writer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,12 @@ def _upload(self, file_list: list):
294294
if ext not in [".json", ".jsonl", ".npy", ".parquet", ".csv"]:
295295
continue
296296

297-
relative_file_path = str(file_path).replace(str(super().data_path), "")
298-
minio_file_path = str(
299-
Path.joinpath(self._remote_path, relative_file_path.lstrip("/"))
300-
).lstrip("/")
297+
relative_file_path = (
298+
Path(file_path).resolve().relative_to(super().data_path).as_posix()
299+
)
300+
minio_file_path = (
301+
f"{self._remote_path.as_posix().strip('/')}/{relative_file_path}"
302+
)
301303

302304
if self._object_exists(minio_file_path):
303305
logger.info(

tests/unit/test_remote_bulk_writer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ def test_upload_jsonl_file(self, tmp_path):
112112
uploaded_files = writer._upload([str(jsonl_file)])
113113

114114
assert len(uploaded_files) == 1
115-
assert uploaded_files[0].endswith(".jsonl")
115+
assert uploaded_files[0].endswith("/1.jsonl")
116116
mock_upload_object.assert_called_once()
117117
_, kwargs = mock_upload_object.call_args
118118
assert kwargs["file_path"].endswith(".jsonl")
119-
assert kwargs["object_name"].endswith(".jsonl")
119+
assert kwargs["object_name"] == uploaded_files[0]
120+
assert kwargs["object_name"].endswith("/1.jsonl")
121+
assert "bulk/test/" in kwargs["object_name"]
122+
assert "\\" not in kwargs["object_name"]
120123
mock_local_rm.assert_called_once_with(str(jsonl_file))
121-
assert writer.batch_files[0][0].endswith(".jsonl")
124+
assert writer.batch_files[0][0] == uploaded_files[0]

0 commit comments

Comments
 (0)