Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
chore: bump tensorflow
Signed-off-by: jupyterjazz <[email protected]>
  • Loading branch information
jupyterjazz committed Jul 13, 2023
commit 9ddb0ffcf2dbcc399bf9094e3be6a617a6e4ea52
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install poetry
poetry install --without dev
poetry run pip install tensorflow==2.11.0
poetry run pip install tensorflow==2.12.0
- name: Test basic import
run: poetry run python -c 'from docarray import DocList, BaseDoc'

Expand Down Expand Up @@ -242,7 +242,7 @@ jobs:
python -m pip install poetry
poetry install --all-extras
poetry run pip install protobuf==3.20.0
poetry run pip install tensorflow==2.11.0
poetry run pip install tensorflow==2.12.0
sudo apt-get update
sudo apt-get install --no-install-recommends ffmpeg

Expand Down Expand Up @@ -287,7 +287,7 @@ jobs:
python -m pip install poetry
poetry install --all-extras
poetry run pip install protobuf==3.20.0
poetry run pip install tensorflow==2.11.0
poetry run pip install tensorflow==2.12.0
poetry run pip install elasticsearch==8.6.2
sudo apt-get update
sudo apt-get install --no-install-recommends ffmpeg
Expand Down Expand Up @@ -332,7 +332,7 @@ jobs:
python -m pip install poetry
poetry install --all-extras
poetry run pip install protobuf==3.20.0
poetry run pip install tensorflow==2.11.0
poetry run pip install tensorflow==2.12.0
sudo apt-get update
sudo apt-get install --no-install-recommends ffmpeg

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ Like the [PyTorch approach](#coming-from-pytorch), you can also use DocArray wit
First off, to use DocArray with TensorFlow we first need to install it as follows:

```
pip install tensorflow==2.11.0
pip install tensorflow==2.12.0
pip install protobuf==3.19.0
```

Expand Down
26 changes: 16 additions & 10 deletions docarray/index/backends/milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from docarray import BaseDoc, DocList
from docarray.index.abstract import BaseDocIndex
from docarray.index.backends.helper import _execute_find_and_filter_query
from docarray.typing import AnyTensor
from docarray.typing import AnyTensor, NdArray
from docarray.typing.id import ID
from docarray.typing.tensor.abstract_tensor import AbstractTensor
from docarray.utils._internal._typing import safe_issubclass
Expand All @@ -42,6 +42,7 @@
FieldSchema,
connections,
utility,
Hits,
)
else:
from pymilvus import (
Expand All @@ -51,6 +52,7 @@
FieldSchema,
connections,
utility,
Hits,
)

ID_VARCHAR_LEN = 1024
Expand Down Expand Up @@ -88,7 +90,7 @@ def __init__(self, db_config=None, **kwargs):
class DBConfig(BaseDocIndex.DBConfig):
"""Dataclass that contains all "static" configurations of MilvusDocumentIndex."""

collection_name: str = None
collection_name: Optional[str] = None
collection_description: str = ""
host: str = "localhost"
port: int = 19530
Expand Down Expand Up @@ -286,7 +288,7 @@ def index(self, docs: Union[BaseDoc, Sequence[BaseDoc]], **kwargs):
self._update_subindex_data(docs_validated)

docs = self._validate_docs(docs)
entities = [[] for _ in range(len(self._collection.schema))]
entities: List[List[Any]] = [[] for _ in range(len(self._collection.schema))]

for i in range(len(docs)):
entities[0].append(docs[i].to_base64(**self._db_config.serialize_config))
Expand Down Expand Up @@ -571,9 +573,9 @@ def execute_query(self, query: Any, *args, **kwargs) -> Any:
def _check_loaded(self):
"""This function checks if the collection is loaded and loads it if necessary"""

self._collection.load() and setattr(
self, "_loaded", True
) if not self._loaded else None
if not self._loaded:
self._collection.load()
self._loaded = True

def _docs_from_query_response(self, result: Sequence[Dict]) -> Sequence[TSchema]:
return DocList[self._schema](
Expand All @@ -585,7 +587,11 @@ def _docs_from_query_response(self, result: Sequence[Dict]) -> Sequence[TSchema]
]
)

def _docs_from_find_response(self, result: str) -> _FindResult:
def _docs_from_find_response(self, result: Hits) -> _FindResult:
scores: NdArray = NdArray._docarray_from_native(
np.array([hit.score for hit in result])
)

return _FindResult(
documents=DocList[self._schema](
[
Expand All @@ -595,7 +601,7 @@ def _docs_from_find_response(self, result: str) -> _FindResult:
for hit in result
]
),
scores=[hit.score for hit in result],
scores=scores,
)

def _always_true_expr(self, primary_key: str) -> str:
Expand All @@ -608,7 +614,7 @@ def _always_true_expr(self, primary_key: str) -> str:
"""
return f'({primary_key} in ["1"]) or ({primary_key} not in ["1"])'

def _map_embedding(self, embedding: Optional[AnyTensor]) -> AnyTensor:
def _map_embedding(self, embedding: Optional[AnyTensor]) -> Optional[AnyTensor]:
"""
Milvus exclusively supports one-dimensional vectors. If multi-dimensional
vectors are provided, they will be automatically flattened to ensure compatibility.
Expand All @@ -623,7 +629,7 @@ def _map_embedding(self, embedding: Optional[AnyTensor]) -> AnyTensor:
if embedding.ndim > 1:
embedding = np.asarray(embedding).squeeze()
else:
embedding = np.zeros(self._config.n_dim)
embedding = np.zeros(self._db_config.n_dim)
return embedding

def __contains__(self, item) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ web = ["fastapi"]
qdrant = ["qdrant-client"]
weaviate = ["weaviate-client"]
milvus = ["pymilvus"]
redis = ['redis']
redis = ["redis"]

# all
full = ["protobuf", "lz4", "pandas", "pillow", "types-pillow", "av", "pydub", "trimesh"]
Expand Down