Skip to content

fix: support both ColabKernelClient and KernelClient in runtime - #95

Merged
sethtroisi merged 1 commit into
googlecolab:mainfrom
Mhdaw:fix-colab-kernel-client-compatibility
Jul 30, 2026
Merged

fix: support both ColabKernelClient and KernelClient in runtime#95
sethtroisi merged 1 commit into
googlecolab:mainfrom
Mhdaw:fix-colab-kernel-client-compatibility

Conversation

@Mhdaw

@Mhdaw Mhdaw commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes an AttributeError when running colab run / colab exec caused by attribute differences between PyPI releases of jupyter-kernel-client (KernelClient) and the git repository fork (ColabKernelClient).

Root Cause

  • PyPI release of jupyter-kernel-client exports KernelClient.
  • Git repository fork of jupyter-kernel-client exports ColabKernelClient.
  • When installed as a package via pip install google-colab-cli or uv tool install google-colab-cli, jupyter-kernel-client from PyPI is resolved, causing AttributeError: module 'jupyter_kernel_client' has no attribute 'KernelClient'.

Fix

Added dynamic attribute inspection in ColabRuntime.kernel_client to instantiate ColabKernelClient when present and fall back to KernelClient. Updated test_runtime.py unit tests accordingly.

Testing

  • Executed full test suite (uv run pytest): 322/322 passed.
  • Verified live script execution via colab run on Google Colab VM.

@google-cla

google-cla Bot commented Jul 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Mhdaw

Mhdaw commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Context & Background

While setting up automated Google Colab workflows using Google Antigravity paired with Gemini 3.6 flash high, we encountered a runtime AttributeError when executing colab run headlessly:

AttributeError: module 'jupyter_kernel_client' has no attribute 'KernelClient'

Upon investigating the dependency resolution, Gemini identified the root cause: a structural difference between the official PyPI release (jupyter-kernel-client==1.0.0, which exports KernelClient) and the development git source (googlecolab/jupyter-kernel-client, which exports ColabKernelClient).

This PR adds dynamic attribute inspection in ColabRuntime to support both package sources seamlessly, guaranteeing compatibility for both standard pip/uv PyPI installations and source builds.

Verified against live Google Colab runtimes and passed the complete 322-test unit suite (uv run pytest).

@sethtroisi
sethtroisi merged commit 604aac1 into googlecolab:main Jul 30, 2026
7 checks passed
@sethtroisi

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

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