Clean AST implementation for GoFish graphics library
Project description
gofish-python
A Python wrapper for the GoFish graphics library. Supports the mid-level chart API for now. The low-level API is not supported yet. (See notes/design.md and notes/implementation.md for more details.)
Note: This package uses uv for fast package management and testing.
Prerequisites
- Python 3.8+
- uv - Fast Python package manager
- Node.js (for building the widget bundle)
- pnpm (for managing Node.js dependencies)
Installation
This package uses uv for fast package management.
cd packages/gofish-python
uv pip install -e .
Installing Node.js Dependencies
If you need to build the widget bundle, install Node.js dependencies:
pnpm install
Usage
from gofish import chart, spread, stack, rect
# Create a chart specification
data = [{"lake": "A", "species": "B", "count": 10}]
c = (
chart(data, options={"w": 800, "h": 600})
.flow(
spread("lake", dir="x", spacing=64),
stack("species", dir="y", spacing=0),
)
.mark(rect(h="count", fill="species"))
)
# Convert to JSON IR
ir = c.to_ir()
print(ir)
# {
# "data": None,
# "operators": [
# {"type": "spread", "field": "lake", "dir": "x", "spacing": 64},
# {"type": "stack", "field": "species", "dir": "y", "spacing": 0}
# ],
# "mark": {"type": "rect", "h": "count", "fill": "species"},
# "options": {"w": 800, "h": 600}
# }
IR Format
The JSON IR has the following structure:
{
"data": null,
"operators": [
{ "type": "spread", "field": "lake", "dir": "x", "spacing": 8 },
{ "type": "derive", "lambdaId": "uuid-here" },
{ "type": "stack", "field": "species", "dir": "y" }
],
"mark": { "type": "rect", "h": "count", "fill": "species" },
"options": {}
}
Building
Building the Widget Bundle
The widget bundle is a self-contained JavaScript module that includes all dependencies. Build it with:
# From the package directory
pnpm run build:widget
# Or directly with Node.js
node build-widget.mjs
This will:
- Bundle the TypeScript widget source (
widget-src/index.ts) - Include all dependencies (gofish-graphics, solid-js, apache-arrow)
- Output to
gofish/_static/widget.esm.js
Note: The build process will automatically use gofish-graphics/dist/index.js if available, otherwise it falls back to the package import. Make sure gofish-graphics is built first if you're developing locally.
Running Tests
Python Unit Tests
# Install with test dependencies
uv pip install -e ".[test]"
# Run all tests
uv run pytest
# Or run directly if installed
pytest
# Run specific test file
pytest tests/test_ast.py
# Run with verbose output
pytest -v
Jupyter Notebook Tests
The package includes Jupyter notebooks for interactive testing:
tests/test_ir.ipynb- Tests for IR generationtests/test_rendering.ipynb- Tests for widget rendering
To run these:
# Start Jupyter
jupyter notebook
# Or use the provided script (if available)
./run_notebook.sh
Development Workflow
-
Install dependencies:
uv pip install -e ".[test]" pnpm install
-
Make changes to Python code or widget TypeScript source
-
Build widget (if you modified widget code):
pnpm run build:widget
-
Run tests:
pytest
-
Test in Jupyter (optional):
jupyter notebook tests/test_rendering.ipynb
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gofish_graphics-0.1.1.dev20260714.tar.gz.
File metadata
- Download URL: gofish_graphics-0.1.1.dev20260714.tar.gz
- Upload date:
- Size: 944.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdaf84b5224de98fbfbf7211f9b73d32ff3ea08acab488ac1e1f91ea8578f65b
|
|
| MD5 |
7ea108d6010ee9c358f9a77446321194
|
|
| BLAKE2b-256 |
c43f84b1e15774ae8ed24f8241f4aa0d03e400b24788a19998fa589b903a5b91
|
Provenance
The following attestation bundles were made for gofish_graphics-0.1.1.dev20260714.tar.gz:
Publisher:
release.yml on gofish-graphics/gofish-graphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gofish_graphics-0.1.1.dev20260714.tar.gz -
Subject digest:
fdaf84b5224de98fbfbf7211f9b73d32ff3ea08acab488ac1e1f91ea8578f65b - Sigstore transparency entry: 2166926003
- Sigstore integration time:
-
Permalink:
gofish-graphics/gofish-graphics@bfde86bc3136efedd17babf43f402d662fdda494 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/gofish-graphics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bfde86bc3136efedd17babf43f402d662fdda494 -
Trigger Event:
schedule
-
Statement type:
File details
Details for the file gofish_graphics-0.1.1.dev20260714-py3-none-any.whl.
File metadata
- Download URL: gofish_graphics-0.1.1.dev20260714-py3-none-any.whl
- Upload date:
- Size: 941.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b49a8e48e5f2fd6ba3bca0abc0a694400049556b4dd00ed306f2097ca4769dc
|
|
| MD5 |
b259d313b27072dc98a85ec54376a5c9
|
|
| BLAKE2b-256 |
4c84bf20e52d7df8cc01e1f70254abd5539e7a24e1a7df80429815ae046b61bb
|
Provenance
The following attestation bundles were made for gofish_graphics-0.1.1.dev20260714-py3-none-any.whl:
Publisher:
release.yml on gofish-graphics/gofish-graphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gofish_graphics-0.1.1.dev20260714-py3-none-any.whl -
Subject digest:
3b49a8e48e5f2fd6ba3bca0abc0a694400049556b4dd00ed306f2097ca4769dc - Sigstore transparency entry: 2166926009
- Sigstore integration time:
-
Permalink:
gofish-graphics/gofish-graphics@bfde86bc3136efedd17babf43f402d662fdda494 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/gofish-graphics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bfde86bc3136efedd17babf43f402d662fdda494 -
Trigger Event:
schedule
-
Statement type: