Skip to content

Conversation

@terapyon
Copy link
Member

@terapyon terapyon commented Nov 17, 2025

PR Description

Overview

This PR implements a major migration from ipywidgets-based rendering to MIME renderer architecture (v0.4.0). This
change simplifies installation, improves compatibility with modern JupyterLab environments, and provides a
cleaner codebase.

Key Changes

Architecture Overhaul

  • Complete removal of ipywidgets dependency: Migrated to MIME renderer using custom MIME type
    application/vnd.netvis+json
  • Removed nbextension support: Optimized exclusively for JupyterLab 3.x/4.x (Jupyter Notebook Classic is no
    longer supported)
  • Simplified installation: Manual extension enabling is no longer required

Implementation Improvements

Frontend (TypeScript)

  • Added: src/mimePlugin.ts - Entry point for JupyterLab MIME extension
  • Added: src/renderer.ts - MIME data rendering logic
  • Refactored: src/graph.ts - D3.js visualization core logic (duplicate code removed)
  • Removed: src/widget.ts, src/plugin.ts, src/extension.ts - ipywidgets-related code

Backend (Python)

  • Updated: net_vis/netvis.py - MIME output support via _repr_mimebundle_()
  • Removed: _jupyter_nbextension_paths() from net_vis/__init__.py
  • Removed: net_vis/tests/test_nbextension_path.py - obsolete nbextension test

Enhanced Test Coverage

  • TypeScript Tests: 41 tests implemented (Jest)
    • src/__tests__/mimePlugin.test.ts - MIME plugin unit tests (18 tests)
    • src/__tests__/renderer.test.ts - Renderer component tests (20 tests)
    • src/__tests__/graph.test.ts - Graph visualization logic tests (3 tests)
  • Python Tests: All 16 tests passing (pytest)
    • MIME bundle structure validation
    • Version information embedding verification
    • Error handling validation

CI/CD Optimization

  • GitHub Actions build.yml improvements:
    • Removed Yarn 4.6.0 pinning (now uses Yarn 1.22.x)
    • JavaScript tests and linting run only on Ubuntu (Windows/macOS run build verification only)
    • Reduced build time and cost
  • Jest configuration improvements: Excluded /venv/ to suppress Haste warnings

Version Management and Frontend-Backend Communication

  • Added version validation between frontend and backend
  • Displays warnings when version mismatch is detected

Breaking Changes

❌ Removed Features

  • ipywidgets support
  • Jupyter Notebook Classic nbextension support
  • _jupyter_nbextension_paths() function

✅ Maintained Compatibility

  • Python API is 100% compatible: Existing code using NetVis(value=data) works without modification
  • All D3.js visualization features preserved:
    • Force-directed layout
    • Node dragging, zoom, pan
    • Interactive tooltips
    • Custom node colors and sizes
    • Directed edges with arrows

System Requirements

  • Supported: JupyterLab 3.x, 4.x
  • Not Supported: Jupyter Notebook Classic
  • Python: 3.10, 3.11, 3.12
  • OS: Ubuntu, Windows, macOS
  • D3.js: 7.9+

Documentation

  • MIGRATION.md: Migration guide from 0.3.x to 0.4.0
  • CHANGES.md: Detailed changelog
  • README.md: Updated installation instructions

Test Results

✅ Python Tests

============================== 16 passed in 0.02s ==============================

✅ TypeScript Tests

Test Suites: 3 passed, 3 total
Tests: 41 passed, 41 total

✅ Lint

✨ Done in 2.35s

✅ Build

TypeScript compilation: Success

Related Issues

Closes #[issue_number] (if applicable)

Review Points

  1. Validity of architecture change (ipywidgets → MIME renderer)
  2. Backward compatibility (no changes to Python API)
  3. Test coverage (41 TypeScript tests, 16 Python tests)
  4. CI/CD optimization (Yarn version, OS-specific test strategy)
  5. Documentation completeness (MIGRATION.md, CHANGES.md)

File Statistics

  • 45 files changed: +9,603 additions, -9,744 deletions
  • Major additions: MIME renderer architecture, comprehensive test suite, migration documentation
  • Major deletions: ipywidgets code, nbextension support, obsolete tests

@terapyon terapyon changed the title mime renderer feat: Migrate from ipywidgets to MIME renderer architecture (v0.4.0) Nov 18, 2025
@terapyon terapyon marked this pull request as ready for review November 18, 2025 08:30
@terapyon terapyon merged commit 40eac7d into main Nov 21, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants