Skip to content

Commit 40eac7d

Browse files
authored
Merge pull request #23 from cmscom/001-mime-renderer
feat: Migrate from ipywidgets to MIME renderer architecture (v0.4.0)
2 parents 9e05627 + 2a1f025 commit 40eac7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+9458
-10282
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
os: [ubuntu-latest, windows-latest, macos-latest]
19-
python-version: ['3.10', '3.11', '3.12']
19+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
2020
steps:
2121
- name: Checkout
2222
uses: actions/checkout@v4
@@ -31,31 +31,12 @@ jobs:
3131
with:
3232
node-version: '18'
3333

34-
- name: Setup Yarn
35-
run: |
36-
corepack enable
37-
corepack prepare [email protected] --activate
38-
echo 'nodeLinker: node-modules' > .yarnrc.yml
39-
40-
- name: Yarn version
41-
run: |
42-
yarn --version
43-
4434
- name: Install dependencies
4535
shell: bash
4636
run: |
4737
python -m pip install --upgrade pip
4838
python -m pip install -U codecov
49-
yarn --version
50-
yarn config set nodeLinker node-modules
51-
52-
if [ "$RUNNER_OS" == "Windows" ]; then
53-
yarn install
54-
else
55-
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
56-
fi
57-
env:
58-
YARN_ENABLE_IMMUTABLE_INSTALLS: 'false'
39+
yarn install
5940
6041
- name: Install package
6142
run: |
@@ -66,6 +47,7 @@ jobs:
6647
python -m pytest -v
6748
6849
- name: Run JavaScript tests
50+
if: ${{ matrix.os == 'ubuntu-latest' }}
6951
run: |
7052
yarn run test
7153
@@ -74,6 +56,21 @@ jobs:
7456
run: |
7557
yarn run lint:check
7658
59+
- name: Run ruff check
60+
if: ${{ matrix.os == 'ubuntu-latest' }}
61+
run: |
62+
python -m ruff check net_vis
63+
64+
- name: Run ruff format check
65+
if: ${{ matrix.os == 'ubuntu-latest' }}
66+
run: |
67+
python -m ruff format --check net_vis
68+
69+
- name: Run pyright type check
70+
if: ${{ matrix.os == 'ubuntu-latest' }}
71+
run: |
72+
python -m pyright net_vis
73+
7774
# - name: Check docs can be build + links
7875
# if: ${{ matrix.os == 'ubuntu-latest' }}
7976
# working-directory: docs

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,11 @@ VSCode
159159

160160
*.code-workspace
161161
.yarnrc.yml
162+
.devcontainer/
163+
164+
.specify
165+
specs/
166+
CLAUDE.md
167+
.claude/
168+
IPYWIDGET_TO_MIME.md
169+
venv-*/

CHANGES.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# Changelog
22

3+
## 0.4.0 (2025-11-21)
4+
5+
**Major Release: Migration to MIME Renderer Architecture** (terapyon)
6+
7+
### Breaking Changes
8+
9+
- **Removed ipywidgets dependency**: NetVis no longer requires or uses ipywidgets for rendering
10+
- **Removed nbextension support**: The Jupyter Notebook classic extension has been removed
11+
- **Simplified installation**: No manual extension enabling required - works automatically in JupyterLab 3.x/4.x
12+
- **Python API unchanged**: Existing code using `NetVis(value=data)` continues to work without modification
13+
14+
### New Features
15+
16+
- MIME Renderer Architecture using custom MIME type `application/vnd.netvis+json`
17+
- Automatic rendering in JupyterLab output cells
18+
- Version validation between frontend and backend
19+
- Enhanced error handling for invalid graph data
20+
21+
### Improvements
22+
23+
- Cleaner codebase with duplicate code removed
24+
- Better performance with simplified rendering pipeline
25+
- Comprehensive test coverage (Python 75%, TypeScript 41%)
26+
- Modern JupyterLab 3.x/4.x architecture
27+
28+
### Migration
29+
30+
See [MIGRATION.md](./MIGRATION.md) for migration guide from 0.3.x to 0.4.0.
31+
32+
### Compatibility
33+
34+
- Supported: JupyterLab 3.x and 4.x
35+
- Not Supported: Jupyter Notebook Classic
36+
- Python: 3.10+
37+
- D3.js: 7.9+ (all visualization features preserved)
38+
339
## 0.3.1 (2025-07-12)
440

