
Setup Python Tools
Wire client-side Pyodide Python tool execution into a Cognite Flows app after Atlas chat is integrated—without hand-rolling usePyodideRuntime and pythonRuntime hooks.
Install
npx skills add https://github.com/cognitedata/builder-skills --skill setup-python-toolsWhat is this skill?
- Mandatory skill when adding Pyodide/Python tools—do not manually configure usePyodideRuntime or pythonRuntime on useAtla
- Copies python.ts, pyodide.ts, pyodide-react.ts, pyodide-runtime.ts from integrate-atlas-chat code bundle
- Handles Pyodide install, hook setup, loading UI, and client tool confirmation flow for runPythonCode
- Explicit prerequisite: integrate-atlas-chat complete (vendored src/atlas-agent + peer deps)
- Triggers on pythonRuntime, usePyodideRuntime, runPythonCode, and client-side Python execution
Adoption & trust: 1k installs on skills.sh; 4 GitHub stars; 2/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
This is a concrete Build integration task for Flows apps with Atlas agents, not a cross-journey methodology skill. Integrations fits Pyodide runtime wiring, CDF runPythonCode tools, and chat hook plumbing between agent config and the React client.
Common Questions / FAQ
Is Setup Python Tools safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Setup Python Tools
# Set Up Python Tool Execution Add client-side Python tool execution via Pyodide to this Flows app. Target: **$ARGUMENTS** ## Prerequisite **`integrate-atlas-chat`** must already be complete: the app should have vendored atlas-agent code under `src/atlas-agent/` (including `react.ts` for `useAtlasChat`) and the peer dependencies from that skill (`@sinclair/typebox`, `ajv`, `ajv-formats`). Copy the Python-related modules from the **`integrate-atlas-chat`** skill `code/` directory into `src/atlas-agent/` when adding Pyodide (`python.ts`, `pyodide.ts`, `pyodide-react.ts`, `pyodide-runtime.ts` — see **`integrate-atlas-chat`** Step 5). ## Background Atlas agents can have Python tools defined in their CDF config (`type: "runPythonCode"`). When the agent calls one, it arrives as a `toolConfirmation` (auto-allowed) followed by a `clientTool` action. The library fetches the tool's Python code from the agent config automatically and executes it via the provided `pythonRuntime`. You only need to: 1. Set up `usePyodideRuntime` to get a runtime instance 2. Pass `pythonRuntime` to `useAtlasChat` No `PythonToolConfig` entries — the library reads the code from the agent's CDF config. The flow is: 1. `usePyodideRuntime` loads Pyodide (~30MB, cached after first load), installs packages, and injects Cognite SDK credentials into the Python environment 2. When the agent calls a Python tool, the library fetches its code from the agent's CDF config (cached per session), wraps it, executes it in Pyodide, and returns the result --- ## Step 1 — Understand the app Read these files before touching anything: - `package.json` — detect package manager and existing deps - The component that calls `useAtlasChat` — understand current tools/config --- ## Step 2 — Install Pyodide Install **exactly** `pyodide@0.29.3` using the app's package manager. This version must match the CDN artifacts loaded at runtime — installing a different version will cause errors. - pnpm → `pnpm add pyodide@0.29.3` - npm → `npm install pyodide@0.29.3` - yarn → `yarn add pyodide@0.29.3` > **Note**: After **`integrate-atlas-chat`**, `@sinclair/typebox`, `ajv`, and `ajv-formats` should > already be installed. If anything is missing, install the versions listed in that skill's **Dependencies** table. --- ## Step 3 — Set up usePyodideRuntime In the component that calls `useAtlasChat`, add the Pyodide runtime hook: ```tsx import { loadPyodide } from "pyodide"; import { usePyodideRuntime } from "./atlas-agent/pyodide-react"; import { useAtlasChat } from "./atlas-agent/react"; function MyChat() { const { sdk, isLoading } = useDune(); // Initialize Python runtime (loads Pyodide, installs packages, sets up Cognite SDK) const { runtime: pythonRuntime, loading: pythonLoading, progress: pythonProgress, error: pythonError, isReady: pythonReady, } = usePyodideRuntime({ loadPyodide, client: isLoading ? null : sdk, requirements: ["pandas", "numpy"], // optional — additional packages }); // ... useAtlasChat below } ``` ### Hook API reference | Return field | Type | Description | |---|---|---| | `runtime` | `PythonRuntime \| undefined` | The initialized runtime, or undefined if not ready | | `loading` | `boolean` | True while Pyodide is loading / initializing | | `error` | `string \| null` | Error message if initialization f