PySyft icon indicating copy to clipboard operation
PySyft copied to clipboard

Retrieving StorableObject from bytes leads to loss of data/tag/description

Open Benardi opened this issue 6 years ago • 1 comments

Description

A StorableObject instance made into bytes using StorableObject.to_bytes() and retrieved using syft.core.common.serde._deserialize loses the values of its fields data/tag/description.

The problem occurred using branch syft_0.3.0

How to Reproduce

  1. Go to branch syft_0.3.0
  2. Install syft locally via pip install -e . 2.1 Install packages missing from requirements : pip install loguru sqlitedict packaging
  3. Run the code below to see the error:
import torch as th
from syft.core.common.uid import UID
from syft.core.common.serde import _deserialize
from syft.core.store.storeable_object import StorableObject

storable = StorableObject(
  id = UID(),
  data=th.Tensor([1, 2, 3, 4]),
  description="Dummy tensor",
  tags=["dummy", "tensor"]
)

print("Original StorableObject")

print("\nRetrieved StorableObject")
print("ID: {}".format(storable.id))
print("DATA: {}".format(storable.data))
print("DESCRIPTION: {}".format(storable.description))
print("TAGS: {}".format(storable.tags))

the_bytes= storable.to_bytes()
retrieved = _deserialize(blob=the_bytes, from_bytes=True)

print("\nRetrieved StorableObject")
print("ID: {}".format(retrieved.id))
print("DATA: {}".format(retrieved.data))
print("DESCRIPTION: {}".format(retrieved.description))
print("TAGS: {}".format(retrieved.tags))

Expected Behavior

Once made again into an instance of StorableObject the object should contain the same fields and values it displayed before

Screenshots

Output of python code above:

image

System Information

  • OS: Debian
  • OS Version: 10
  • Language Version: Python 3.7.5, Torch 1.7.0
  • Package Manager Version: pip 19.2.3

Benardi avatar Nov 08 '20 17:11 Benardi

I want to work on it.

xutongye avatar Nov 17 '20 08:11 xutongye