Skip to content
27 changes: 13 additions & 14 deletions docs/notebooks/playground/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,48 @@ async def initialize():
await micropip.install("dlt[duckdb]")
await micropip.install("pandas")
# dependencies needed for ibis
await micropip.install("sqlite3")
await micropip.install("requests")
await micropip.install("ibis-framework[duckdb]")

return sys, mo


@app.cell
def run(dlt):
def run():
import dlt
import requests

@dlt.resource(table_name="items")
def foo():
for i in range(50):
yield {"id": i, "name": f"This is item {i}"}
@dlt.resource(table_name="users")
def users():
yield from requests.get("https://jsonplaceholder.typicode.com/users").json()

pipeline = dlt.pipeline(
pipeline_name="python_data_example",
pipeline_name="users_pipeline",
destination="duckdb",
dataset_name="raw_data",
dev_mode=True,
)

load_info = pipeline.run(foo)
print(pipeline.run(users(), refresh=True))
return (pipeline,)


@app.cell
def view(pipeline):
# NOTE: This line displays the data of the items table in a marimo table
pipeline.dataset().items.df()
return
# NOTE: This line displays the data of the users table in a marimo table
return pipeline.dataset().users.df()


@app.cell
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().items.df().shape[0] == 50
assert pipeline.dataset().users.df().shape[0] == 10
return


Expand Down
Loading