diff --git a/resources/profiles/Flashforge/filament/Generic ASA @Flashforge AD4.json b/resources/profiles/Flashforge/filament/Generic ASA @Flashforge AD4.json index aa1849bb7b..a51765bd55 100644 --- a/resources/profiles/Flashforge/filament/Generic ASA @Flashforge AD4.json +++ b/resources/profiles/Flashforge/filament/Generic ASA @Flashforge AD4.json @@ -3,6 +3,7 @@ "filament_id": "GFL99", "setting_id": "GFSA04", "name": "Generic ASA @Flashforge AD4", + "renamed_from": "Generic ASA @AD4", "from": "system", "instantiation": "true", "inherits": "Flashforge Generic ASA", diff --git a/resources/profiles/Flashforge/filament/Generic PLA Silk @Flashforge AD4.json b/resources/profiles/Flashforge/filament/Generic PLA Silk @Flashforge AD4.json index 571d943ff4..6c2db8a46b 100644 --- a/resources/profiles/Flashforge/filament/Generic PLA Silk @Flashforge AD4.json +++ b/resources/profiles/Flashforge/filament/Generic PLA Silk @Flashforge AD4.json @@ -2,7 +2,8 @@ "type": "filament", "filament_id": "GFL99", "setting_id": "GFSA04", - "name": "PLA Silk @Flashforge AD4", + "name": "Generic PLA Silk @Flashforge AD4", + "renamed_from": "PLA Silk @Flashforge AD4", "from": "system", "instantiation": "true", "inherits": "Flashforge Generic PLA-Silk", diff --git a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.25 nozzle.json b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.25 nozzle.json index ebedc49518..242a846b19 100644 --- a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.25 nozzle.json +++ b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.25 nozzle.json @@ -1,6 +1,7 @@ { "type": "filament", "name": "SUNLU PETG @FF AD5M 0.25 Nozzle", + "renamed_from": "SUNLU PETG @FF AD5M 0.25 nozzle", "inherits": "SUNLU PETG @base", "from": "system", "setting_id": "GFSNLS08_00", diff --git a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.8 nozzle.json b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.8 nozzle.json index dc16fed525..d97075dafd 100644 --- a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.8 nozzle.json +++ b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PETG @FF AD5M 0.8 nozzle.json @@ -1,6 +1,7 @@ { "type": "filament", "name": "SUNLU PETG @FF AD5M 0.8 Nozzle", + "renamed_from": "SUNLU PETG @FF AD5M 0.8 nozzle", "inherits": "SUNLU PETG @base", "from": "system", "setting_id": "GFSNLS08_01", diff --git a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Marble @base.json b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Marble @base.json index 3416ae82d3..04bd581291 100644 --- a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Marble @base.json +++ b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Marble @base.json @@ -1,6 +1,7 @@ { "type": "filament", "name": "SUNLU PLA Marble @base", + "renamed_from": "SUNLU Marble PLA @base", "inherits": "fdm_filament_pla", "from": "system", "filament_id": "GFSNL06", diff --git a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Matte @FF AD5M 0.25 nozzle.json b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Matte @FF AD5M 0.25 nozzle.json index 6e06b8f693..088e032a5b 100644 --- a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Matte @FF AD5M 0.25 nozzle.json +++ b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA Matte @FF AD5M 0.25 nozzle.json @@ -1,6 +1,7 @@ { "type": "filament", "name": "SUNLU PLA Matte @FF AD5M 0.25 Nozzle", + "renamed_from": "SUNLU PLA Matte @FF AD5M 0.25 nozzle", "inherits": "SUNLU PLA Matte @base", "from": "system", "setting_id": "GFSNLS02_00", diff --git a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ 2.0 @FF AD5M 0.25 nozzle.json b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ 2.0 @FF AD5M 0.25 nozzle.json index 7a8bf15d34..97d816cf37 100644 --- a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ 2.0 @FF AD5M 0.25 nozzle.json +++ b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ 2.0 @FF AD5M 0.25 nozzle.json @@ -1,6 +1,7 @@ { "type": "filament", "name": "SUNLU PLA+ 2.0 @FF AD5M 0.25 Nozzle", + "renamed_from": "SUNLU PLA+ 2.0 @FF AD5M 0.25 nozzle", "inherits": "SUNLU PLA+ 2.0 @base", "from": "system", "setting_id": "GFSNLS04_01", diff --git a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ @FF AD5M 0.25 nozzle.json b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ @FF AD5M 0.25 nozzle.json index 7d607ba94b..4bf0c5ae14 100644 --- a/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ @FF AD5M 0.25 nozzle.json +++ b/resources/profiles/Flashforge/filament/SUNLU/SUNLU PLA+ @FF AD5M 0.25 nozzle.json @@ -1,6 +1,7 @@ { "type": "filament", "name": "SUNLU PLA+ @FF AD5M 0.25 Nozzle", + "renamed_from": "SUNLU PLA+ @FF AD5M 0.25 nozzle", "inherits": "SUNLU PLA+ @base", "from": "system", "setting_id": "GFSNLS03_01", diff --git a/resources/profiles/Flashforge/filament/SUNLU/SUNLU Silk PLA+ @FF AD5M 0.25 nozzle.json b/resources/profiles/Flashforge/filament/SUNLU/SUNLU Silk PLA+ @FF AD5M 0.25 nozzle.json index d2ebf074da..0d75d8abfd 100644 --- a/resources/profiles/Flashforge/filament/SUNLU/SUNLU Silk PLA+ @FF AD5M 0.25 nozzle.json +++ b/resources/profiles/Flashforge/filament/SUNLU/SUNLU Silk PLA+ @FF AD5M 0.25 nozzle.json @@ -1,6 +1,7 @@ { "type": "filament", "name": "SUNLU Silk PLA+ @FF AD5M 0.25 Nozzle", + "renamed_from": "SUNLU Silk PLA+ @FF AD5M 0.25 nozzle", "inherits": "SUNLU Silk PLA+ @base", "from": "system", "setting_id": "GFSNLS05_01", diff --git a/resources/profiles/Z-Bolt/filament/Z-Bolt ABS HT @0.4 nozzle.json b/resources/profiles/Z-Bolt/filament/Z-Bolt ABS HT @0.4 nozzle.json index 5ce57d965c..91b1a0e4d5 100644 --- a/resources/profiles/Z-Bolt/filament/Z-Bolt ABS HT @0.4 nozzle.json +++ b/resources/profiles/Z-Bolt/filament/Z-Bolt ABS HT @0.4 nozzle.json @@ -1,6 +1,7 @@ { "type": "filament", - "name": "Z-Bolt ABS HT@0.4 nozzle", + "name": "Z-Bolt ABS HT @0.4 nozzle", + "renamed_from": "Z-Bolt ABS HT@0.4 nozzle", "inherits": "Z-Bolt ABS HT @base", "from": "system", "instantiation": "true", diff --git a/scripts/orca_extra_profile_check.py b/scripts/orca_extra_profile_check.py index 33d8c0acc4..74d537e129 100644 --- a/scripts/orca_extra_profile_check.py +++ b/scripts/orca_extra_profile_check.py @@ -139,8 +139,65 @@ def check_machine_default_materials(profiles_dir, vendor_name): return error_count +def check_filament_name_consistency(profiles_dir, vendor_name): + """ + Make sure filament profile names match in both vendor json and subpath files. + Filament profiles work only if the name in .json matches the name in sub_path file, + or if it's one of the sub_path file's `renamed_from`. + """ + error_count = 0 + vendor_dir = profiles_dir / vendor_name + vendor_file = profiles_dir / (vendor_name + ".json") + + if not vendor_file.exists(): + print(f"No profiles found for vendor: {vendor_name} at {vendor_file}") + return 0 + + try: + with open(vendor_file, 'r', encoding='UTF-8') as fp: + data = json.load(fp) + except Exception as e: + print(f"Error loading vendor profile {vendor_file}: {e}") + return 1 + + if 'filament_list' not in data: + return 0 + + for child in data['filament_list']: + name_in_vendor = child['name'] + sub_path = child['sub_path'] + sub_file = vendor_dir / sub_path + + if not sub_file.exists(): + print(f"Missing sub profile: '{sub_path}' declared in {vendor_file.relative_to(profiles_dir)}") + error_count += 1 + continue + + try: + with open(sub_file, 'r', encoding='UTF-8') as fp: + sub_data = json.load(fp) + except Exception as e: + print(f"Error loading profile {sub_file}: {e}") + error_count += 1 + continue + + name_in_sub = sub_data['name'] + + if name_in_sub == name_in_vendor: + continue + + if 'renamed_from' in sub_data: + renamed_from = [n.strip() for n in sub_data['renamed_from'].split(';')] + if name_in_vendor in renamed_from: + continue + + print(f"Filament name mismatch: required '{name_in_vendor}' in {vendor_file.relative_to(profiles_dir)} but found '{name_in_sub}' in {sub_file.relative_to(profiles_dir)}, and none of its `renamed_from` matches the required name either") + error_count += 1 + + return error_count + def main(): - print("Checking compatible_printers ...") + print("Checking profiles ...") parser = argparse.ArgumentParser(description="Check profiles for issues") parser.add_argument("--vendor", type=str, required=False, help="Vendor name") parser.add_argument("--check-filaments", default=True, action="store_true", help="Check compatible_printers in filament profiles") @@ -157,17 +214,20 @@ def main(): errors_found += check_filament_compatible_printers(profiles_dir / args.vendor / "filament") if args.check_materials: errors_found += check_machine_default_materials(profiles_dir, args.vendor) + errors_found += check_filament_name_consistency(profiles_dir, args.vendor) checked_vendor_count += 1 else: for vendor_dir in profiles_dir.iterdir(): + if not vendor_dir.is_dir(): + continue + errors_found += check_filament_name_consistency(profiles_dir, vendor_dir.name) # skip "OrcaFilamentLibrary" folder if vendor_dir.name == "OrcaFilamentLibrary": continue - if vendor_dir.is_dir(): - if args.check_filaments or not (args.check_materials and not args.check_filaments): - errors_found += check_filament_compatible_printers(vendor_dir / "filament") - if args.check_materials: - errors_found += check_machine_default_materials(profiles_dir, vendor_dir.name) + if args.check_filaments or not (args.check_materials and not args.check_filaments): + errors_found += check_filament_compatible_printers(vendor_dir / "filament") + if args.check_materials: + errors_found += check_machine_default_materials(profiles_dir, vendor_dir.name) checked_vendor_count += 1 if errors_found > 0: