| 36 | |
| 37 | @pytest.mark.skipif(sys.version_info < (3, 10), reason="requires 3.10 glob.glob") |
| 38 | def test_partial_remove(bench_dvc, tmp_dir, dvc, dataset, remote): |
| 39 | random.seed(5232) |
| 40 | # Add/push full dataset |
| 41 | bench_dvc("add", dataset) |
| 42 | bench_dvc("push") |
| 43 | |
| 44 | # Remove some files |
| 45 | for f in glob.glob("*", root_dir=dataset, recursive=True): # type: ignore[call-arg] |
| 46 | if random.random() > 0.5: # noqa: S311 |
| 47 | if os.path.isfile(dataset / f): |
| 48 | os.remove(dataset / f) |
| 49 | elif os.path.isdir(dataset / f): |
| 50 | shutil.rmtree(dataset / f) |
| 51 | |
| 52 | # Benchmark operations for removing files from dataset |
| 53 | bench_dvc("add", dataset, name="update") |
| 54 | bench_dvc("push", name="update") |
| 55 | bench_dvc("gc", "-f", "-w") |
| 56 | bench_dvc("gc", "-f", "-w", "-c", name="cloud") |