You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(kernels): clear stale image pins for TPU pushes - #1219
TPU push
enable_tpu = true
clear docker_image from kernel metadata
clear dockerImageVersionId from notebook metadata
preserve the remaining notebook metadata
Resolves the stale CPU/GPU image pin reported in #1197.
Evidence
Before:kernels_push forwarded docker_image and notebook metadata.kaggle.dockerImageVersionId even for TPU requests, matching the issue reproducer and maintainer-confirmed root cause.
After: the isolated unit test confirms the request omits both stale image selectors and keeps other notebook metadata; the source notebook remains unchanged.
python tests/unit/test_kernels_push.py: 18 tests passed in an isolated, credential-free environment.
Merge Danger
Door: two-way
Blast Radius: TPU pushes
Only TPU requests drop the CPU/GPU image pins; non-TPU request handling is unchanged.
Thanks again for working on this, @sean0407! After taking a closer look, here are a few items to address before merging:
Formatting (black)
The Cloud Build lint step failed on black --check in src/kaggle/api/kaggle_api_extended.py. Since pyproject.toml sets line-length = 120, black formats the request.docker_image assignment on a single line:
TPU requested via --accelerator (acc) or machine_shape without "enable_tpu": true
Currently this only checks enable_tpu = self.get_bool(meta_data, "enable_tpu", False). However, users can also request a TPU via kaggle kernels push --accelerator TpuV5E8 (acc="TpuV5E8") or by setting "machine_shape": "TpuV5E8" in kernel-metadata.json (which is what docs/kernels_metadata.md documents), and acc overrides the boolean GPU/TPU settings in kernel-metadata.json.
Resolving machine_shape = acc if acc else self.get_or_default(meta_data, "machine_shape", None) up front and treating TPU machine_shape values (e.g., TpuV5E8, Tpu1VmV38, TpuV38) as TPU pushes—unless acc explicitly overrides to a non-TPU shape—will cover --accelerator TpuV5E8 and machine_shape-only configs as well.
Guard against "metadata": null in notebook JSON json_body.get("metadata", {}).get("kaggle", {}) will raise AttributeError if "metadata": null is present in the .ipynb file. Checking isinstance on metadata first avoids that:
CHANGELOG.md conflict and formatting
Please rebase or merge main to resolve the conflict in CHANGELOG.md (from the 2.2.5 release), and remove the extra blank lines around the bullet and the trailing period to match the rest of the file.
Thanks for the detailed review. I updated kernels_push() to derive TPU status from the effective accelerator or machine_shape; an explicit --accelerator now overrides the metadata booleans. I also guarded notebook metadata: null, applied Black formatting, merged current main, and kept the changelog entry with the surrounding release entries.
Verification in an isolated Python 3.13 container: pytest -q tests/unit passed (1,424 tests, 38 subtests); Black check passed for both changed Python files; mypy passed for src/kaggle and tests (78 files).
The PR is updated at head 8179bdc6b45707887fdad632f7e3c42c7db603ec. Could you review this follow-up when convenient?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the stale CPU/GPU image pin reported in #1197.
Evidence
kernels_pushforwardeddocker_imageand notebookmetadata.kaggle.dockerImageVersionIdeven for TPU requests, matching the issue reproducer and maintainer-confirmed root cause.python tests/unit/test_kernels_push.py: 18 tests passed in an isolated, credential-free environment.Merge Danger
Door: two-way
Blast Radius: TPU pushes
Only TPU requests drop the CPU/GPU image pins; non-TPU request handling is unchanged.