Notebooks exported from Aesops
Rerun a workbook chat's SQL steps locally in Jupyter using the aesops SDK and your own API key.
Export a chat from its Steps tab or its "⋮" menu (Export Notebook, in DuckDB
or pandas flavor) to download a .ipynb that reruns the SQL steps the AI ran
in that chat, outside Aesops.
To export every chat in a workbook at once, use the download icon next to the Chats heading (it appears when the workbook has two or more chats). Chats with no SQL steps are skipped. You get a single notebook if only one chat qualifies, otherwise a zip with one notebook per chat.
Running it
-
Install the SDK — version 0.3.0 or later (older versions lack the
con/view_nameoptions the notebook uses):pip install aesops -
Create a read-scoped API key from your Aesops account's workspace and paste it into the setup cell's
Client(api_key="..."). -
Run the Setup — run once cells top to bottom. They create the client, one local DuckDB connection
con, and load each dataset the notebook uses. -
Run any analysis cell, in any order and as often as you like.
Data links expire after about an hour. If a query starts failing with a 403 error, re-run the cell that loads the datasets to refresh them.
pandas version
Export as pandas (or Pandas in the export menu) downloads the same
notebook with each step returning a pandas DataFrame instead of a DuckDB
table. Export as DuckDB is the default. The SQL is
unchanged (it isn't translated to pandas code); the setup cell installs
aesops[pandas] and each step ends with .df(). DataFrames are loaded into
memory, so very large results cost memory.
What's in it
- Title cell: the chat's objective (or the workbook's, if the chat has none; omitted if neither is set), the workbook and chat dates, the workbook's datasets and saved outputs, and how many steps run here versus appear as SQL only.
- Setup cells: the client, the connection, and one
ds.to_duckdb(con=con, view_name="ds_xxxx")per dataset (see Loading data). - Glossary: maps each
ds_xxxxalias in the SQL to the dataset's name and slug. - Analysis cells: one line each,
step_N = con.sql("""..."""), with the original SQL unmodified. The result renders as a table; call.df()or.pl()for a DataFrame.
Charts
Chart steps keep their SQL cell and add a cell that redraws the chart with
seaborn, colored with the Aesops chart palette
(aesops.colors.aeschart). The code is generated from the chart's settings, so
it's plain, editable Python. Notebooks with charts also install seaborn
(and the pandas extra, since seaborn works on DataFrames).
Bar, line, area, scatter, box plot and heatmap use seaborn directly. Pie,
donut and radar use matplotlib (seaborn has no equivalent), and map charts use
geopandas. The redraw approximates the in-app chart rather than matching it
exactly.
Limits
- Saved outputs are rebuilt from the query that created them, so they're recomputed from the datasets as they are now. They can differ from the snapshot saved in Aesops if the data changed or the saved result was row-limited.
- Steps that use data that can't be rebuilt outside Aesops (for example a dataset since removed from the workbook) are shown as SQL only and not run.
- Datasets you haven't published yet are marked draft in the glossary and still run, but only with an API key from the account that owns them.
- Steps that failed in Aesops are kept for the record, shown as SQL only with a note, and not run.
- Only the AI's steps are included, not SQL you wrote yourself, and only one chat per notebook.
- Keep the
Clientopen for the notebook's whole lifetime — don't wrap it in awithblock (see Context manager).
DuckDB primer
New to DuckDB? Why the SDK is built on it, what DuckDBPyRelation is, and a few worked SQL examples over a dataset.
Brand colors
The Aesops chart palette (aeschart) as plain hex strings, with the light and dark swatches shown inline, so a chart built from Aesops data can match the platform's own look.