Skip to content

Commit

Permalink
force serde/deserde of values in MongoBackingStore before saving to s…
Browse files Browse the repository at this point in the history
…tore

- fix DEFAULT_CHUNK_SIZE for seaweed
  • Loading branch information
shubham3121 committed Oct 22, 2023
1 parent c781453 commit 4cdc87a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/syft/src/syft/store/blob_storage/seaweedfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

READ_EXPIRATION_TIME = 1800 # seconds
WRITE_EXPIRATION_TIME = 900 # seconds
DEFAULT_CHUNK_SIZE = 1024**2 # 1 GB
DEFAULT_CHUNK_SIZE = 1024**3 # 1 GB


def _byte_chunks(bytes: BytesIO, size: int) -> Generator[bytes, None, None]:
Expand Down
8 changes: 4 additions & 4 deletions packages/syft/src/syft/store/mongo_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def _set(self, key: UID, value: Any) -> None:
try:
bson_data = {
"_id": key,
f"{key}": value,
f"{key}": _serialize(value, to_bytes=True),
"_repr_debug_": _repr_debug_(value),
}
collection.insert_one(bson_data)
Expand All @@ -667,7 +667,7 @@ def _update(self, key: UID, value: Any) -> None:
{"_id": key},
{
"$set": {
f"{key}": value,
f"{key}": _serialize(value, to_bytes=True),
"_repr_debug_": _repr_debug_(value),
}
},
Expand All @@ -688,7 +688,7 @@ def _get(self, key: UID) -> Any:

result: Optional[Dict] = collection.find_one({"_id": key})
if result is not None:
return result[f"{key}"]
return _deserialize(result[f"{key}"], from_bytes=True)
else:
# raise KeyError(f"{key} does not exist")
# return an empty set which is the same with SQLiteBackingStore
Expand Down Expand Up @@ -741,7 +741,7 @@ def _get_all(self) -> Any:
keys, values = [], []
for row in result:
keys.append(row["_id"])
values.append(row[f"{row['_id']}"])
values.append(_deserialize(row[f"{row['_id']}"], from_bytes=True))
return dict(zip(keys, values))

def keys(self) -> Any:
Expand Down

0 comments on commit 4cdc87a

Please sign in to comment.