-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Send & Get Datasets #2960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Send & Get Datasets #2960
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
97a2cf2
dataset inherits abstractobject
abogaziah bb5054a
added abstract dataset test
abogaziah 803b37c
formatting
abogaziah 500cf4a
fix
abogaziah 1fabb5a
removed owner annotation
abogaziah ffc0e08
formatting
abogaziah c3da99b
Added simplify& detail
abogaziah 8a72d64
Merge branch 'master' into master
LaRiffle 0937d00
Edit simplify& detail
abogaziah 7acd96c
Merge branch 'master' of https://github.com/abogaziah/PySyft
abogaziah 871adf8
Merge branch 'master' into master
abogaziah 06f6298
Merge branch 'master' into master
LaRiffle 46bb642
Added PointerDataset type
abogaziah 849ff8a
Merge branch 'master' of https://github.com/abogaziah/PySyft
abogaziah 6472aac
Added send()
abogaziah fc27545
Added send(), create_pointer()
abogaziah 017d7f7
Merge remote-tracking branch 'upstream/master'
abogaziah 5a4a8b3
Added get(), pointer.data(), pointer.target()
abogaziah 2b4ee06
Added wrap(), edited base.search(), edit dataset.__init__()
abogaziah ae5101c
Formatting
abogaziah 880864a
Added test file, __repr__(), removed get() override
abogaziah fe52b27
Added tags, description to create_pointer()
abogaziah 5e37ab4
formatting
abogaziah e1aa881
changed repr of dataset ptr
abogaziah bd860c3
replaced == with torch.equal()
abogaziah 847f51a
adapt dataloader
abogaziah 7e239c9
formatting
abogaziah a1ddd72
added serede test!
abogaziah 6ec07fc
added serede test!
abogaziah 4620cd9
Merge branch 'master' into master
LaRiffle a6491ac
test fixes
abogaziah 17a4251
test fixes
abogaziah f50cda5
serde test fix
abogaziah 9169ad9
formatting
abogaziah 022a0da
hook_args fix
abogaziah 69a10fb
Merge branch 'master' into master
LaRiffle a3ddae8
Update test_dataset_pointer.py
LaRiffle c776e10
pointer location fix
abogaziah ebfc062
formatting
abogaziah 1081a3c
formatting
abogaziah ef5204b
formatting
abogaziah 642166c
formatting
abogaziah ae46ad1
fedrated check pass
abogaziah bfe8f2a
formatting
abogaziah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| from typing import List | ||
| from typing import Union | ||
|
|
||
| import syft as sy | ||
| from syft.generic.pointers.object_pointer import ObjectPointer | ||
| from syft.workers.abstract import AbstractWorker | ||
|
|
||
|
|
||
| class PointerDataset(ObjectPointer): | ||
| def __init__( | ||
| self, | ||
| location: "AbstractWorker" = None, | ||
| id_at_location: Union[str, int] = None, | ||
| owner: "AbstractWorker" = None, | ||
| garbage_collect_data: bool = True, | ||
| id: Union[str, int] = None, | ||
| tags: List[str] = None, | ||
| description: str = None, | ||
| ): | ||
| if owner is None: | ||
| owner = sy.framework.hook.local_worker | ||
| super().__init__( | ||
| location=location, | ||
| id_at_location=id_at_location, | ||
| owner=owner, | ||
| garbage_collect_data=garbage_collect_data, | ||
| id=id, | ||
| tags=tags, | ||
| description=description, | ||
| ) | ||
|
|
||
| @property | ||
| def data(self): | ||
| command = ("get_data", self.id_at_location, [], {}) | ||
| ptr = self.owner.send_command(message=command, recipient=self.location).wrap() | ||
| return ptr | ||
|
|
||
| @property | ||
| def targets(self): | ||
| command = ("get_targets", self.id_at_location, [], {}) | ||
| ptr = self.owner.send_command(message=command, recipient=self.location).wrap() | ||
| return ptr | ||
|
|
||
| def wrap(self): | ||
| return self | ||
|
|
||
| def __repr__(self): | ||
| type_name = type(self).__name__ | ||
| out = f"[" f"{type_name} | " f"owner: {str(self.owner.id)}, id:{self.id}" | ||
|
|
||
| if self.point_to_attr is not None: | ||
| out += "::" + str(self.point_to_attr).replace(".", "::") | ||
|
|
||
| big_str = False | ||
|
|
||
| if self.tags is not None and len(self.tags): | ||
| big_str = True | ||
| out += "\n\tTags: " | ||
| for tag in self.tags: | ||
| out += str(tag) + " " | ||
|
|
||
| if big_str and hasattr(self, "shape"): | ||
| out += "\n\tShape: " + str(self.shape) | ||
|
|
||
| if self.description is not None: | ||
| big_str = True | ||
| out += "\n\tDescription: " + str(self.description).split("\n")[0] + "..." | ||
|
|
||
| return out | ||
|
|
||
| def __len__(self): | ||
| command = ("__len__", self.id_at_location, [], {}) | ||
| len = self.owner.send_command(message=command, recipient=self.location) | ||
| return len | ||
|
|
||
| def __getitem__(self, index): | ||
| command = ("__getitem__", self.id_at_location, [index], {}) | ||
| data_elem, target_elem = self.owner.send_command(message=command, recipient=self.location) | ||
| return data_elem.wrap(), target_elem.wrap() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how this works exactly, I'll wait that you add tests on this functionality to comment :)