From 5a39e6beda7e2e031db5a8435d809e7982465233 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 15 Apr 2025 21:16:42 +0800 Subject: [PATCH 1/4] Add `renamed_from` so existing user won't break (cherry picked from commit f8f3b5c2c9b0b15c209d8307a6eaba24e393ddda) --- .../Flashforge/filament/Generic ASA @Flashforge AD4.json | 1 + .../filament/SUNLU/SUNLU PETG @FF AD5M 0.25 nozzle.json | 1 + .../filament/SUNLU/SUNLU PETG @FF AD5M 0.8 nozzle.json | 1 + .../Flashforge/filament/SUNLU/SUNLU PLA Marble @base.json | 1 + .../filament/SUNLU/SUNLU PLA Matte @FF AD5M 0.25 nozzle.json | 1 + .../filament/SUNLU/SUNLU PLA+ 2.0 @FF AD5M 0.25 nozzle.json | 1 + .../filament/SUNLU/SUNLU PLA+ @FF AD5M 0.25 nozzle.json | 1 + .../filament/SUNLU/SUNLU Silk PLA+ @FF AD5M 0.25 nozzle.json | 1 + 8 files changed, 8 insertions(+) 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/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", From eb38474bb209a11e4df47b8828431e175b0dc557 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 15 Apr 2025 17:09:03 +0800 Subject: [PATCH 2/4] Add check for profile name consistency (cherry picked from commit 7343aa5b55cab9a9f7cbdcdddd4e7650f1577598) --- scripts/orca_extra_profile_check.py | 68 ++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/scripts/orca_extra_profile_check.py b/scripts/orca_extra_profile_check.py index 33d8c0acc4..73da993966 100644 --- a/scripts/orca_extra_profile_check.py +++ b/scripts/orca_extra_profile_check.py @@ -139,8 +139,61 @@ def check_machine_default_materials(profiles_dir, vendor_name): return error_count +def check_name_consistency(profiles_dir, vendor_name): + """ + Make sure profile names match in both vendor json and subpath files + """ + 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 + + for sect in [ + 'machine_model_list', + 'process_list', + 'filament_list', + 'machine_list', + ]: + if sect not in data: + continue + for child in data[sect]: + 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 not name_in_vendor == name_in_sub: + print(f"Profile name mismatch: '{name_in_vendor}' in {vendor_file.relative_to(profiles_dir)} but '{name_in_sub}' in {sub_file.relative_to(profiles_dir)}") + 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 +210,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_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_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: From eb57036dab43856df3a87d7c884c1169a727eb09 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 15 Apr 2025 21:42:21 +0800 Subject: [PATCH 3/4] Update filament name checking script (cherry picked from commit 7c4c1bf191de1fd6b86a07bf62c1ab634faa9f55) --- scripts/orca_extra_profile_check.py | 66 +++++++++++++++-------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/scripts/orca_extra_profile_check.py b/scripts/orca_extra_profile_check.py index 73da993966..74d537e129 100644 --- a/scripts/orca_extra_profile_check.py +++ b/scripts/orca_extra_profile_check.py @@ -139,9 +139,11 @@ def check_machine_default_materials(profiles_dir, vendor_name): return error_count -def check_name_consistency(profiles_dir, vendor_name): +def check_filament_name_consistency(profiles_dir, vendor_name): """ - Make sure profile names match in both vendor json and subpath files + 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 @@ -158,37 +160,39 @@ def check_name_consistency(profiles_dir, vendor_name): print(f"Error loading vendor profile {vendor_file}: {e}") return 1 - for sect in [ - 'machine_model_list', - 'process_list', - 'filament_list', - 'machine_list', - ]: - if sect not in data: + 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 - for child in data[sect]: - 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 + 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 - 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 not name_in_vendor == name_in_sub: - print(f"Profile name mismatch: '{name_in_vendor}' in {vendor_file.relative_to(profiles_dir)} but '{name_in_sub}' in {sub_file.relative_to(profiles_dir)}") - error_count += 1 + 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 @@ -210,13 +214,13 @@ 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_name_consistency(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_name_consistency(profiles_dir, vendor_dir.name) + errors_found += check_filament_name_consistency(profiles_dir, vendor_dir.name) # skip "OrcaFilamentLibrary" folder if vendor_dir.name == "OrcaFilamentLibrary": continue From 2b5fd7ad2e2f3c42a3ff7113e4fa2fcde7085fac Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 15 Apr 2025 20:02:22 +0800 Subject: [PATCH 4/4] Fix filament name inconsistency (cherry picked from commit 36225fc3dbd88babbc5a227fcc6247528d0de6a4) --- .../Flashforge/filament/Generic PLA Silk @Flashforge AD4.json | 3 ++- .../profiles/Z-Bolt/filament/Z-Bolt ABS HT @0.4 nozzle.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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/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",