Skip to content

Commit eab4311

Browse files
authored
Merge pull request #9165 from OpenMined/eelco/sync-delete-warning
add sync warning for deletions
2 parents bcbe0f7 + c01c255 commit eab4311

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

packages/syft/src/syft/client/datasite_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ def get_sync_state(self) -> SyncState | SyftError:
202202

203203
def apply_state(self, resolved_state: ResolvedSyncState) -> SyftSuccess | SyftError:
204204
if len(resolved_state.delete_objs):
205-
raise NotImplementedError("TODO implement delete")
205+
prompt_warning_message(
206+
message=(
207+
"Attempted to delete objects by syncing. "
208+
"This is not currently supported, objects must be deleted manually."
209+
)
210+
)
206211
items = resolved_state.create_objs + resolved_state.update_objs
207212

208213
action_objects = [x for x in items if isinstance(x, ActionObject)]

packages/syft/src/syft/service/sync/diff_state.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from ...util.notebook_ui.components.sync import Label
4040
from ...util.notebook_ui.components.sync import SyncTableObject
4141
from ...util.notebook_ui.icons import Icon
42+
from ...util.util import prompt_warning_message
4243
from ..action.action_object import ActionObject
4344
from ..action.action_permissions import ActionObjectPermission
4445
from ..action.action_permissions import ActionPermission
@@ -1192,6 +1193,7 @@ def from_sync_state(
11921193
_include_server_status: bool = False,
11931194
) -> "ServerDiff":
11941195
obj_uid_to_diff = {}
1196+
show_deletion_warning = False
11951197
for obj_id in set(low_state.objects.keys()) | set(high_state.objects.keys()):
11961198
low_obj = low_state.objects.get(obj_id, None)
11971199
high_obj = high_state.objects.get(obj_id, None)
@@ -1216,6 +1218,7 @@ def from_sync_state(
12161218
# So, skip if the object is not present on the *source* side
12171219
source_obj = low_obj if direction == SyncDirection.LOW_TO_HIGH else high_obj
12181220
if source_obj is None:
1221+
show_deletion_warning = True
12191222
continue
12201223

12211224
diff = ObjectDiff.from_objects(
@@ -1272,6 +1275,15 @@ def from_sync_state(
12721275
inplace=True,
12731276
)
12741277

1278+
if show_deletion_warning:
1279+
prompt_warning_message(
1280+
message=(
1281+
"The target server has objects not found on the source server. "
1282+
"These objects cannot be deleted via syncing and only manual deletion is possible."
1283+
),
1284+
confirm=False,
1285+
)
1286+
12751287
return res
12761288

12771289
@staticmethod

0 commit comments

Comments
 (0)