541
- bugfix for build version (terapyon)

MIGRATION.md

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
# Migration Guide: NetVis 0.3.x → 0.4.0
2+
3+
This guide helps you migrate from NetVis version 0.3.x to 0.4.0.
4+
5+
## Overview
6+
7+
Version 0.4.0 introduces a major architectural change from ipywidgets-based rendering to a MIME renderer extension. This simplifies installation and improves compatibility with modern JupyterLab environments.
8+
9+
## Breaking Changes
10+
11+
### 1. Removed ipywidgets Dependency
12+
13+
**What changed**: NetVis no longer uses ipywidgets for rendering graphs.
14+
15+
**Impact**:
16+
- No action required for most users - the Python API remains unchanged
17+
- Graphs now render using JupyterLab's MIME renderer system
18+
19+
**Migration**:
20+
```python
21+
# Your existing code works without changes
22+
import net_vis
23+
24+
data = '{"nodes": [{"id": "A"}], "links": []}'
25+
w = net_vis.NetVis(value=data)
26+
w # Still displays automatically in JupyterLab
27+
```
28+
29+
### 2. Removed nbextension Support
30+
31+
**What changed**: The Jupyter Notebook classic nbextension has been removed.
32+
33+
**Impact**:
34+
- NetVis 0.4.0 only works in **JupyterLab 3.x and 4.x**
35+
- Jupyter Notebook Classic is **no longer supported**
36+
37+
**Migration**:
38+
39+
If you're using Jupyter Notebook Classic:
40+
- **Option 1 (Recommended)**: Migrate to JupyterLab 3.x or 4.x
41+
- **Option 2**: Stay on NetVis 0.3.x until you can migrate to JupyterLab
42+
43+
### 3. Simplified Installation
44+
45+
**What changed**: Manual extension enabling is no longer required.
46+
47+
**Old installation (0.3.x)**:
48+
```bash
49+
pip install net_vis
50+
jupyter nbextension enable --py net_vis # No longer needed
51+
```
52+
53+
**New installation (0.4.0)**:
54+
```bash
55+
pip install net_vis
56+
# That's it! No manual enabling required
57+
```
58+
59+
**Migration**: Simply upgrade using pip:
60+
```bash
61+
pip install --upgrade net_vis
62+
```
63+
64+
## Non-Breaking Changes
65+
66+
### Python API (No Changes Required)
67+
68+
The Python API for creating graphs remains **100% compatible**:
69+
70+
```python
71+
import net_vis
72+
73+
# All existing code continues to work
74+
data = """
75+
{
76+
"nodes": [
77+
{"id": "A"},
78+
{"id": "B"}
79+
],
80+
"links": [
81+
{"source": "A", "target": "B"}
82+
]
83+
}
84+
"""
85+
86+
graph = net_vis.NetVis(value=data)
87+
graph # Displays in JupyterLab output cell
88+
```
89+
90+
### D3.js Visualization Features (Fully Preserved)
91+
92+
All D3.js visualization features from 0.3.x are preserved in 0.4.0:
93+
- ✅ Force-directed layout
94+
- ✅ Node dragging
95+
- ✅ Zoom and pan
96+
- ✅ Interactive tooltips
97+
- ✅ Custom node colors and sizes
98+
- ✅ Directed edges with arrows
99+
100+
## Step-by-Step Migration
101+
102+
### For End Users
103+
104+
1. **Check your JupyterLab version**:
105+
```bash
106+
jupyter lab --version
107+
```
108+
- If version < 3.0: Upgrade to JupyterLab 3.x or 4.x first
109+
- If version ≥ 3.0: Proceed to step 2
110+
111+
2. **Upgrade NetVis**:
112+
```bash
113+
pip install --upgrade net_vis
114+
```
115+
116+
3. **Restart JupyterLab**:
117+
```bash
118+
jupyter lab
119+
```
120+
121+
4. **Test your notebooks**:
122+
- Open an existing notebook with NetVis graphs
123+
- Re-run cells with `NetVis()` objects
124+
- Graphs should display automatically
125+
126+
### For Developers
127+
128+
1. **Update development environment**:
129+
```bash
130+
# Remove old nbextension build artifacts
131+
jupyter nbextension uninstall --py net_vis
132+
133+
# Pull latest code
134+
git checkout 001-mime-renderer
135+
136+
# Reinstall in development mode
137+
pip install -e ".[test]"
138+
jupyter labextension develop --overwrite .
139+
```
140+
141+
2. **Remove nbextension references**:
142+
- Update documentation removing nbextension commands
143+
- Update CI/CD removing nbextension build steps
144+
145+
3. **Run tests**:
146+
```bash
147+
pytest net_vis/tests/
148+
yarn test
149+
```
150+
151+
## Troubleshooting
152+
153+
### "NetVis object displays as plain text"
154+
155+
**Cause**: JupyterLab doesn't have the MIME renderer registered.
156+
157+
**Solution**:
158+
```bash
159+
# Ensure the extension is installed
160+
jupyter labextension list | grep net_vis
161+
162+
# If not listed, reinstall:
163+
pip uninstall net_vis
164+
pip install net_vis
165+
166+
# Restart JupyterLab
167+
```
168+
169+
### "Module 'ipywidgets' not found" error
170+
171+
**Cause**: Old notebooks may have cached imports.
172+
173+
**Solution**:
174+
1. Restart the notebook kernel
175+
2. Clear all outputs: `Cell > All Output > Clear`
176+
3. Re-run cells
177+
178+
### Jupyter Notebook Classic no longer supported
179+
180+
**Cause**: NetVis 0.4.0 uses MIME renderers which are JupyterLab-specific.
181+
182+
**Solution**:
183+
- Migrate to JupyterLab 3.x or 4.x (recommended)
184+
- Or continue using NetVis 0.3.x with Jupyter Notebook Classic
185+
186+
## New Features in 0.4.0
187+
188+
While migrating, take advantage of new features:
189+
190+
### Version Validation
191+
192+
NetVis now validates version compatibility between Python and TypeScript:
193+
- Automatic warnings if frontend/backend versions mismatch
194+
- Helps prevent rendering issues
195+
196+
### Improved Error Messages
197+
198+
Better error messages for common issues:
199+
- Invalid JSON in graph data
200+
- Missing required fields (`nodes`, `links`)
201+
- Duplicate node IDs
202+
- Invalid link references
203+
204+
### Enhanced Testing
205+
206+
More comprehensive test coverage ensures reliability:
207+
- Python: 75% coverage
208+
- TypeScript: 41% coverage
209+
- Integration tests for MIME rendering
210+
211+
## Getting Help
212+
213+
If you encounter issues during migration:
214+
215+
1. **Check compatibility**:
216+
- JupyterLab version ≥ 3.0
217+
- Python version ≥ 3.10
218+
219+
2. **Review error messages**:
220+
- NetVis 0.4.0 provides detailed error messages
221+
- Check browser console for frontend errors
222+
223+
3. **File an issue**:
224+
- GitHub Issues: https://github.com/cmscom/netvis/issues
225+
- Include: NetVis version, JupyterLab version, error messages
226+
227+
## Rollback (if needed)
228+
229+
If you need to temporarily roll back to 0.3.x:
230+
231+
```bash
232+
pip install net_vis==0.3.1
233+
```
234+
235+
Note: This will reinstall the ipywidgets-based version.
236+
237+
## Summary
238+
239+
**Key Points**:
240+
- ✅ Python API unchanged - existing code works
241+
- ✅ All D3.js features preserved
242+
- ⚠️ JupyterLab 3.x/4.x required
243+
- ⚠️ Jupyter Notebook Classic no longer supported
244+
- ✅ Simpler installation (no manual enabling)
245+
246+
**Benefits**:
247+
- Cleaner, more maintainable codebase
248+
- Better alignment with JupyterLab ecosystem
249+
- Improved performance and error handling
250+
- Future-proof architecture
251+
252+
For most users, migration is as simple as upgrading the package - your existing notebooks will continue to work without code changes.

0 commit comments

Comments
 (0)