|
| 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