From 58e0b6a51e069905ddd9451cce24a3822035e842 Mon Sep 17 00:00:00 2001 From: AngeloDanducci Date: Mon, 14 Sep 2026 09:54:46 -0400 Subject: [PATCH 1/2] fix: make sure pillow is not partially upgraded Signed-off-by: AngeloDanducci --- notebooks/atai_2026/tutorial.ipynb | 7 +++++++ notebooks/icml_2026/tutorial.ipynb | 7 +++++++ notebooks/orlando_2025/tutorial.ipynb | 9 ++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/notebooks/atai_2026/tutorial.ipynb b/notebooks/atai_2026/tutorial.ipynb index 4d4a8fa..2dfc6bd 100644 --- a/notebooks/atai_2026/tutorial.ipynb +++ b/notebooks/atai_2026/tutorial.ipynb @@ -43,6 +43,13 @@ "# install Mellea.\n", "!uv pip install \"mellea[hf,docling,sandbox,tools]\"\n", "\n", + "# Colab's preinstalled pillow can end up half-replaced (12.3.0 metadata over\n", + "# stale 11.3.0 files), so docling hits 'ImportError: cannot import name _Ink\n", + "# from PIL._typing'. Force a clean, atomic rewrite of pillow into the kernel's\n", + "# own interpreter, defeating the wheel cache. (mellea issue #1640)\n", + "import sys # noqa: E402\n", + "!{sys.executable} -m pip install --upgrade --force-reinstall --no-cache-dir --no-deps pillow\n", + "\n", "# install additional dependencies.\n", "!uv pip install matplotlib \"omegaconf>=2.3\" \"ipywidgets>=8.1.8\"\n", "\n", diff --git a/notebooks/icml_2026/tutorial.ipynb b/notebooks/icml_2026/tutorial.ipynb index 9e0744c..16df31f 100644 --- a/notebooks/icml_2026/tutorial.ipynb +++ b/notebooks/icml_2026/tutorial.ipynb @@ -47,6 +47,13 @@ "# install Mellea.\n", "!uv pip install \"mellea[hf,docling,sandbox,tools]==0.6.0\"\n", "\n", + "# Colab's preinstalled pillow can end up half-replaced (12.3.0 metadata over\n", + "# stale 11.3.0 files), so docling hits 'ImportError: cannot import name _Ink\n", + "# from PIL._typing'. Force a clean, atomic rewrite of pillow into the kernel's\n", + "# own interpreter, defeating the wheel cache. (mellea issue #1640)\n", + "import sys # noqa: E402\n", + "!{sys.executable} -m pip install --upgrade --force-reinstall --no-cache-dir --no-deps pillow\n", + "\n", "# install additional dependencies.\n", "!uv pip install matplotlib \"omegaconf>=2.3\" \"ipywidgets>=8.1.8\"\n", "\n", diff --git a/notebooks/orlando_2025/tutorial.ipynb b/notebooks/orlando_2025/tutorial.ipynb index bf96ef2..c038e8a 100644 --- a/notebooks/orlando_2025/tutorial.ipynb +++ b/notebooks/orlando_2025/tutorial.ipynb @@ -47,6 +47,13 @@ "# install Mellea.\n", "!uv pip install mellea[all] -q\n", "\n", + "# Colab's preinstalled pillow can end up half-replaced (12.3.0 metadata over\n", + "# stale 11.3.0 files), so docling hits 'ImportError: cannot import name _Ink\n", + "# from PIL._typing'. Force a clean, atomic rewrite of pillow into the kernel's\n", + "# own interpreter, defeating the wheel cache. (mellea issue #1640)\n", + "import sys # noqa: E402\n", + "!{sys.executable} -m pip install --upgrade --force-reinstall --no-cache-dir --no-deps pillow\n", + "\n", "# Run docling once to download model weights.\n", "from mellea.stdlib.components.docs.richdocument import RichDocument\n", "rd = RichDocument.from_document_file(\"https://arxiv.org/pdf/1906.04043\")\n", @@ -586,4 +593,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} From 8cb0fed8440a7e4711fd29d94e8b2ee546dcf54b Mon Sep 17 00:00:00 2001 From: AngeloDanducci Date: Mon, 14 Sep 2026 15:46:02 -0400 Subject: [PATCH 2/2] fix: restart kernel to avoid serving cached dependencies Signed-off-by: AngeloDanducci --- notebooks/atai_2026/tutorial.ipynb | 43 +++++++++++++++++++-------- notebooks/icml_2026/tutorial.ipynb | 43 +++++++++++++++++++-------- notebooks/orlando_2025/tutorial.ipynb | 41 +++++++++++++++++-------- 3 files changed, 89 insertions(+), 38 deletions(-) diff --git a/notebooks/atai_2026/tutorial.ipynb b/notebooks/atai_2026/tutorial.ipynb index 2dfc6bd..7b885e1 100644 --- a/notebooks/atai_2026/tutorial.ipynb +++ b/notebooks/atai_2026/tutorial.ipynb @@ -33,26 +33,43 @@ }, "outputs": [], "source": [ - "# Install ollama.\n", - "!curl -fsSL https://ollama.com/install.sh | sh > /dev/null\n", - "!nohup ollama serve >/dev/null 2>&1 &\n", - "\n", - "# Download the granite4:3b weights.\n", - "!ollama pull granite4:latest\n", + "# One-time setup: install Mellea, then restart the runtime. This MUST be a\n", + "# separate cell that ends by restarting, and it must run before ollama or any\n", + "# import. Installing mellea upgrades Colab's preinstalled pillow (11.x, which\n", + "# predates `_Ink`) to a newer pillow (12.x), but this kernel already imported the\n", + "# old PIL and keeps serving its cached PIL._typing (which lacks `_Ink`) even after\n", + "# pip swaps the new files onto disk -- so docling would fail with\n", + "# 'ImportError: cannot import name _Ink from PIL._typing'. The disk is already\n", + "# correct after install; only the running kernel is stale, so restarting it is the\n", + "# whole fix. After the restart, run the next cell.\n", "\n", "# install Mellea.\n", "!uv pip install \"mellea[hf,docling,sandbox,tools]\"\n", "\n", - "# Colab's preinstalled pillow can end up half-replaced (12.3.0 metadata over\n", - "# stale 11.3.0 files), so docling hits 'ImportError: cannot import name _Ink\n", - "# from PIL._typing'. Force a clean, atomic rewrite of pillow into the kernel's\n", - "# own interpreter, defeating the wheel cache. (mellea issue #1640)\n", - "import sys # noqa: E402\n", - "!{sys.executable} -m pip install --upgrade --force-reinstall --no-cache-dir --no-deps pillow\n", - "\n", "# install additional dependencies.\n", "!uv pip install matplotlib \"omegaconf>=2.3\" \"ipywidgets>=8.1.8\"\n", "\n", + "# Restart the runtime so the kernel reloads the freshly installed pillow.\n", + "import IPython # noqa: E402\n", + "IPython.Application.instance().kernel.do_shutdown(True)\n" + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "# Setup (run after the restart above). ollama, model weights, supporting files, and\n", + "# display niceties all live here rather than in the install cell, because that cell\n", + "# restarts the runtime -- which would kill the ollama server and discard the display\n", + "# hooks and logger config.\n", + "\n", + "# Install and start ollama.\n", + "!curl -fsSL https://ollama.com/install.sh | sh > /dev/null\n", + "!nohup ollama serve >/dev/null 2>&1 &\n", + "\n", + "# Download the granite4:3b weights.\n", + "!ollama pull granite4:latest\n", + "\n", "# Get supporting files.\n", "!wget https://nfulton.org/atai26.tar.gz\n", "!tar xvfz atai26.tar.gz\n", diff --git a/notebooks/icml_2026/tutorial.ipynb b/notebooks/icml_2026/tutorial.ipynb index 16df31f..2b69add 100644 --- a/notebooks/icml_2026/tutorial.ipynb +++ b/notebooks/icml_2026/tutorial.ipynb @@ -37,26 +37,43 @@ }, "outputs": [], "source": [ - "# Install ollama. Uncomment if you don't have ollama installed / running.\n", - "# !curl -fsSL https://ollama.com/install.sh | sh > /dev/null\n", - "# !nohup ollama serve >/dev/null 2>&1 &\n", - "\n", - "# Download the granite4.1:3b weights.\n", - "!ollama pull granite4.1:3b\n", + "# One-time setup: install Mellea, then restart the runtime. This MUST be a\n", + "# separate cell that ends by restarting, and it must run before ollama or any\n", + "# import. Installing mellea upgrades Colab's preinstalled pillow (11.x, which\n", + "# predates `_Ink`) to a newer pillow (12.x), but this kernel already imported the\n", + "# old PIL and keeps serving its cached PIL._typing (which lacks `_Ink`) even after\n", + "# pip swaps the new files onto disk -- so docling would fail with\n", + "# 'ImportError: cannot import name _Ink from PIL._typing'. The disk is already\n", + "# correct after install; only the running kernel is stale, so restarting it is the\n", + "# whole fix. After the restart, run the next cell.\n", "\n", "# install Mellea.\n", "!uv pip install \"mellea[hf,docling,sandbox,tools]==0.6.0\"\n", "\n", - "# Colab's preinstalled pillow can end up half-replaced (12.3.0 metadata over\n", - "# stale 11.3.0 files), so docling hits 'ImportError: cannot import name _Ink\n", - "# from PIL._typing'. Force a clean, atomic rewrite of pillow into the kernel's\n", - "# own interpreter, defeating the wheel cache. (mellea issue #1640)\n", - "import sys # noqa: E402\n", - "!{sys.executable} -m pip install --upgrade --force-reinstall --no-cache-dir --no-deps pillow\n", - "\n", "# install additional dependencies.\n", "!uv pip install matplotlib \"omegaconf>=2.3\" \"ipywidgets>=8.1.8\"\n", "\n", + "# Restart the runtime so the kernel reloads the freshly installed pillow.\n", + "import IPython # noqa: E402\n", + "IPython.Application.instance().kernel.do_shutdown(True)\n" + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "# Setup (run after the restart above). ollama, model weights, supporting files, and\n", + "# display niceties all live here rather than in the install cell, because that cell\n", + "# restarts the runtime -- which would kill the ollama server and discard the display\n", + "# hooks and logger config.\n", + "\n", + "# Install ollama. Uncomment if you don't have ollama installed / running.\n", + "# !curl -fsSL https://ollama.com/install.sh | sh > /dev/null\n", + "# !nohup ollama serve >/dev/null 2>&1 &\n", + "\n", + "# Download the granite4.1:3b weights.\n", + "!ollama pull granite4.1:3b\n", + "\n", "# Get supporting files.\n", "!curl -L https://raw.githubusercontent.com/generative-computing/mellea-tutorials/refs/heads/main/notebooks/icml_2026/construction_docs.tar.gz | tar -xzf -\n", "\n", diff --git a/notebooks/orlando_2025/tutorial.ipynb b/notebooks/orlando_2025/tutorial.ipynb index c038e8a..880205b 100644 --- a/notebooks/orlando_2025/tutorial.ipynb +++ b/notebooks/orlando_2025/tutorial.ipynb @@ -36,24 +36,41 @@ }, "outputs": [], "source": [ - "# Install ollama.\n", + "# One-time setup: install Mellea, then restart the runtime. This MUST be a\n", + "# separate cell that ends by restarting, and it must run before ollama or any\n", + "# import. Installing mellea upgrades Colab's preinstalled pillow (11.x, which\n", + "# predates `_Ink`) to a newer pillow (12.x), but this kernel already imported the\n", + "# old PIL and keeps serving its cached PIL._typing (which lacks `_Ink`) even after\n", + "# pip swaps the new files onto disk -- so docling would fail with\n", + "# 'ImportError: cannot import name _Ink from PIL._typing'. The disk is already\n", + "# correct after install; only the running kernel is stale, so restarting it is the\n", + "# whole fix. After the restart, run the next cell.\n", + "\n", + "# install Mellea.\n", + "!uv pip install mellea[all] -q\n", + "\n", + "# Restart the runtime so the kernel reloads the freshly installed pillow.\n", + "import IPython # noqa: E402\n", + "IPython.Application.instance().kernel.do_shutdown(True)\n" + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "# Setup (run after the restart above). ollama, model weights, the docling warm-up,\n", + "# and display niceties all live here rather than in the install cell, because that\n", + "# cell restarts the runtime -- which would kill the ollama server, discard the\n", + "# display hooks, and run docling against the stale (pre-restart) pillow.\n", + "\n", + "# Install and start ollama.\n", "!curl -fsSL https://ollama.com/install.sh | sh > /dev/null\n", "!nohup ollama serve >/dev/null 2>&1 &\n", - "\n", + "\n", "# Download model weights for the Granite 4 and Llama 3.2 models.\n", "!ollama pull ibm/granite4:micro\n", "!ollama pull llama3.2:3b\n", "\n", - "# install Mellea.\n", - "!uv pip install mellea[all] -q\n", - "\n", - "# Colab's preinstalled pillow can end up half-replaced (12.3.0 metadata over\n", - "# stale 11.3.0 files), so docling hits 'ImportError: cannot import name _Ink\n", - "# from PIL._typing'. Force a clean, atomic rewrite of pillow into the kernel's\n", - "# own interpreter, defeating the wheel cache. (mellea issue #1640)\n", - "import sys # noqa: E402\n", - "!{sys.executable} -m pip install --upgrade --force-reinstall --no-cache-dir --no-deps pillow\n", - "\n", "# Run docling once to download model weights.\n", "from mellea.stdlib.components.docs.richdocument import RichDocument\n", "rd = RichDocument.from_document_file(\"https://arxiv.org/pdf/1906.04043\")\n",