Skip to content

fix: validate dataset sources before copying - #9618

Merged
koenvanderveen merged 5 commits into
OpenMined:devfrom
yashb98:fix/dataset-source-validation
Nov 20, 2026
Merged

koenvanderveen merged 5 commits into
OpenMined:devfrom
yashb98:fix/dataset-source-validation

Conversation

@yashb98

@yashb98 yashb98 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • When the DO calls create_dataset with a private data path that does not exist, or a README that is missing, a folder or not a .md file, we previously copied the mock data (and the README, when only the private path was wrong) into the new dataset's folder before we raised the error. Now we check the mock, private and README paths before we copy anything, so a failed call leaves the SyftBox folder unchanged.
  • When the DO then fixes the path and calls create_dataset again with the same name, we previously raised FileExistsError, because the mock folder from the failed call was not empty, and the DO had to delete that folder by hand. Now the second call creates the dataset.

Guidelines

High level

  • 🟢 Split: no need to split. The one extra change, copy_paths taking Iterable[Path] instead of Iterator[Path], is a type hint on the same code path.
  • 🟢 Size: check the dataset source paths before copying, so a failed create_dataset can be retried with the same name.

Mid level

  • 🟢 User-facing code: no API change, and the same errors with the same messages.
  • 🟢 Error handling
  • 🟢 State versioning: no new state.
  • 🟢 Function structure: _validate_source_files checks every source path once, at the start of _materialize_version, so it covers both create_dataset and migrate_dataset. The _copy_* methods only copy.
  • 🟢 Tests: one test, test_bad_source_copies_nothing_and_retry_works, for a missing private file, a missing README and a README that is not .md.

Low level

  • 🟢 Naming
  • 🟢 Code style

Security

No change.

Testing

  • test_bad_source_copies_nothing_and_retry_works passes with the fix. With dev's dataset_storage.py, all 3 of its cases fail.
  • On the branch merged with dev, the syft-datasets suite and just test-unit-fast (758 tests) pass.
  • The syft-rds suite gives the same result with and without this change.
  • Pre-commit passes.
  • The live Google Drive integration tests were not run.

Asana task

  • None (self-discovered).

@yashb98
yashb98 marked this pull request as ready for review November 7, 2026 22:51
Check the mock, private and README paths in one place, at the start of
_materialize_version, instead of again inside each _copy_* method. That
also covers migrate_dataset, and removes the raise at the end of the copy
methods that could no longer run.

Replace the retry tests with one test for the three bad paths, and drop
the RDS test that checked the same thing one layer up.
dev no longer has a codec for dataset protocol version 1.
@koenvanderveen
koenvanderveen merged commit 5969f71 into OpenMined:dev Nov 20, 2026
19 of 20 checks passed
@yashb98

yashb98 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Hi @koenvanderveen, sorry for the late reply. Thanks for reviewing this, tidying up the code and tests, and merging it. Really appreciate your time and help!

@yashb98

yashb98 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@koenvanderveen , I’d be happy to help with more work on PySyft. I also work on ML systems, with PRs in PyTorch, JAX, bitsandbytes and Helion covering compiler fixes, CUDA performance and autotuning.

Are there any issues, PRs or other areas you’d like me to look into?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants