AI Flow
Public Made by Adomby adom
Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board.
project-page: merge a project-library part once when it is on several references #75
Base: 083ebd94b24153d7463f70c1910f111415e63fc7
What blocked the board: project-page refused the PicoQuorum Console board with "project library symbol CL10A105KB8NNNC (CL10A105KB8NNNC) has the same name as a symbol already in the library". The part is in the project library (prefer: true) and sits on four references in BOM rows that parts keeps apart (C2, C28, C29, C32), so proj in project-page.py held four entries for one MPN. merge_project_parts merged the first and then failed on the second, because its own merge had put the symbol in have. The 100k on R11, R15, R16 hit the same thing.
Change: proj keeps one entry per MPN (the first, order preserved) before merge_project_parts.
Test: tests/project-page-library.py::test_a_project_library_part_on_several_references_is_packaged_once, the same project-library part given twice with different refs; one symbol is packaged. It fails on the base and passes with the change; the whole file passes (36 tests). The board's own run used a one-row-per-MPN BOM as a workaround, because the container has no cargo to rebuild the binary that embeds the script.
Diff Skip to comments (1)
@@ -1,1031 +1,1034 @@⋯ 802 unchanged lines ⋯ open(os.path.join(fp_dir, m), "w").write(t) sp = os.path.join(sym_dir, f"{lib}.kicad_sym") t = open(sp).read() if os.path.isfile(sp) else ""- proj = [p for p in parts if p.get("projectLib") and not p.get("wiki")]+ # one entry per MPN: the parts record lists a part once per reference group, so a value on several+ # references (four 1 uF caps) arrives more than once and must be merged only once+ proj = list({p["mpn"]: p for p in reversed([p for p in parts if p.get("projectLib") and not p.get("wiki")])}.values())[::-1] versions = [sym_header_version(t) or 0] + [sym_header_version(open(p["projectLib"]["symbolFile"]).read()) or 0 for p in proj] t = merge_project_parts(proj, t, fp_dir, m_dir, lib, pkgid) if t:⋯ 219 unchanged lines ⋯ if __name__ == "__main__": main()+@@ -1,566 +1,576 @@⋯ 257 unchanged lines ⋯ readme = (self.run_dir / "project-page" / "README.md").read_text() self.assertIn("project library (no public page yet)", readme) + def test_a_project_library_part_on_several_references_is_packaged_once(self):+ a = self.project_lib(); b = dict(a)+ a["refs"], b["refs"] = ["C2"], ["C28", "C29"]+ v = self.run_page(parts=self.parts() + [a, b])+ self.assertTrue(v["ok"], v)+ with zipfile.ZipFile(v["zip"]) as z:+ sym = z.read("symbols/test-board.kicad_sym").decode()+ self.assertEqual(sym.count('(symbol "ABC-123"'), 1)+ def test_only_project_library_parts_need_no_cloud_library(self): v = self.run_page(parts=[self.project_lib()]) self.assertTrue(v["ok"], v)⋯ 300 unchanged lines ⋯ if __name__ == "__main__": unittest.main()+
Comments
Log in to comment.