Development Setup¶
This guide covers setting up a development environment for contributing to PyNodeWidget.
Prerequisites¶
- Python 3.12+: Core runtime
- uv: Fast Python package manager (recommended)
- Bun: JavaScript bundler for building frontend assets
- Git: Version control
Initial Setup¶
1. Clone the Repository¶
2. Install Dependencies¶
Using uv (recommended):
# Install Python dependencies
uv sync
# Install development dependencies
uv pip install -e ".[dev,docs]"
# Install documentation dependencies separately if needed
uv pip install mkdocs mkdocs-material 'mkdocstrings[python]' pymdown-extensions
Using pip:
3. Build JavaScript Assets¶
Development Workflow¶
JavaScript Development¶
For frontend development with hot reload:
This starts Vite in development mode with hot module replacement.
Building JavaScript¶
Built assets are automatically copied to src/pynodewidget/static/.
Python Development¶
The package is installed in editable mode, so changes to Python files are immediately available:
Testing Your Changes¶
In a Jupyter notebook:
from pynodewidget import NodeFlowWidget, JsonSchemaNodeWidget
# Test your changes
flow = NodeFlowWidget()
flow
Documentation¶
Serving Documentation Locally¶
With taskipy (recommended):
Or directly:
Visit http://127.0.0.1:8000 to view the documentation. Changes to markdown files are reflected automatically.
Building Documentation¶
With taskipy:
Or directly:
Testing Documentation Build¶
Ensure documentation builds without errors:
The --strict flag treats warnings as errors.
Deploying Documentation¶
With taskipy:
Or directly:
Available Tasks¶
PyNodeWidget uses taskipy for common development tasks:
# Testing
task test # Run all tests (Python + JavaScript)
task test-py # Run Python tests with pytest
task test-js # Run JavaScript tests with Vitest
# Documentation
task docs-serve # Start documentation server with live reload
task docs-build # Build static documentation site
# View all tasks
task --list
Tasks are defined in pyproject.toml under [tool.taskipy.tasks]:
[tool.taskipy.tasks]
docs-serve = "mkdocs serve"
docs-build = "mkdocs build"
test-py = "pytest"
test-js = "bun --cwd=js run test"
test = "task test-py && task test-js"
Project Structure¶
pynodeflow/
├── src/pynodewidget/ # Python package
│ ├── __init__.py
│ ├── widget.py # Main widget
│ ├── json_schema_node.py # Node base class
│ ├── node_builder.py # Configuration helpers
│ ├── observable_dict.py # Auto-sync dictionary
│ ├── protocols.py # Extension protocols
│ └── static/ # Built JavaScript assets
├── js/ # JavaScript/TypeScript source
│ ├── src/ # React components
│ ├── dev/ # Development app
│ ├── tests/ # JavaScript tests
│ └── package.json
├── docs/ # Documentation source
│ ├── index.md
│ ├── getting-started/
│ ├── guides/
│ ├── api/
│ └── examples/
├── tests/ # Python tests
├── examples/ # Example notebooks and scripts
├── pyproject.toml # Python package config
├── mkdocs.yml # Documentation config
└── hatch_build.py # Custom build hook
Running Tests¶
PyNodeWidget has comprehensive test suites for both Python and JavaScript. Use taskipy for convenient task running.
All Tests¶
Run both Python and JavaScript tests:
This executes test-py followed by test-js.
Python Tests¶
Run Python tests with pytest:
or use pytest directly
JavaScript Tests¶
Run JavaScript/TypeScript tests with Vitest:
Code Style¶
Python¶
We follow PEP 8 with some modifications. Format code with:
JavaScript/TypeScript¶
Format with Prettier:
Lint with ESLint:
Building the Package¶
Development Build¶
Production Build¶
# Build JavaScript first
cd js && bun run build && cd ..
# Build Python package
uv build
# Or with hatchling
python -m build
The build process:
- Runs
hatch_build.pycustom hook - Builds JavaScript assets if needed
- Copies built assets to
src/pynodewidget/static/ - Creates wheel and sdist
Tips¶
Fast Iteration¶
For rapid development:
- Keep
mkdocs serverunning for documentation - Use
bun run devfor JavaScript hot reload - Use Jupyter's
%autoreloadfor Python:
Debugging¶
Enable verbose logging:
Inspect widget state:
Clean Slate¶
Start fresh:
# Clean Python
rm -rf src/pynodewidget/__pycache__
rm -rf src/pynodewidget/static/*
# Clean JavaScript
cd js
rm -rf node_modules dist
bun install
bun run build
cd ..
# Reinstall
uv pip install -e ".[dev,docs]"
Common Issues¶
Widget Not Updating¶
If the widget doesn't reflect your changes:
- Rebuild JavaScript:
cd js && bun run build - Restart Jupyter kernel
- Check
src/pynodewidget/static/contains latest files
Import Errors¶
Ensure package is installed in editable mode:
JavaScript Build Fails¶
Check Bun is installed and up to date:
Documentation Not Building¶
Ensure all dependencies are installed:
Next Steps¶
- Running Tests: Learn about the test suite
- Building Documentation: Documentation development
- Contributing Guide: How to contribute