From 7d82dba26dd348c0754de4198cda85a69b364395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Mon, 3 Nov 2025 17:18:36 +0100 Subject: [PATCH 01/12] Add flex batch --- viewer/functions/api.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index c1670a243..26b7041ca 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -333,6 +333,24 @@ def get_serial_numbers_for_site(site, verbose=False): flex_pcb_vendor = flex_pcb_vendor.replace("None-None", "Unknown") flex_pcb_vendor = flex_pcb_vendor.replace("None", "Unknown") + # batch name + flex_pcb_batch = "" + batches = flex.get("batches", []) + # restrict to "ready" + batches = [b for b in batches if b.get("state") == "ready"] + if batches: + # sort by timestamp, in case there would be several, to find the latest + batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) + batch = batches[0] + flex_pcb_batch = batch.get("number", "") + if flex_pcb_batch: + # shorten the batch name (example batch name: "IZM Quad Bare Module production batch 14 (May 2025)") + print(flex_pcb_batch) + flex_pcb_batch = flex_pcb_batch[flex_pcb_batch.find("batch") :] + else: + flex_pcb_batch = "Unknown" + + bare_module = ( localdb.component.find_one({"_id": ObjectId(bare_id)}) if ObjectId.is_valid(bare_id) @@ -372,6 +390,7 @@ def get_serial_numbers_for_site(site, verbose=False): # update entry in dictionary component["flex_pcb_vendor"] = flex_pcb_vendor + component["flex_pcb_batch"] = flex_pcb_batch component["bare_module_vendor"] = bare_module_vendor component["bare_module_batch"] = bare_module_batch @@ -426,6 +445,7 @@ def get_serial_numbers_for_site(site, verbose=False): "Unknown", # Default to "Unknown" if not found ), "flex_pcb_vendor": doc.get("flex_pcb_vendor", "Unknown"), + "flex_pcb_batch": doc.get("flex_pcb_batch", "Unknown"), "bare_module_vendor": doc.get("bare_module_vendor", "Unknown"), "bare_module_batch": doc.get("bare_module_batch", "Unknown"), } -- GitLab From 909f0bdb24216c233c97b4665b76ba58d4401cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Mon, 3 Nov 2025 17:19:55 +0100 Subject: [PATCH 02/12] Remove print --- viewer/functions/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 26b7041ca..87666e635 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -345,12 +345,11 @@ def get_serial_numbers_for_site(site, verbose=False): flex_pcb_batch = batch.get("number", "") if flex_pcb_batch: # shorten the batch name (example batch name: "IZM Quad Bare Module production batch 14 (May 2025)") - print(flex_pcb_batch) + logger.error(flex_pcb_batch) flex_pcb_batch = flex_pcb_batch[flex_pcb_batch.find("batch") :] else: flex_pcb_batch = "Unknown" - bare_module = ( localdb.component.find_one({"_id": ObjectId(bare_id)}) if ObjectId.is_valid(bare_id) -- GitLab From 0aeb905d8c2b23b117ad6b1c5a4737f176409512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Mon, 3 Nov 2025 17:39:19 +0100 Subject: [PATCH 03/12] Flex PCB formatting --- viewer/functions/api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 87666e635..05f5af951 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -344,9 +344,11 @@ def get_serial_numbers_for_site(site, verbose=False): batch = batches[0] flex_pcb_batch = batch.get("number", "") if flex_pcb_batch: - # shorten the batch name (example batch name: "IZM Quad Bare Module production batch 14 (May 2025)") - logger.error(flex_pcb_batch) - flex_pcb_batch = flex_pcb_batch[flex_pcb_batch.find("batch") :] + # shorten the batch name (example batch name: "Pixel_Populated_PCB_Norbit_Production_20250626") + prefix = "Pixel_Populated_PCB_" + pos = flex_pcb_batch.find(prefix) + if pos > -1: + flex_pcb_batch = flex_pcb_batch[pos + len(prefix) :] else: flex_pcb_batch = "Unknown" -- GitLab From 9974af663d38d6d7ec14136b6d309557e380f4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Tue, 4 Nov 2025 12:15:15 +0100 Subject: [PATCH 04/12] Bare vs populated flex batch --- viewer/functions/api.py | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 05f5af951..ef02e3325 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -334,23 +334,42 @@ def get_serial_numbers_for_site(site, verbose=False): flex_pcb_vendor = flex_pcb_vendor.replace("None", "Unknown") # batch name - flex_pcb_batch = "" + flex_pcb_bare_batch = "" + flex_pcb_populated_batch = "" batches = flex.get("batches", []) # restrict to "ready" batches = [b for b in batches if b.get("state") == "ready"] if batches: # sort by timestamp, in case there would be several, to find the latest batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) - batch = batches[0] - flex_pcb_batch = batch.get("number", "") - if flex_pcb_batch: + batches_bare = [ + b for b in batches if "bare" in batches.get("number").lower() + ] + batches_populated = [ + b for b in batches if "populated" in batches.get("number").lower() + ] + if len(batches_bare) > 0: + flex_pcb_bare_batch = batches_bare[0].get("number", "") + if len(batches_populated) > 0: + flex_pcb_populated_batch = batches_populated[0].get("number", "") + if flex_pcb_bare_batch: + # shorten the batch name + prefix = "Pixel_Bare_PCB_" + pos = flex_pcb_bare_batch.find(prefix) + if pos > -1: + flex_pcb_bare_batch = flex_pcb_bare_batch[pos + len(prefix) :] + else: + flex_pcb_bare_batch = "Unknown" + if flex_pcb_populated_batch: # shorten the batch name (example batch name: "Pixel_Populated_PCB_Norbit_Production_20250626") prefix = "Pixel_Populated_PCB_" - pos = flex_pcb_batch.find(prefix) + pos = flex_pcb_populated_batch.find(prefix) if pos > -1: - flex_pcb_batch = flex_pcb_batch[pos + len(prefix) :] + flex_pcb_populated_batch = flex_pcb_populated_batch[ + pos + len(prefix) : + ] else: - flex_pcb_batch = "Unknown" + flex_pcb_populated_batch = "Unknown" bare_module = ( localdb.component.find_one({"_id": ObjectId(bare_id)}) @@ -391,7 +410,8 @@ def get_serial_numbers_for_site(site, verbose=False): # update entry in dictionary component["flex_pcb_vendor"] = flex_pcb_vendor - component["flex_pcb_batch"] = flex_pcb_batch + component["flex_pcb_bare_batch"] = flex_pcb_bare_batch + component["flex_pcb_populated_batch"] = flex_pcb_populated_batch component["bare_module_vendor"] = bare_module_vendor component["bare_module_batch"] = bare_module_batch @@ -446,7 +466,10 @@ def get_serial_numbers_for_site(site, verbose=False): "Unknown", # Default to "Unknown" if not found ), "flex_pcb_vendor": doc.get("flex_pcb_vendor", "Unknown"), - "flex_pcb_batch": doc.get("flex_pcb_batch", "Unknown"), + "flex_pcb_bare_batch": doc.get("flex_pcb_bare_batch", "Unknown"), + "flex_pcb_populated_batch": doc.get( + "flex_pcb_populated_batch", "Unknown" + ), "bare_module_vendor": doc.get("bare_module_vendor", "Unknown"), "bare_module_batch": doc.get("bare_module_batch", "Unknown"), } -- GitLab From f6f5ee79ca279bb5dbb1f13a53be9c5b48910ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Tue, 4 Nov 2025 13:54:47 +0100 Subject: [PATCH 05/12] Fix typo --- viewer/functions/api.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index ef02e3325..6cdb09b55 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -342,11 +342,9 @@ def get_serial_numbers_for_site(site, verbose=False): if batches: # sort by timestamp, in case there would be several, to find the latest batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) - batches_bare = [ - b for b in batches if "bare" in batches.get("number").lower() - ] + batches_bare = [b for b in batches if "bare" in b.get("number").lower()] batches_populated = [ - b for b in batches if "populated" in batches.get("number").lower() + b for b in batches if "populated" in b.get("number").lower() ] if len(batches_bare) > 0: flex_pcb_bare_batch = batches_bare[0].get("number", "") -- GitLab From 13e212b76be7eb0e69987b575a6b91c1bff23817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Mon, 3 Nov 2025 17:18:36 +0100 Subject: [PATCH 06/12] Add flex batch --- viewer/functions/api.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index c1670a243..26b7041ca 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -333,6 +333,24 @@ def get_serial_numbers_for_site(site, verbose=False): flex_pcb_vendor = flex_pcb_vendor.replace("None-None", "Unknown") flex_pcb_vendor = flex_pcb_vendor.replace("None", "Unknown") + # batch name + flex_pcb_batch = "" + batches = flex.get("batches", []) + # restrict to "ready" + batches = [b for b in batches if b.get("state") == "ready"] + if batches: + # sort by timestamp, in case there would be several, to find the latest + batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) + batch = batches[0] + flex_pcb_batch = batch.get("number", "") + if flex_pcb_batch: + # shorten the batch name (example batch name: "IZM Quad Bare Module production batch 14 (May 2025)") + print(flex_pcb_batch) + flex_pcb_batch = flex_pcb_batch[flex_pcb_batch.find("batch") :] + else: + flex_pcb_batch = "Unknown" + + bare_module = ( localdb.component.find_one({"_id": ObjectId(bare_id)}) if ObjectId.is_valid(bare_id) @@ -372,6 +390,7 @@ def get_serial_numbers_for_site(site, verbose=False): # update entry in dictionary component["flex_pcb_vendor"] = flex_pcb_vendor + component["flex_pcb_batch"] = flex_pcb_batch component["bare_module_vendor"] = bare_module_vendor component["bare_module_batch"] = bare_module_batch @@ -426,6 +445,7 @@ def get_serial_numbers_for_site(site, verbose=False): "Unknown", # Default to "Unknown" if not found ), "flex_pcb_vendor": doc.get("flex_pcb_vendor", "Unknown"), + "flex_pcb_batch": doc.get("flex_pcb_batch", "Unknown"), "bare_module_vendor": doc.get("bare_module_vendor", "Unknown"), "bare_module_batch": doc.get("bare_module_batch", "Unknown"), } -- GitLab From 7548799c299a1bed2437b8e39871d265de0ff433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Mon, 3 Nov 2025 17:19:55 +0100 Subject: [PATCH 07/12] Remove print --- viewer/functions/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 26b7041ca..87666e635 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -345,12 +345,11 @@ def get_serial_numbers_for_site(site, verbose=False): flex_pcb_batch = batch.get("number", "") if flex_pcb_batch: # shorten the batch name (example batch name: "IZM Quad Bare Module production batch 14 (May 2025)") - print(flex_pcb_batch) + logger.error(flex_pcb_batch) flex_pcb_batch = flex_pcb_batch[flex_pcb_batch.find("batch") :] else: flex_pcb_batch = "Unknown" - bare_module = ( localdb.component.find_one({"_id": ObjectId(bare_id)}) if ObjectId.is_valid(bare_id) -- GitLab From 44cfd154c5609839f5dbe4da056348b121f5e36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Mon, 3 Nov 2025 17:39:19 +0100 Subject: [PATCH 08/12] Flex PCB formatting --- viewer/functions/api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 87666e635..05f5af951 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -344,9 +344,11 @@ def get_serial_numbers_for_site(site, verbose=False): batch = batches[0] flex_pcb_batch = batch.get("number", "") if flex_pcb_batch: - # shorten the batch name (example batch name: "IZM Quad Bare Module production batch 14 (May 2025)") - logger.error(flex_pcb_batch) - flex_pcb_batch = flex_pcb_batch[flex_pcb_batch.find("batch") :] + # shorten the batch name (example batch name: "Pixel_Populated_PCB_Norbit_Production_20250626") + prefix = "Pixel_Populated_PCB_" + pos = flex_pcb_batch.find(prefix) + if pos > -1: + flex_pcb_batch = flex_pcb_batch[pos + len(prefix) :] else: flex_pcb_batch = "Unknown" -- GitLab From d5d48e5f6b8dfa5185e932395036defd2d82c116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Tue, 4 Nov 2025 12:15:15 +0100 Subject: [PATCH 09/12] Bare vs populated flex batch --- viewer/functions/api.py | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 05f5af951..ef02e3325 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -334,23 +334,42 @@ def get_serial_numbers_for_site(site, verbose=False): flex_pcb_vendor = flex_pcb_vendor.replace("None", "Unknown") # batch name - flex_pcb_batch = "" + flex_pcb_bare_batch = "" + flex_pcb_populated_batch = "" batches = flex.get("batches", []) # restrict to "ready" batches = [b for b in batches if b.get("state") == "ready"] if batches: # sort by timestamp, in case there would be several, to find the latest batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) - batch = batches[0] - flex_pcb_batch = batch.get("number", "") - if flex_pcb_batch: + batches_bare = [ + b for b in batches if "bare" in batches.get("number").lower() + ] + batches_populated = [ + b for b in batches if "populated" in batches.get("number").lower() + ] + if len(batches_bare) > 0: + flex_pcb_bare_batch = batches_bare[0].get("number", "") + if len(batches_populated) > 0: + flex_pcb_populated_batch = batches_populated[0].get("number", "") + if flex_pcb_bare_batch: + # shorten the batch name + prefix = "Pixel_Bare_PCB_" + pos = flex_pcb_bare_batch.find(prefix) + if pos > -1: + flex_pcb_bare_batch = flex_pcb_bare_batch[pos + len(prefix) :] + else: + flex_pcb_bare_batch = "Unknown" + if flex_pcb_populated_batch: # shorten the batch name (example batch name: "Pixel_Populated_PCB_Norbit_Production_20250626") prefix = "Pixel_Populated_PCB_" - pos = flex_pcb_batch.find(prefix) + pos = flex_pcb_populated_batch.find(prefix) if pos > -1: - flex_pcb_batch = flex_pcb_batch[pos + len(prefix) :] + flex_pcb_populated_batch = flex_pcb_populated_batch[ + pos + len(prefix) : + ] else: - flex_pcb_batch = "Unknown" + flex_pcb_populated_batch = "Unknown" bare_module = ( localdb.component.find_one({"_id": ObjectId(bare_id)}) @@ -391,7 +410,8 @@ def get_serial_numbers_for_site(site, verbose=False): # update entry in dictionary component["flex_pcb_vendor"] = flex_pcb_vendor - component["flex_pcb_batch"] = flex_pcb_batch + component["flex_pcb_bare_batch"] = flex_pcb_bare_batch + component["flex_pcb_populated_batch"] = flex_pcb_populated_batch component["bare_module_vendor"] = bare_module_vendor component["bare_module_batch"] = bare_module_batch @@ -446,7 +466,10 @@ def get_serial_numbers_for_site(site, verbose=False): "Unknown", # Default to "Unknown" if not found ), "flex_pcb_vendor": doc.get("flex_pcb_vendor", "Unknown"), - "flex_pcb_batch": doc.get("flex_pcb_batch", "Unknown"), + "flex_pcb_bare_batch": doc.get("flex_pcb_bare_batch", "Unknown"), + "flex_pcb_populated_batch": doc.get( + "flex_pcb_populated_batch", "Unknown" + ), "bare_module_vendor": doc.get("bare_module_vendor", "Unknown"), "bare_module_batch": doc.get("bare_module_batch", "Unknown"), } -- GitLab From 0b84257ac1077050301bb23c2567fc18a891ea1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Tue, 4 Nov 2025 13:54:47 +0100 Subject: [PATCH 10/12] Fix typo --- viewer/functions/api.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index ef02e3325..6cdb09b55 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -342,11 +342,9 @@ def get_serial_numbers_for_site(site, verbose=False): if batches: # sort by timestamp, in case there would be several, to find the latest batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) - batches_bare = [ - b for b in batches if "bare" in batches.get("number").lower() - ] + batches_bare = [b for b in batches if "bare" in b.get("number").lower()] batches_populated = [ - b for b in batches if "populated" in batches.get("number").lower() + b for b in batches if "populated" in b.get("number").lower() ] if len(batches_bare) > 0: flex_pcb_bare_batch = batches_bare[0].get("number", "") -- GitLab From cb2db84cd4e7c53e9a6476c1db61c248914b8eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Fri, 14 Nov 2025 13:22:59 +0100 Subject: [PATCH 11/12] Better way to parse batch type --- viewer/functions/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 6cdb09b55..54e83e251 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -342,9 +342,11 @@ def get_serial_numbers_for_site(site, verbose=False): if batches: # sort by timestamp, in case there would be several, to find the latest batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) - batches_bare = [b for b in batches if "bare" in b.get("number").lower()] + batches_bare = [ + b for b in batches if b.get("type") == "PIXEL_BARE_PCB_BATCH" + ] batches_populated = [ - b for b in batches if "populated" in b.get("number").lower() + b for b in batches if b.get("type") == "PIXEL_POPULATED_PCB_BATCH" ] if len(batches_bare) > 0: flex_pcb_bare_batch = batches_bare[0].get("number", "") -- GitLab From ff988cfc771b72a5244e0e6088ef6760446ee227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Chapon?= Date: Fri, 14 Nov 2025 14:11:58 +0100 Subject: [PATCH 12/12] Fix getting batch type --- viewer/functions/api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/viewer/functions/api.py b/viewer/functions/api.py index 54e83e251..e6ff51e19 100644 --- a/viewer/functions/api.py +++ b/viewer/functions/api.py @@ -343,10 +343,14 @@ def get_serial_numbers_for_site(site, verbose=False): # sort by timestamp, in case there would be several, to find the latest batches = sorted(batches, key=lambda b: b["stateTs"], reverse=True) batches_bare = [ - b for b in batches if b.get("type") == "PIXEL_BARE_PCB_BATCH" + b + for b in batches + if b.get("batchType", {}).get("code") == "PIXEL_BARE_PCB_BATCH" ] batches_populated = [ - b for b in batches if b.get("type") == "PIXEL_POPULATED_PCB_BATCH" + b + for b in batches + if b.get("batchType", {}).get("code") == "PIXEL_POPULATED_PCB_BATCH" ] if len(batches_bare) > 0: flex_pcb_bare_batch = batches_bare[0].get("number", "") -- GitLab