Skip to content

fix: support PyPI jupyter-kernel-client>=1.0 (JupyterKernelClient rename) - #125

Open
theaathish wants to merge 2 commits into
googlecolab:mainfrom
theaathish:fix-jupyter-kernel-client-1x-compat
Open

fix: support PyPI jupyter-kernel-client>=1.0 (JupyterKernelClient rename)#125
theaathish wants to merge 2 commits into
googlecolab:mainfrom
theaathish:fix-jupyter-kernel-client-1x-compat

Conversation

@theaathish

Copy link
Copy Markdown

Problem

Installing from PyPI (uv tool install google-colab-cli / pip install google-colab-cli) resolves the unpinned jupyter-kernel-client dependency to 1.0.2, where KernelClient was renamed to JupyterKernelClient.

colab exec then fails on any session (auth + colab status/colab ls still work):

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

Full traceback originates at src/colab_cli/runtime.py in ColabRuntime.kernel_client (jupyter_kernel_client.KernelClient(...)).

Repro (CLI 0.6.0 + PyPI jupyter-kernel-client 1.0.2):

colab status   # OK - shows session, IDLE
colab ls       # OK
echo "print('hi')" | colab exec   # AttributeError above

Fix

Resolve the client class across all known variants in ColabRuntime.kernel_client:

  • ColabKernelClient(proxy_token=...) (git fork version)
  • KernelClient(token=...) (PyPI <1.0)
  • JupyterKernelClient(token=...) (PyPI >=1.0, fallback)

The JupyterKernelClient constructor is compatible (passes through to KernelHttpManager via **kwargs: server_url, token, kernel_id, client_kwargs, headers), verified live with colab exec after patching.

Tests

  • Updated test_colab_runtime_kernel_client to handle all three variants.
  • Added test_colab_runtime_kernel_client_jupyterclient_fallback simulating PyPI>=1.0 (only JupyterKernelClient present).
  • uv run pytest tests/test_runtime.py -v: 9 passed.
  • uv run ruff check + ruff format --check: clean.
  • Live: echo "print('connection_test_ok')" | colab execconnection_test_ok.

…ame)

PyPI jupyter-kernel-client 1.x renamed KernelClient -> JupyterKernelClient.
uv/pip installs of google-colab-cli resolve the unpinned dependency to
1.0.2, so colab exec fails with:

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

Resolve the client class as ColabKernelClient -> KernelClient ->
JupyterKernelClient, keeping proxy_token vs token params correct.
@google-cla

google-cla Bot commented Sep 6, 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.

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.

1 participant