← back to Carnegie Import
publish_shopify: add paginated dedup guard so re-runs skip already-live parent-applications
084d704c3e2cdae10a24b9d278ff891575349ba6 · 2026-07-22 09:11:50 -0700 · Steve Abrams
Files touched
Diff
commit 084d704c3e2cdae10a24b9d278ff891575349ba6
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Jul 22 09:11:50 2026 -0700
publish_shopify: add paginated dedup guard so re-runs skip already-live parent-applications
---
publish_shopify.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/publish_shopify.py b/publish_shopify.py
index 97c5041..bae7395 100644
--- a/publish_shopify.py
+++ b/publish_shopify.py
@@ -86,6 +86,28 @@ def main():
ap.add_argument("--apply",action="store_true")
a=ap.parse_args()
prods=products_for(a.cls)
+ # Dedup guard: skip parent-applications already live (idempotent re-runs, canary overlap).
+ existing=set()
+ try:
+ url="products.json?vendor=Carnegie&limit=250&fields=id,variants"
+ while url:
+ req=urllib.request.Request(f"{API}/{url}",headers={"X-Shopify-Access-Token":TOKEN,"User-Agent":UA})
+ with urllib.request.urlopen(req,timeout=60) as r:
+ body=json.loads(r.read()); link=r.headers.get("Link","")
+ for pr in body.get("products",[]):
+ for v in pr.get("variants",[]):
+ sku=v.get("sku","")
+ if sku.endswith("-SAMPLE"): existing.add(sku[:-7])
+ url=None
+ for part in link.split(","):
+ if 'rel="next"' in part:
+ url=part[part.find("<")+1:part.find(">")].split("/admin/api/2024-10/")[-1]
+ except Exception as e:
+ print(f"[publish] warn: could not read existing products for dedup: {e}")
+ before=len(prods)
+ prods=[p for p in prods if p["parent"] not in existing]
+ skipped=before-len(prods)
+ if skipped: print(f"[publish] dedup: skipping {skipped} already-live parent-applications")
if a.limit: prods=prods[:a.limit]
print(f"[publish] class={a.cls} products={len(prods)} apply={a.apply} delay={a.delay}s")
tot_var=sum(len(p['dwskus'])+1 for p in prods)
← 7b70ec1 Add palette enrichment (5928 SKUs, full hex+pct) + dry-run-v
·
back to Carnegie Import
·
chore: lint (3 autofix), refactor, untrack images, v0.1.0 (s f731bfe →