Theflame47 commited on
Commit
a5c603d
·
verified ·
1 Parent(s): d20f3e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -119,19 +119,21 @@ def run_phase_a(
119
  yield flush()
120
 
121
  shops = _list_shops(logs)
122
- shop_choices = []
 
 
 
 
123
  for s in shops:
124
- sid = s.get("id")
125
- title = s.get("title") or "untitled"
126
- chan = s.get("sales_channel") or "unknown"
127
- shop_choices.append((f"{title} ({chan}) — {sid}", str(sid)))
128
 
129
- if selected_shop_id:
130
- shop_id = str(selected_shop_id)
131
  else:
132
- raise RuntimeError("Pick a shop (Atheria) first, then Run.")
133
 
134
- _log(logs, f"Using shop_id={shop_id}")
135
  yield flush()
136
 
137
  max_templates = int(max_templates or 0)
@@ -162,7 +164,10 @@ def run_phase_a(
162
  pairs_scanned += 1
163
  _log(logs, f"Blueprint {bp_id_s} / Provider {p_id_s}: fetching variants")
164
 
165
- vr = _req("GET", f"/v1/catalog/blueprints/{bp_id_s}/print_providers/{p_id_s}/variants.json?show-out-of-stock=1")
 
 
 
166
  variants = vr.get("variants") if isinstance(vr, dict) else None
167
  if not isinstance(variants, list) or not variants:
168
  continue
@@ -238,7 +243,7 @@ def run_phase_a(
238
  yield "\n".join(logs), "[]", None
239
 
240
 
241
- def fetch_shops_for_dropdown() -> Tuple[str, gr.Dropdown]:
242
  logs: List[str] = []
243
  shops = _list_shops(logs)
244
  choices = []
@@ -247,7 +252,7 @@ def fetch_shops_for_dropdown() -> Tuple[str, gr.Dropdown]:
247
  title = s.get("title") or "untitled"
248
  chan = s.get("sales_channel") or "unknown"
249
  choices.append((f"{title} ({chan}) — {sid}", str(sid)))
250
- return "\n".join(logs), gr.Dropdown(choices=choices, value=None)
251
 
252
 
253
  with gr.Blocks(title="Printify Phase A Probe") as demo:
@@ -274,4 +279,4 @@ with gr.Blocks(title="Printify Phase A Probe") as demo:
274
  outputs=[logs, preview, download],
275
  )
276
 
277
- demo.queue().launch()
 
119
  yield flush()
120
 
121
  shops = _list_shops(logs)
122
+ if not selected_shop_id:
123
+ raise RuntimeError("Pick a shop (Atheria) first, then Run.")
124
+ shop_id = str(selected_shop_id)
125
+
126
+ hit = None
127
  for s in shops:
128
+ if str(s.get("id")) == shop_id:
129
+ hit = s
130
+ break
 
131
 
132
+ if hit:
133
+ _log(logs, f"Selected shop: title={hit.get('title') or 'untitled'} id={shop_id} channel={hit.get('sales_channel') or 'unknown'}")
134
  else:
135
+ _log(logs, f"Selected shop_id={shop_id} (not found in list_shops response?)")
136
 
 
137
  yield flush()
138
 
139
  max_templates = int(max_templates or 0)
 
164
  pairs_scanned += 1
165
  _log(logs, f"Blueprint {bp_id_s} / Provider {p_id_s}: fetching variants")
166
 
167
+ vr = _req(
168
+ "GET",
169
+ f"/v1/catalog/blueprints/{bp_id_s}/print_providers/{p_id_s}/variants.json?show-out-of-stock=1",
170
+ )
171
  variants = vr.get("variants") if isinstance(vr, dict) else None
172
  if not isinstance(variants, list) or not variants:
173
  continue
 
243
  yield "\n".join(logs), "[]", None
244
 
245
 
246
+ def fetch_shops_for_dropdown() -> Tuple[str, dict]:
247
  logs: List[str] = []
248
  shops = _list_shops(logs)
249
  choices = []
 
252
  title = s.get("title") or "untitled"
253
  chan = s.get("sales_channel") or "unknown"
254
  choices.append((f"{title} ({chan}) — {sid}", str(sid)))
255
+ return "\n".join(logs), gr.update(choices=choices, value=None)
256
 
257
 
258
  with gr.Blocks(title="Printify Phase A Probe") as demo:
 
279
  outputs=[logs, preview, download],
280
  )
281
 
282
+ demo.queue().launch(server_name="0.0.0.0", server_port=7860)