Skip to content

Commit

Permalink
fix: pass code lint
Browse files Browse the repository at this point in the history
Signed-off-by: OxalisCu <[email protected]>
  • Loading branch information
OxalisCu committed Sep 4, 2024
1 parent 15a31b4 commit 7b33c2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
25 changes: 5 additions & 20 deletions pymilvus/bulk_writer/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import logging
from pathlib import Path
from typing import Optional

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -43,12 +44,12 @@ def __init__(
self,
schema: CollectionSchema,
file_type: BulkFileType = BulkFileType.NUMPY,
config: dict = {},
config: Optional[dict] = None,
):
self._buffer = {}
self._fields = {}
self._file_type = file_type
self._config = config
self._config = config or {}
for field in schema.fields:
if field.is_primary and field.auto_id:
continue
Expand Down Expand Up @@ -289,7 +290,6 @@ def _persist_parquet(self, local_path: str, **kwargs):

def _persist_csv(self, local_path: str, **kwargs):
sep = self._config.get("sep", ",")
# nullkey = ""

header = list(self._buffer.keys())
data = []
Expand All @@ -300,21 +300,6 @@ def _persist_csv(self, local_path: str, **kwargs):
field_schema = self._fields[name]

# null is not supported yet
# if field_schema.nullable:
# if field_schema.dtype in {
# DataType.SPARSE_FLOAT_VECTOR,
# DataType.BINARY_VECTOR,
# DataType.FLOAT_VECTOR,
# DataType.FLOAT16_VECTOR,
# DataType.BFLOAT16_VECTOR,
# }:
# self._throw(f"vector field should not be nullable")
# else:
# row.append(
# nullkey if self._buffer[name][i] is None else self._buffer[name][i]
# )
# continue

# convert to string
if field_schema.dtype in {
DataType.JSON,
Expand All @@ -339,11 +324,11 @@ def _persist_csv(self, local_path: str, **kwargs):
row.append(str(self._buffer[name][i]))
data.append(row)

rows = [header] + data
rows = [header, *data]

file_path = Path(local_path + ".csv")
try:
with open(file_path, "w", encoding="utf-8") as f:
with file_path.open("w", encoding="utf-8") as f:
writer = csv.writer(f, delimiter=sep)
writer.writerows(rows)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion pymilvus/bulk_writer/bulk_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(
self._total_row_count = 0
self._file_type = file_type
self._buffer_lock = Lock()
self._config = config or {}
self._config = config

# the old parameter segment_size is changed to chunk_size, compatible with the legacy code
self._chunk_size = chunk_size
Expand Down

0 comments on commit 7b33c2c

Please sign in to comment.