Skip to content

Commit

Permalink
fix notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvanderveen committed Dec 1, 2023
1 parent d1cbb28 commit 97d926d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
33 changes: 22 additions & 11 deletions notebooks/api/0.8/09-blob-storage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
"from syft import autocache"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"ORCHESTRA_DEPLOYMENT_TYPE\"] =\"container_stack\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -190,6 +201,15 @@
"uploaded_file_storage_id = upload_file(domain_client, data_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"blob_retrieval = domain_client.api.services.blob_storage.read(uploaded_file_storage_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -267,16 +287,6 @@
"action_object = sy.ActionObject.from_path(path=data_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open(action_object.syft_action_data.file_name, \"wb\") as f:\n",
" f.write(action_object.syft_action_data.read())"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -292,7 +302,8 @@
"metadata": {},
"outputs": [],
"source": [
"action_object"
"with open(action_object.syft_action_data.file_name, \"wb\") as f:\n",
" f.write(action_object.syft_action_data.read())"
]
},
{
Expand Down
17 changes: 15 additions & 2 deletions packages/syft/src/syft/store/blob_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ class BlobRetrieval(SyftObject):
file_size: Optional[int]

def read(self) -> Union[SyftObject, SyftError]:
pass
# we need both methods bcs of inheritrance
return self._read()

def _read(self):
with open(self.file_name, "rb") as f:
return f.read()

def _read_data(self, **kwargs):
return self._read()


@migrate(BlobRetrieval, BlobRetrievalV1)
Expand Down Expand Up @@ -129,7 +137,12 @@ def read(self) -> Union[SyftObject, SyftError]:
if self.type_ is BlobFileType:
with open(self.file_name, "wb") as fp:
fp.write(self.syft_object)
return BlobFile(file_name=self.file_name)
return BlobFile(
file_name=self.file_name,
syft_blob_storage_entry_id=self.syft_blob_storage_entry_id,
syft_node_location=self.syft_node_location,
syft_client_verify_key=self.syft_client_verify_key,
)
return deserialize(self.syft_object, from_bytes=True)


Expand Down

0 comments on commit 97d926d

Please sign in to comment.