Skip to content

Commit

Permalink
sync ignores objects missing on the *source* side
Browse files Browse the repository at this point in the history
We don't support deletion of objects yet.
So, skip if the object is not present on the *source* side.
  • Loading branch information
abyesilyurt committed Aug 2, 2024
1 parent 887010a commit a1de49f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/syft/src/syft/service/sync/diff_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,12 @@ def from_sync_state(
low_status = "NEW"
high_status = "NEW"

# We don't support deletion of objects yet.
# So, skip if the object is not present on the *source* side
source_obj = low_obj if direction == SyncDirection.LOW_TO_HIGH else high_obj
if source_obj is None:
continue

diff = ObjectDiff.from_objects(
low_obj=low_obj,
high_obj=high_obj,
Expand Down
14 changes: 14 additions & 0 deletions packages/syft/tests/syft/service/sync/sync_resolve_single_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ def compute() -> int:
assert res == compute(syft_no_server=True)


def test_skip_deletion(low_worker, high_worker):
low_client: DatasiteClient = low_worker.root_client
high_client: DatasiteClient = high_worker.root_client

@sy.syft_function_single_use()
def compute() -> int:
return 42

_ = low_client.code.request_code_execution(compute)

w = sy.sync(high_client, low_client)
assert isinstance(w, SyftSuccess), f"Expected empty diff, got {w}"


def test_diff_state_with_dataset(low_worker: Worker, high_worker: Worker):
low_client: DatasiteClient = low_worker.root_client
client_low_ds = get_ds_client(low_client)
Expand Down

0 comments on commit a1de49f

Please sign in to comment.