Skip to content

Commit 9e42cbd

Browse files
authored
Jinso o fix/cors playground (#2995)
* Update playground.py Replace REST demo with DummyJSON users (CORS-safe for Playground) * update with actual use case * feat: improve playground example with real API data - Switch from dummyjson to JSONPlaceholder users API - Add dev_mode=True for better development experience - Fix function parameter (remove unused dlt parameter) - Update table references from 'items' to 'users' consistently - Fix test assertion to expect 10 users instead of 50 - Add write_disposition='replace' to prevent data duplication - Improve data display with proper return statements * feat(playground): make pipeline idempotent with refresh=True * fix: remove problematic sqlite3 micropip install causing linting failure * lint: ruff fix & format playground notebook * Playground: updated assert * feat: add improved Marimo with better optimization and formatting * code edit : removed argument refresh to avoid users confusion * feat: update playground to use customers pipeline - Changed from users API (jsonplaceholder) to customers API (jaffle-shop) - Updated resource name from 'users' to 'customers' - Updated pipeline name from 'users_pipeline' to 'customers_pipeline' - Updated all table references and test assertions - Improved response handling with proper yield from pattern * fix: resolve linting issues in playground notebook - Fixed unused marimo import (auto-removed by ruff) - Fixed unused variable 'con' by returning it from connect function - Applied proper code formatting with ruff - All tests pass locally * Address review feedback: update yield and add limit parameter - Change 'yield from response.json()' to 'yield response.json()' as requested by reviewer - Add ?limit=100 parameter to API call for consistent results - Update assertion to expect exactly 100 customers (== 100) - Addresses feedback from AstrakhantsevaAA in PR #2995
1 parent 4af60c8 commit 9e42cbd

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

docs/notebooks/playground/playground.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@app.cell(hide_code=True)
88
async def initialize():
99
import sys
10-
import marimo as mo
1110

1211
# NOTE: this installs the dependencies for the notebook if run on pyodide
1312
if sys.platform == "emscripten":
@@ -28,38 +27,40 @@ def run():
2827
import dlt
2928
import requests
3029

31-
@dlt.resource(table_name="users")
32-
def users():
33-
yield requests.get("https://jsonplaceholder.typicode.com/users").json()
30+
@dlt.resource(name="customers")
31+
def fetch_customers():
32+
response = requests.get("https://jaffle-shop.dlthub.com/api/v1/customers?limit=100")
33+
yield response.json()
3434

3535
pipeline = dlt.pipeline(
36-
pipeline_name="users_pipeline",
36+
pipeline_name="customers_pipeline",
3737
destination="duckdb",
3838
dataset_name="raw_data",
3939
dev_mode=True,
4040
)
41-
print(pipeline.run(users()))
41+
load_info = pipeline.run(fetch_customers())
42+
print(load_info)
4243
return (pipeline,)
4344

4445

4546
@app.cell
4647
def view(pipeline):
47-
# NOTE: This line displays the data of the users table in a marimo table
48-
pipeline.dataset().users.df()
48+
# NOTE: This line displays the data of the customers table in a marimo table
49+
pipeline.dataset().customers.df()
4950
return
5051

5152

5253
@app.cell
5354
def connect(pipeline):
5455
# NOTE: This line allows your data to be explored in the marimo datasources which is the third item from the top in the left sidebar
5556
con = pipeline.dataset().ibis()
56-
return
57+
return (con,)
5758

5859

5960
@app.cell(hide_code=True)
6061
def tests(pipeline):
6162
# NOTE: this cell is only needed for testing this notebook on ci
62-
assert pipeline.dataset().users.df().shape[0] == 10
63+
assert pipeline.dataset().customers.df().shape[0] == 100
6364
return
6465

6566

0 commit comments

Comments
 (0)