Skip to content

Commit

Permalink
fix: regen async
Browse files Browse the repository at this point in the history
  • Loading branch information
joein committed Apr 15, 2024
1 parent 078f9d9 commit 7d40b76
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions qdrant_client/local/async_qdrant_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, location: str, force_disable_check_same_thread: bool = False)
self._load()
self._closed: bool = False

@property
def closed(self) -> bool:
return self._closed

Expand Down Expand Up @@ -129,6 +130,8 @@ def _load(self) -> None:
def _save(self) -> None:
if not self.persistent:
return
if self.closed:
raise RuntimeError("QdrantLocal instance is closed. Please create a new instance.")
meta_path = os.path.join(self.location, META_INFO_FILENAME)
with open(meta_path, "w") as f:
f.write(
Expand All @@ -144,6 +147,8 @@ def _save(self) -> None:
)

def _get_collection(self, collection_name: str) -> LocalCollection:
if self.closed:
raise RuntimeError("QdrantLocal instance is closed. Please create a new instance.")
if collection_name in self.collections:
return self.collections[collection_name]
if collection_name in self.aliases:
Expand Down Expand Up @@ -552,6 +557,8 @@ async def update_collection_aliases(
async def get_collection_aliases(
self, collection_name: str, **kwargs: Any
) -> types.CollectionsAliasesResponse:
if self.closed:
raise RuntimeError("QdrantLocal instance is closed. Please create a new instance.")
return types.CollectionsAliasesResponse(
aliases=[
rest_models.AliasDescription(alias_name=alias_name, collection_name=name)
Expand All @@ -561,6 +568,8 @@ async def get_collection_aliases(
)

async def get_aliases(self, **kwargs: Any) -> types.CollectionsAliasesResponse:
if self.closed:
raise RuntimeError("QdrantLocal instance is closed. Please create a new instance.")
return types.CollectionsAliasesResponse(
aliases=[
rest_models.AliasDescription(alias_name=alias_name, collection_name=name)
Expand All @@ -569,6 +578,8 @@ async def get_aliases(self, **kwargs: Any) -> types.CollectionsAliasesResponse:
)

async def get_collections(self, **kwargs: Any) -> types.CollectionsResponse:
if self.closed:
raise RuntimeError("QdrantLocal instance is closed. Please create a new instance.")
return types.CollectionsResponse(
collections=[
rest_models.CollectionDescription(name=name)
Expand Down Expand Up @@ -598,6 +609,8 @@ def _collection_path(self, collection_name: str) -> Optional[str]:
return None

async def delete_collection(self, collection_name: str, **kwargs: Any) -> bool:
if self.closed:
raise RuntimeError("QdrantLocal instance is closed. Please create a new instance.")
_collection = self.collections.pop(collection_name, None)
del _collection
self.aliases = {
Expand All @@ -619,6 +632,8 @@ async def create_collection(
sparse_vectors_config: Optional[Mapping[str, types.SparseVectorParams]] = None,
**kwargs: Any,
) -> bool:
if self.closed:
raise RuntimeError("QdrantLocal instance is closed. Please create a new instance.")
src_collection = None
from_collection_name = None
if init_from is not None:
Expand Down

0 comments on commit 7d40b76

Please sign in to comment.