A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
/* Copyright 2026 Marimo. All rights reserved. */
import type {
DataSourceDiscoveryResult,
SQLSchemaListPreview,
SQLTableListPreview,
SQLTablePreview,
ValidateSQLResult,
} from "../kernel/messages";
import { CachingRequestRegistry } from "../network/CachingRequestRegistry";
import { DeferredRequestRegistry } from "../network/DeferredRequestRegistry";
import { getRequestClient } from "../network/requests";
import type {
ListSQLSchemasRequest,
ListSQLTablesRequest,
PreviewSQLTableRequest,
ValidateSQLRequest,
} from "../network/types";
// We make a request to the backend to preview the table, passing in Engine, DB, Schema, and Table
// The backend returns data tables, which could also exist in other engines, dbs, schemas
// Thus, we use the request ID pattern to match the response to the request
export const DiscoverDataSources = new DeferredRequestRegistry<
{},
DataSourceDiscoveryResult
>("data-source-discovery-result", async (requestId) => {
const client = getRequestClient();
await client.discoverDataSources({
requestId,
});
});
export const PreviewSQLTable = new DeferredRequestRegistry<
Omit<PreviewSQLTableRequest, "requestId">,
SQLTablePreview
>("sql-table-preview", async (requestId, req) => {
const client = getRequestClient();
await client.previewSQLTable({
requestId: requestId,
...req,
});
});
export const PreviewSQLSchemaList = new DeferredRequestRegistry<
Omit<ListSQLSchemasRequest, "requestId">,
SQLSchemaListPreview
>("sql-schema-list-preview", async (requestId, req) => {
const client = getRequestClient();
await client.previewSQLSchemaList({
requestId: requestId,
...req,
});
});
export const PreviewSQLTableList = new DeferredRequestRegistry<
Omit<ListSQLTablesRequest, "requestId">,
SQLTableListPreview
>("sql-table-list-preview", async (requestId, req) => {
const client = getRequestClient();
await client.previewSQLTableList({
requestId: requestId,
...req,
});
});
export const ValidateSQL = new CachingRequestRegistry(
new DeferredRequestRegistry<
Omit<ValidateSQLRequest, "requestId">,
ValidateSQLResult
>("validate-sql", async (requestId, req) => {
const client = getRequestClient();
await client.validateSQL({
requestId: requestId,
...req,
});
}),
{
// Only keep the last 3 validation results
maxSize: 3,
},
);