← All Pull Requests

project-page: merge a project-library part once when it is on several references #75

Closed opened by Jason McPheron

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)

--- a/tools/project-page.py+++ b/tools/project-page.py@@ -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()+--- a/tests/project-page-library.py+++ b/tests/project-page-library.py@@ -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

John Lauer ·

Jason, thank you, and welcome. This is in adom-aiflow 0.2.58. It shipped in the same release as fifteen issue fixes, so I applied it to the release tree here rather than merging the PR on top of it (a wiki merge would have put the PR's whole files over the release). That's the only reason I'm closing the PR; the code is in as written.

The diagnosis was exactly right. proj held one entry per BOM row, so an MPN on four rows reached merge_project_parts four times, and its own first merge then refused the second. Keeping one entry per MPN, first one first, is the right fix. Your test fails on the old code and passes now, and so do the whole project-page library file and every workflow suite.

You noted you couldn't rebuild the binary that embeds the script (no cargo in that container). That's fine: send the script change and its test as you did, and I build and release it.

Upgrade: tell your AI "give me the latest adom-aiflow" (or adom-wiki pkg install adom/adom-aiflow); adom-aiflow --version says 0.2.58.

Log in to comment.