| 
1 | 1 | import os  | 
2 |  | -from glob import glob  | 
3 | 2 | import tempfile  | 
4 | 3 | from shutil import copyfile, copytree  | 
5 | 4 | from sys import platform  | 
@@ -38,44 +37,43 @@ def test_config(path):  | 
38 | 37 |         raise FileNotFoundError(f"Test data folder not found: {original_data_path}")  | 
39 | 38 | 
 
  | 
40 | 39 |     valid_extensions = {".vtp", ".vti", ".vtu", ".vtm", ".png", ".jpeg", ".jpg"}  | 
41 |  | - | 
42 |  | -    legacy_id = "123456789"  | 
43 |  | -    legacy_dir = os.path.join(tmp_data_root, legacy_id)  | 
44 |  | -    os.makedirs(legacy_dir, exist_ok=True)  | 
 | 40 | +      | 
 | 41 | +    test_ids = ["123456789", "12345678"]  | 
 | 42 | +      | 
 | 43 | +    for test_id in test_ids:  | 
 | 44 | +        test_id_dir = os.path.join(tmp_data_root, test_id)  | 
 | 45 | +        os.makedirs(test_id_dir, exist_ok=True)  | 
 | 46 | +      | 
 | 47 | +    test_project_uuid = "test-project-uuid"  | 
 | 48 | +    test_data_uuid = "test-data-uuid"  | 
 | 49 | +    new_structure_dir = os.path.join(tmp_data_root, test_project_uuid, test_data_uuid)  | 
 | 50 | +    os.makedirs(new_structure_dir, exist_ok=True)  | 
 | 51 | +      | 
 | 52 | +    uploads_dir = os.path.join(tmp_data_root, test_project_uuid, "uploads")  | 
 | 53 | +    os.makedirs(uploads_dir, exist_ok=True)  | 
45 | 54 | 
 
  | 
46 | 55 |     for root, dirs, files in os.walk(original_data_path):  | 
47 |  | -        rel_root = os.path.relpath(root, original_data_path)  | 
48 |  | - | 
49 |  | -        # Copier sous-dossiers (comme cube/) dans leur ensemble  | 
50 | 56 |         for d in dirs:  | 
51 | 57 |             src_dir = os.path.join(root, d)  | 
52 |  | -            dst_dir = os.path.join(tmp_data_root, legacy_id, d)  | 
 | 58 | +            dst_dir = os.path.join(tmp_data_root, test_ids[0], d)  | 
53 | 59 |             if not os.path.exists(dst_dir):  | 
54 | 60 |                 copytree(src_dir, dst_dir, dirs_exist_ok=True)  | 
55 |  | -                print(f"📦 Copied folder: {src_dir} → {dst_dir}", flush=True)  | 
56 | 61 | 
 
  | 
57 | 62 |         for file_name in files:  | 
58 | 63 |             ext = os.path.splitext(file_name)[1].lower()  | 
59 | 64 |             if ext not in valid_extensions:  | 
60 | 65 |                 continue  | 
61 | 66 | 
 
  | 
62 | 67 |             full_path = os.path.join(root, file_name)  | 
63 |  | -            uuid = os.path.splitext(file_name)[0]  | 
64 |  | - | 
65 |  | -            # uuid/filename  | 
66 |  | -            dst_dir = os.path.join(tmp_data_root, uuid)  | 
67 |  | -            os.makedirs(dst_dir, exist_ok=True)  | 
68 |  | -            dst = os.path.join(dst_dir, file_name)  | 
69 |  | -            copyfile(full_path, dst)  | 
70 |  | - | 
71 |  | -            # legacy path: 123456789/filename  | 
72 |  | -            legacy_dst = os.path.join(legacy_dir, file_name)  | 
73 |  | -            copyfile(full_path, legacy_dst)  | 
74 |  | - | 
75 |  | -            # root-level copy  | 
76 |  | -            root_level_dst = os.path.join(tmp_data_root, file_name)  | 
77 |  | -            copyfile(full_path, root_level_dst)  | 
78 |  | - | 
79 |  | -            print(f"📄 Copied file: {full_path} → {root_level_dst}", flush=True)  | 
 | 68 | +              | 
 | 69 | +            for test_id in test_ids:  | 
 | 70 | +                test_id_dst = os.path.join(tmp_data_root, test_id, file_name)  | 
 | 71 | +                copyfile(full_path, test_id_dst)  | 
 | 72 | +              | 
 | 73 | +            new_structure_dst = os.path.join(new_structure_dir, file_name)  | 
 | 74 | +            copyfile(full_path, new_structure_dst)  | 
 | 75 | +              | 
 | 76 | +            uploads_dst = os.path.join(uploads_dir, file_name)  | 
 | 77 | +            copyfile(full_path, uploads_dst)  | 
80 | 78 | 
 
  | 
81 | 79 |     print(f"\n✅ DATA_FOLDER_PATH set to: {tmp_data_root}", flush=True)  | 
0 commit comments