Keep downstream customization limited to printer profiles

Extract non-profile changes into a separate development line while preserving all profile content.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Eric McCann
2026-09-29 22:42:50 -04:00
co-authored by Codex
parent 9590d71fd9
commit d58c3b0d89
10 changed files with 64 additions and 188 deletions
+7 -9
View File
@@ -1757,20 +1757,18 @@ def check_variant_names(profiles_dir, vendor):
def check_variant_arrays(profiles_dir, vendor, strict=False):
"""Variant arrays have the declared width or a shared single value,
and a printer's variant layout keys agree.
"""Every variant array an instantiated preset writes is exactly its
variant length x stride wide, and a printer's variant layout keys agree.
Only instantiated presets are judged, each at the variant length of its composed
config (_variant_length's); a base is not, since what it writes counts only where
it reaches a preset that does not override it. A full-width array holds one
value per variant; a single value at stride 1 broadcasts to every variant.
Short, nonempty filament arrays use element zero for missing variants,
matching the C++ loader. Other widths are errors. A key the preset does not write
takes what reaches it - the default,
value per variant; any other width is an error, one value included and whatever
the values. A key the preset does not write takes what reaches it - the default,
or an array it inherits or includes - which the loader sizes to the preset, and
is not checked. With strict, every instantiated preset also holds each key that
reaches it at its own width or as a shared single value, so a preset with
other variants restates non-shared arrays when necessary. The machine_max_* limits hold
reaches it at its own width, so a preset with other variants than the file its
array comes from restates the array. The machine_max_* limits hold
a (normal, silent) pair per variant. A process that lists variants pairs each
with its extruder id (extruder 1 everywhere when absent); a machine's layout keys
are held to _check_printer_layout, which reports a printer_extruder_id that does
@@ -1792,7 +1790,7 @@ def check_variant_arrays(profiles_dir, vendor, strict=False):
continue
value, path = config[key]
width, need = len(_as_list(value)), variant_length * stride
if width == need or (stride == 1 and (width == 1 or (ptype == "filament" and 0 < width < need))):
if width == need:
continue
print_error(f'{rel}: "{key}" has {width} values for variant length {variant_length}'
f"{' (' + reason + ')' if reason else ''} at stride {stride}, "
+12 -14
View File
@@ -968,25 +968,21 @@ class TestFixVariant(TreeCase):
retraction_length=["0.8", "1.2"], z_hop=["0.4"],
machine_max_speed_x=["500", "200"])
errors, out = self.width_errors()
self.assertEqual(errors, 1, out)
self.assertNotIn('"z_hop"', out)
self.assertEqual(errors, 2, out)
self.assertIn('M.json: "z_hop" has 1 values for variant length 2 (no '
'printer_extruder_variant, so one default variant per extruder) at stride 1, '
'which takes 2', out)
self.assertIn('M.json: "machine_max_speed_x" has 2 values for variant length 2', out)
self.assertNotIn("retraction_length", out)
def test_one_value_applies_to_every_variant(self):
def test_one_value_is_an_error_where_the_list_has_more_variants(self):
self.preset("process/P.json", instantiation="true", outer_wall_speed=["30"],
print_extruder_id=["1", "1"],
print_extruder_variant=["Direct Drive Standard", "Direct Drive High Flow"])
errors, out = self.width_errors()
self.assertEqual(errors, 0, out)
self.assertEqual(self.width_errors("strict")[0], 0)
def test_a_short_filament_array_uses_element_zero_for_missing_variants(self):
self.preset("filament/F.json", instantiation="true", pressure_advance=["0.02", "0.04"],
filament_extruder_variant=["Direct Drive Standard", "Direct Drive High Flow", "Bowden Standard"])
errors, out = self.width_errors()
self.assertEqual(errors, 0, out)
self.assertEqual(self.width_errors("strict")[0], 0)
self.assertEqual(errors, 1, out)
self.assertIn('P.json: "outer_wall_speed" has 1 values for variant length 2 at stride 1, '
'which takes 2', out)
def test_one_value_is_padded_to_every_variant(self):
self.preset("machine/M.json", instantiation="true", nozzle_diameter=["0.4"] * 3,
@@ -1029,11 +1025,13 @@ class TestFixVariant(TreeCase):
self.assertNotIn("outer_wall_speed", self.t.read("V", "process/S1.json"))
self.assertEqual(self.width_errors("strict")[0], 0)
def test_an_inherited_single_value_is_valid_and_can_be_explicitly_expanded(self):
def test_an_inherited_array_is_checked_and_restated_only_when_strict(self):
self.processes(["30"])
self.assertEqual(self.width_errors()[0], 0)
errors, out = self.width_errors("strict")
self.assertEqual(errors, 0, out)
self.assertEqual(errors, 1, out)
self.assertIn('process/D1.json: "outer_wall_speed" has 1 values for variant length 2 at '
'stride 1, which takes 2 (it comes from V/process/common.json)', out)
before = self.t.bytes_map()
self.run_command("fix-variant")
self.assertEqual(self.t.bytes_map(), before)