diff --git a/notebooks/atai_2026/tutorial.ipynb b/notebooks/atai_2026/tutorial.ipynb index 4d4a8fa..7b885e1 100644 --- a/notebooks/atai_2026/tutorial.ipynb +++ b/notebooks/atai_2026/tutorial.ipynb @@ -33,12 +33,15 @@ }, "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", @@ -46,6 +49,27 @@ "# 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 9e0744c..2b69add 100644 --- a/notebooks/icml_2026/tutorial.ipynb +++ b/notebooks/icml_2026/tutorial.ipynb @@ -37,12 +37,15 @@ }, "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", @@ -50,6 +53,27 @@ "# 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 bf96ef2..880205b 100644 --- a/notebooks/orlando_2025/tutorial.ipynb +++ b/notebooks/orlando_2025/tutorial.ipynb @@ -36,17 +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", "# 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 +610,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +}