Skip to content

feat(session): allow stopping untracked backend assignments via --endpoint - #317

Closed
Milabo-HRH wants to merge 1 commit into
googlecolab:mainfrom
Milabo-HRH:feat/stop-by-endpoint
Closed

Milabo-HRH wants to merge 1 commit into
googlecolab:mainfrom
Milabo-HRH:feat/stop-by-endpoint

Conversation

@Milabo-HRH

Copy link
Copy Markdown
Contributor

Fixes #290 (and provides the direct orphan-termination fallback requested in #263).

Problem

When local session metadata is missing (e.g., sessions.json was removed or colab new timed out after server-side provisioning), colab sessions displays the active runtime as [?] <endpoint>, but colab stop only resolves locally tracked session names and has no way to terminate that backend assignment.

Fix

  • Add --endpoint <endpoint> to colab stop (mutually exclusive with -s/--session and --all).
  • Syncs with backend assignments:
    • If <endpoint> belongs to a locally tracked session, terminates it via _stopOne (keeping local state in sync).
    • If <endpoint> matches an untracked [?] backend assignment, attempts best-effort kernel shutdown, calls client.unassign(endpoint), and logs the termination event.
    • If <endpoint> is not found among active backend assignments, prints an actionable error and exits 1 without calling unassign.
  • colab stop --all remains scoped to locally tracked CLI sessions so untracked browser runtimes are never terminated unexpectedly.

Testing

  • Added unit tests in tests/test_cli.py covering untracked backend assignment termination, tracked session lookup by endpoint, missing endpoint error, and mutual-exclusion checks with -s / --all.
  • ruff format --check src/colab_cli/commands/session.py tests/test_cli.py -> clean.
  • pytest -q tests -> 683 passed, 27 skipped (including test_cli_help_commands_sorted_alphabetically).

@sethtroisi

Copy link
Copy Markdown
Collaborator

You can stop untracked backends with -s after #315

I do like --endpoint but

  try:
        ColabRuntime(url, token).stop(shutdown_kernel=True)
    except Exception:
        pass

isn't doing anything and this is already possible.

@sethtroisi sethtroisi closed this Dec 3, 2026
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.

colab stop cannot release a session when colab sessions shows a backend assignment but local metadata has been lost

2 participants