mirror of
https://github.com/dlt-hub/dlt.git
synced 2025-12-17 19:31:30 +00:00
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
This commit is contained in:
@@ -7,7 +7,6 @@ app = marimo.App()
|
||||
@app.cell(hide_code=True)
|
||||
async def initialize():
|
||||
import sys
|
||||
import marimo as mo
|
||||
|
||||
# NOTE: this installs the dependencies for the notebook if run on pyodide
|
||||
if sys.platform == "emscripten":
|
||||
@@ -28,24 +27,26 @@ def run():
|
||||
import dlt
|
||||
import requests
|
||||
|
||||
@dlt.resource(table_name="users")
|
||||
def users():
|
||||
yield requests.get("https://jsonplaceholder.typicode.com/users").json()
|
||||
@dlt.resource(name="customers")
|
||||
def fetch_customers():
|
||||
response = requests.get("https://jaffle-shop.dlthub.com/api/v1/customers?limit=100")
|
||||
yield response.json()
|
||||
|
||||
pipeline = dlt.pipeline(
|
||||
pipeline_name="users_pipeline",
|
||||
pipeline_name="customers_pipeline",
|
||||
destination="duckdb",
|
||||
dataset_name="raw_data",
|
||||
dev_mode=True,
|
||||
)
|
||||
print(pipeline.run(users()))
|
||||
load_info = pipeline.run(fetch_customers())
|
||||
print(load_info)
|
||||
return (pipeline,)
|
||||
|
||||
|
||||
@app.cell
|
||||
def view(pipeline):
|
||||
# NOTE: This line displays the data of the users table in a marimo table
|
||||
pipeline.dataset().users.df()
|
||||
# NOTE: This line displays the data of the customers table in a marimo table
|
||||
pipeline.dataset().customers.df()
|
||||
return
|
||||
|
||||
|
||||
@@ -53,13 +54,13 @@ def view(pipeline):
|
||||
def connect(pipeline):
|
||||
# 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
|
||||
con = pipeline.dataset().ibis()
|
||||
return
|
||||
return (con,)
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
def tests(pipeline):
|
||||
# NOTE: this cell is only needed for testing this notebook on ci
|
||||
assert pipeline.dataset().users.df().shape[0] == 10
|
||||
assert pipeline.dataset().customers.df().shape[0] == 100
|
||||
return
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user