Skip to content

docs(notebooks): add google colab badge and install cell to model construction notebook#406

Merged
conorheins merged 5 commits into
mainfrom
docs/add-colab-badge-to-example-notebooks
May 26, 2026
Merged

docs(notebooks): add google colab badge and install cell to model construction notebook#406
conorheins merged 5 commits into
mainfrom
docs/add-colab-badge-to-example-notebooks

Conversation

@Arun-Niranjan

@Arun-Niranjan Arun-Niranjan commented May 25, 2026

Copy link
Copy Markdown
Collaborator

It would be good to be able to run our notebooks in google colab (makes talks and live demos much easier).

This change modifies the model_construction_tutorial notebook so that this works.

I'll do the others in a follow-up PR, just wanted this one to be small to make the changes obvious

@Arun-Niranjan Arun-Niranjan changed the title Add google colab badge and install cell to model construction notebook docs (notebooks): Add google colab badge and install cell to model construction notebook May 25, 2026
@Arun-Niranjan Arun-Niranjan changed the title docs (notebooks): Add google colab badge and install cell to model construction notebook docs(notebooks): Add google colab badge and install cell to model construction notebook May 25, 2026
@Arun-Niranjan Arun-Niranjan changed the title docs(notebooks): Add google colab badge and install cell to model construction notebook docs(notebooks): add google colab badge and install cell to model construction notebook May 25, 2026
@Arun-Niranjan Arun-Niranjan added the documentation Improvements or additions to documentation label May 25, 2026
@Arun-Niranjan Arun-Niranjan marked this pull request as ready for review May 25, 2026 14:01
Comment on lines +43 to +45
"import sys\n",
"if \"google.colab\" in sys.modules:\n",
" %pip install \"inferactively-pymdp\" -q"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

logic:

  • we only run this install if we are in a colab space
  • we can install the vanilla dependencies, as colab ships with JAX and CUDA support already there. (in fact if you try %pip install "inferactively-pymdp[gpu]" -q you get an error)

@Arun-Niranjan

Copy link
Copy Markdown
Collaborator Author

@conorheins I can't remember what we decided on notebook outputs? it does make the diffs much more painful to evaluate, but I think for tutorial notebooks especially they're worth keeping so that people can see what the expected results are without necessarily having to run it.

@conorheins

conorheins commented May 26, 2026

Copy link
Copy Markdown
Collaborator

This is a nice idea and agree will make quick experimentation for users and demo-ing during presentations much more frictionless.

@conorheins I can't remember what we decided on notebook outputs? it does make the diffs much more painful to evaluate, but I think for tutorial notebooks especially they're worth keeping so that people can see what the expected results are without necessarily having to run it.

good question -- yeah the policy was to keep saved outputs. the relevant prior work are PRs #367 and #375. Short version of the policy:

  • every non-legacy notebook under examples/ lives in either test_notebooks/ci_notebooks.txt(PR-CI tier) or tests/notebooks/nightly_notebooks.txt (heavier nightly tier).
  • both tiers keep saved outputs -- exactly for the reason you said
  • to keep diffs tractable, a local precommit hook (scripts/notebook_precommit.py) does two things on commit: strips top-level kernelspec / language_info metadata, and standardizes execution counts (output-bearing cells get 1, 2, ..., N and empty-output cells get null). That way local kernel history doesn't get committed

So keeping outputs in the model_construction_tutorial as you did here is the right call. The one thing missing is running the hooks -- I pulled the branch down and the current state still has kernelspec / language_info populated and execution counts in the 33–48 range from your local kernel. If you run:

uv sync --group dev
uv run --group dev pre-commit install
uv run --group dev pre-commit run --all-files

it'll fix the metadata + renumber the execution counts, and the diff will get a lot easier to review. Worth installing before you push #407 too since it touches all 20 notebooks. Docs for all of this are in test/notebooks/README.md and the "Recommended local hooks" section of CONTRIBUTING.md.

FYI the hooks aren't wired into a CI job ( only the ruff linting runs there) so this won't block the merge, but it's the documented convention.

@Arun-Niranjan

Copy link
Copy Markdown
Collaborator Author

ok that's done for this one, once this is merged I'll update the PR stacked on top.

@conorheins conorheins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

One heads-up for #407: most of the other 19 notebooks haven't been touched since the notebook standardization rule landed in #375, so when you run the hooks on that stacked PR you'll see each notebook diff come out bigger than just "add 2 cells"; there'll be incidental kernelspec/language_info stripping and exec-count renumbering baked in alongside the badge + install cell. That's expected and fine, just don't be surprised by the diff sizes

@conorheins conorheins merged commit be658c2 into main May 26, 2026
5 checks passed
@Arun-Niranjan Arun-Niranjan deleted the docs/add-colab-badge-to-example-notebooks branch May 26, 2026 10:54
conorheins pushed a commit that referenced this pull request May 26, 2026
…407)

Follow on from #406

Diff is a bit larger than expected because of
#406 (review)
conorheins added a commit that referenced this pull request Jun 15, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.0.3](v1.0.2...v1.0.3)
(2026-06-08)


### Documentation

* **notebooks:** add colab badge and install cell to other notebooks
([#407](#407))
([c9f8ef9](c9f8ef9))
* **notebooks:** add google colab badge and install cell to model
construction notebook
([#406](#406))
([be658c2](be658c2))
* remove legacy docs folder
([#409](#409))
([57b09cf](57b09cf))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants