fix: surface friendly error on 412 GPU/TPU allocation instead of a traceback - #112
Open
aadi-joshi wants to merge 1 commit into
Open
fix: surface friendly error on 412 GPU/TPU allocation instead of a traceback#112aadi-joshi wants to merge 1 commit into
aadi-joshi wants to merge 1 commit into
Conversation
…aceback client.assign() already converts a 412 from the backend into TooManyAssignmentsError, but nothing caught it. colab new --gpu and colab run --gpu let it fall through as a raw traceback instead of an actionable message. colab ssh's auto-create path hits the same bug since it calls into session.py's new(). Catch it in both commands and print a message explaining the likely cause (too many active sessions or a temporary usage/capacity limit), mirroring the existing friendly-message pattern used for 400 errors. Fixes googlecolab#73
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #73
client.assign()catches a 412 from the backend and raisesTooManyAssignmentsError(client.py lines 274-277). That exception was never caught anywhere else. Bothcolab new --gpuandcolab run --gpulet it fall through as a raw traceback.colab ssh's auto-create path calls intosession.py'snew(), so it hit the same bug.The 400 case (no quota or entitlement) already had a friendly handler in
session.pyandrun.py. I added a matching handler for 412 in both files, right next to the existing one.The message does not assume the cause is only accelerator scarcity, since
TooManyAssignmentsErrorcan also mean too many active sessions on a plain CPU request. It suggestscolab stopto free a session, retrying, or trying a different accelerator.Testing
test_client.pyconfirmingassign()converts a 412 intoTooManyAssignmentsError.test_cli.pyandtest_run.pymirroring the existing 400 tests, confirming the friendly message shows and the command exits non-zero instead of raising a traceback.uv run pytest tests/, 345 passed.uv run ruff check .on the changed files, clean.Happy to adjust the message wording if you would prefer something different.