-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1241 from tibor-reiss/feat_1168_fetch_objects_by_ids
feature: fetch_objects_by_ids
- Loading branch information
Showing
9 changed files
with
782 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
weaviate/collections/queries/fetch_objects_by_ids/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from .generate import _FetchObjectsByIDsGenerateAsync, _FetchObjectsByIDsGenerate | ||
from .query import _FetchObjectsByIDsQueryAsync, _FetchObjectsByIDsQuery | ||
|
||
__all__ = [ | ||
"_FetchObjectsByIDsGenerate", | ||
"_FetchObjectsByIDsGenerateAsync", | ||
"_FetchObjectsByIDsQuery", | ||
"_FetchObjectsByIDsQueryAsync", | ||
] |
75 changes: 75 additions & 0 deletions
75
weaviate/collections/queries/fetch_objects_by_ids/generate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from typing import Generic, Iterable, List, Optional | ||
|
||
from weaviate import syncify | ||
from weaviate.collections.classes.filters import Filter | ||
from weaviate.collections.classes.grpc import METADATA, Sorting | ||
from weaviate.collections.classes.internal import ( | ||
GenerativeReturnType, | ||
_Generative, | ||
ReturnProperties, | ||
ReturnReferences, | ||
_QueryOptions, | ||
) | ||
from weaviate.collections.classes.types import Properties, TProperties, References, TReferences | ||
from weaviate.collections.queries.base import _Base | ||
from weaviate.proto.v1 import search_get_pb2 | ||
from weaviate.types import UUID, INCLUDE_VECTOR | ||
|
||
|
||
class _FetchObjectsByIDsGenerateAsync( | ||
Generic[Properties, References], _Base[Properties, References] | ||
): | ||
async def fetch_objects_by_ids( | ||
self, | ||
ids: Iterable[UUID], | ||
*, | ||
single_prompt: Optional[str] = None, | ||
grouped_task: Optional[str] = None, | ||
grouped_properties: Optional[List[str]] = None, | ||
limit: Optional[int] = None, | ||
offset: Optional[int] = None, | ||
after: Optional[UUID] = None, | ||
sort: Optional[Sorting] = None, | ||
include_vector: INCLUDE_VECTOR = False, | ||
return_metadata: Optional[METADATA] = None, | ||
return_properties: Optional[ReturnProperties[TProperties]] = None, | ||
return_references: Optional[ReturnReferences[TReferences]] = None | ||
) -> GenerativeReturnType[Properties, References, TProperties, TReferences]: | ||
"""Special case of fetch_objects based on filters on uuid""" | ||
if not ids: | ||
res = search_get_pb2.SearchReply(results=None) | ||
else: | ||
res = await self._query.get( | ||
limit=limit, | ||
offset=offset, | ||
after=after, | ||
filters=Filter.any_of([Filter.by_id().equal(uuid) for uuid in ids]), | ||
sort=sort, | ||
return_metadata=self._parse_return_metadata(return_metadata, include_vector), | ||
return_properties=self._parse_return_properties(return_properties), | ||
return_references=self._parse_return_references(return_references), | ||
generative=_Generative( | ||
single=single_prompt, | ||
grouped=grouped_task, | ||
grouped_properties=grouped_properties, | ||
), | ||
) | ||
return self._result_to_generative_query_return( | ||
res, | ||
_QueryOptions.from_input( | ||
return_metadata, | ||
return_properties, | ||
include_vector, | ||
self._references, | ||
return_references, | ||
), | ||
return_properties, | ||
return_references, | ||
) | ||
|
||
|
||
@syncify.convert | ||
class _FetchObjectsByIDsGenerate( | ||
Generic[Properties, References], _FetchObjectsByIDsGenerateAsync[Properties, References] | ||
): | ||
pass |
Oops, something went wrong.