Skip to content

Commit

Permalink
feat(syft/store): most methods of MongoBackingStore implemented. Only…
Browse files Browse the repository at this point in the history
… `copy` and `update` left
  • Loading branch information
khoaguin committed Oct 13, 2023
1 parent a6a8913 commit bca8ecc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions packages/syft/src/syft/store/mongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,6 @@ def with_collection_permissions(
return Err(str(e))

return Ok(collection_permissions)

def close(self):
self.client.close()
24 changes: 15 additions & 9 deletions packages/syft/src/syft/store/mongo_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,12 @@ def __init__(
self.index_name = index_name
self.settings = settings
self.store_config = store_config
self.client: MongoClient

def init_client(self) -> Union[None, Err]:
client = MongoClient(config=self.store_config.client_config)
self.client = MongoClient(config=self.store_config.client_config)

collection_status = client.with_collection(
collection_status = self.client.with_collection(
collection_settings=self.settings,
store_config=self.store_config,
collection_name=f"{self.settings.name}_{self.index_name}",
Expand Down Expand Up @@ -745,29 +746,34 @@ def pop(self, key: Any) -> Self:
self._delete(key)
return value

def __contains__(self, item: Any) -> bool:
raise NotImplementedError
def __contains__(self, key: Any) -> bool:
return self._exist(key)

def __iter__(self) -> Any:
raise NotImplementedError
return iter(self.keys())

def __repr__(self) -> str:
# 🟡 TODO
raise NotImplementedError
return repr(self._get_all())

def copy(self) -> Self:
# 🟡 TODO
raise NotImplementedError

def update(self, *args: Any, **kwargs: Any) -> Self:
"""
Inserts the specified items to the dictionary.
"""
# 🟡 TODO
raise NotImplementedError

def __del__(self):
"""
Close the mongo client connection
Close the mongo client connection:
- Cleanup client resources and disconnect from MongoDB
- End all server sessions created by this client
- Close all sockets in the connection pools and stop the monitor threads
"""
raise NotImplementedError
self.client.close()


@serializable()
Expand Down

0 comments on commit bca8ecc

Please sign in to comment.