Skip to content

Commit 236b509

Browse files
committed
Gate Foursquare demo cells on checkbox
1 parent a3ce93e commit 236b509

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

examples/widget_demo.marimo.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _(
163163
@app.cell
164164
def _(mo):
165165
show_fsq = mo.ui.checkbox(
166-
label="Enable Foursquare demo (downloads a large DuckDB file, optional)",
166+
label="Enable Foursquare demo",
167167
value=False,
168168
)
169169
show_fsq
@@ -175,9 +175,7 @@ def _(mo, show_fsq):
175175
fsq_ok = show_fsq.value
176176
mo.stop(
177177
not fsq_ok,
178-
mo.md(
179-
"Foursquare demo is disabled. Enable it above to show this section (and optionally download a large file)."
180-
),
178+
mo.md("Foursquare demo is disabled."),
181179
)
182180
mo.md(
183181
"""
@@ -193,25 +191,29 @@ def _(mo, show_fsq):
193191

194192

195193
@app.cell
196-
def _(fsq_ok):
194+
def _(fsq_ok, mo):
195+
mo.stop(not fsq_ok)
197196
fsq_preagg_url = "https://sampledata.sidequery.dev/sidemantic/foursquare_preagg.db"
198197
return (fsq_preagg_url,)
199198

200199

201200
@app.cell
202-
def _(examples_dir, fsq_ok):
201+
def _(examples_dir, fsq_ok, mo):
202+
mo.stop(not fsq_ok)
203203
target_path = examples_dir / "foursquare_preagg.db"
204204
return (target_path,)
205205

206206

207207
@app.cell
208208
def _(
209+
fsq_ok,
209210
fsq_preagg_url,
210211
http_error_cls,
211212
mo,
212213
url_error_cls,
213214
urllib_request,
214215
):
216+
mo.stop(not fsq_ok)
215217
size_mb = None
216218
try:
217219
_req = urllib_request.Request(fsq_preagg_url, method="HEAD")
@@ -230,7 +232,8 @@ def _(
230232

231233

232234
@app.cell
233-
def _(datetime_cls, mo, target_path):
235+
def _(datetime_cls, fsq_ok, mo, target_path):
236+
mo.stop(not fsq_ok)
234237
if target_path.exists():
235238
_size_mb = target_path.stat().st_size / 1_000_000
236239
_updated = datetime_cls.fromtimestamp(target_path.stat().st_mtime).strftime("%Y-%m-%d %H:%M:%S")
@@ -241,7 +244,8 @@ def _(datetime_cls, mo, target_path):
241244

242245

243246
@app.cell
244-
def _(mo, target_path):
247+
def _(fsq_ok, mo, target_path):
248+
mo.stop(not fsq_ok)
245249
label = (
246250
"Re-download Foursquare pre-agg DB (overwrite)" if target_path.exists() else "Download Foursquare pre-agg DB"
247251
)
@@ -255,12 +259,14 @@ def _(
255259
datetime_cls,
256260
download,
257261
fsq_preagg_url,
262+
fsq_ok,
258263
http_error_cls,
259264
mo,
260265
target_path,
261266
url_error_cls,
262267
urllib_request,
263268
):
269+
mo.stop(not fsq_ok)
264270
if download.value:
265271
target_path.parent.mkdir(parents=True, exist_ok=True)
266272

@@ -302,7 +308,8 @@ def _(
302308

303309

304310
@app.cell
305-
def _(fsq_preagg_url, mo, target_path):
311+
def _(fsq_ok, fsq_preagg_url, mo, target_path):
312+
mo.stop(not fsq_ok)
306313
fsq_source = None
307314
if target_path.exists():
308315
mo.md(f"Using local pre-agg DB: `{target_path}`")
@@ -314,7 +321,8 @@ def _(fsq_preagg_url, mo, target_path):
314321

315322

316323
@app.cell
317-
def _(duckdb_adapter_cls, fsq_source, mo):
324+
def _(duckdb_adapter_cls, fsq_ok, fsq_source, mo):
325+
mo.stop(not fsq_ok)
318326
adapter_fsq_preagg = duckdb_adapter_cls(":memory:")
319327
try:
320328
adapter_fsq_preagg.conn.execute("load httpfs")
@@ -330,12 +338,15 @@ def _(duckdb_adapter_cls, fsq_source, mo):
330338
def _(
331339
adapter_fsq_preagg,
332340
dimension_cls,
341+
fsq_ok,
333342
metric_cls,
334343
metrics_explorer_cls,
335344
model_cls,
345+
mo,
336346
preaggregation_cls,
337347
semantic_layer_cls,
338348
):
349+
mo.stop(not fsq_ok)
339350
places_model_preagg = model_cls(
340351
name="places",
341352
table="places",

0 commit comments

Comments
 (0)