Skip to content

Limit version of IPython to < 9.17.0 to avoid import error during notebook validation - #1118

Merged
mhucka merged 1 commit into
tensorflow:masterfrom
mhucka:install-graphviz-pydot
Oct 13, 2026
Merged

mhucka merged 1 commit into
tensorflow:masterfrom
mhucka:install-graphviz-pydot

Conversation

@mhucka

@mhucka mhucka commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Some of the notebooks use Kera's plot_model function. That function has a check for whether graphviz is installed. If it is not installed, plot_model then tests whether "IPython.core.magics.namespace" is present in sys.modules and does one of two things: if it's present, plot_model prints a message; if it is not present, it raises an ImportError. Unfortunately, starting in IPython 9.17.0, IPython no longer eagerly imports IPython.core.magics.* modules at startup. Unless Graphviz is installed separately in the run-time environment, calling plot_model will raise an ImportError.

Our notebook checks are done using our script ci_validate_tutorials.sh, and that script pip-installs IPython, but it only sets a lower bound on the version number. As a result, when the script executes in CI, it installs a version of IPython >= 9.17.0, which leads plot_model to fail the test for "IPython.core.magics.namespace", which leads it to raise ImportError in CI.

The simplest solution is to add an upper bound on the version number in ci_validate_tutorials.sh, which is what this PR does. This will solve the CI failures and also help any users who may encounter the same problem when testing notebooks locally.

Kera's `plot_model` function has a check for whether graphviz is
installed. If it is not installed, `plot_model` does one of two things
depending on whether "IPython.core.magics.namespace" is present in
`sys.modules`: if it is present, `plot_model` prints a message; if it is
not present, it raises an `ImportError`.

Unfortunately, starting in IPython 9.17.0:(upstream commit 7f0ee55684f0,
"Declare IPython's built-in magics lazily"), IPython no longer eagerly
imports `IPython.core.magics.*` modules (including
"IPython.core.magics.namespace") at kernel startup. The script
`ci_validate_tutorials.sh` does pip-installs ipython, but it set a lower
version limit, not an upper version limit. So now when the script runs,
it installs IPython >= 9.17.0 and we get `ImportError` during notebook
validation.

The simplest solution is to set the upper bound on the version, which is
what this PR does.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the ipython dependency constraint in scripts/ci_validate_tutorials.sh to avoid breaking versions. The reviewer pointed out a typo in the version constraint (<9.17.0 instead of <8.17.0), which would allow the installation of the breaking 8.17.0 version, and suggested correcting it to <8.17.0.

Comment thread scripts/ci_validate_tutorials.sh
@mhucka
mhucka added this pull request to the merge queue Oct 13, 2026
Merged via the queue into tensorflow:master with commit 2df92a8 Oct 13, 2026
10 checks passed
@mhucka
mhucka deleted the install-graphviz-pydot branch October 13, 2026 17:03
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