| 13 | |
| 14 | @pytest.mark.skipif(sys.version_info < (3, 10), reason="requires 3.10 glob.glob") |
| 15 | def test_partial_add(bench_dvc, tmp_dir, dvc, dataset, remote): |
| 16 | random.seed(4231) |
| 17 | # Move some files to create a partial dataset |
| 18 | os.makedirs("partial-copy") |
| 19 | for f in glob.glob("*", root_dir=dataset, recursive=True): # type: ignore[call-arg] |
| 20 | if random.random() > 0.5: # noqa: S311 |
| 21 | shutil.move(dataset / f, tmp_dir / "partial-copy" / f) |
| 22 | |
| 23 | # Add/push partial dataset |
| 24 | bench_dvc("add", dataset) |
| 25 | bench_dvc("push") |
| 26 | |
| 27 | # Add more files to the dataset |
| 28 | shutil.copytree("partial-copy", dataset, dirs_exist_ok=True) |
| 29 | |
| 30 | # Benchmark operations for adding files to a dataset |
| 31 | bench_dvc("add", dataset, name="partial") |
| 32 | bench_dvc("push", name="partial") |
| 33 | bench_dvc("gc", "-f", "-w", name="noop") |
| 34 | bench_dvc("gc", "-f", "-w", "-c", name="cloud-noop") |
| 35 | |
| 36 | |
| 37 | @pytest.mark.skipif(sys.version_info < (3, 10), reason="requires 3.10 glob.glob") |