Repository navigation
Replies: 5 comments
|
yea we have |
|
@Formatted I implemented this in my fork https://github.com/danbarua/mighty-colab
You can use both |
|
Adding a mechanism detail for whoever picks this up, since it makes the change smaller than it looks. The credentials needed to adopt an assignment are already being fetched. class ListedAssignment(BaseModel):
accelerator: Accelerator
endpoint: str
variant: AssignmentVariant
machine_shape: Shape
runtime_proxy_info: RuntimeProxyInfo # token + url
Two consequences worth designing around:
I built this before finding this thread (sorry for the duplicate issue, now closed) and hit a few edges that may be worth pre-empting:
Implementation with tests: https://github.com/Le-Anh-Duy/google-colab-cli/tree/feat/attach |
|
It is also not very clear when a colab session is started through the CLI and compute is allocated that way, if it still is using the free plan, or if I would end up being billed. The whole process is a bit unclear from the CLI so it would be good to be able to attach to a session from the browser created with free services and then continue it in the CLI. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
I’d like to propose adding a CLI command that lets users adopt an already-active Colab backend session into local
google-colab-clistate.Proposed command:
After adoption, the existing backend session could be used with the normal CLI workflow:
colab status -s browser-session colab exec -s browser-session -f train.py colab console -s browser-session colab url -s browser-session --openProblem
Right now,
colab sessionscan show active backend assignments, including sessions that were not originally created by the CLI on the current machine/config.However, if a backend session is not present in local
sessions.json, there does not appear to be a supported way to assign it a local session name and continue using it through the CLI.That means a user can have an active Colab runtime, see it from the CLI, but not cleanly run:
colab exec -s my-existing-session -f script.pyunless the CLI created that session originally.
Why this matters
The new Colab CLI is especially useful for terminal-based, scripted, and agentic workflows.
In real workflows, though, users and agents do not always start from a clean
colab new.Common cases:
Being able to adopt an existing backend session would make this handoff much smoother.
Proposed behavior
Adopt by endpoint
This would write a local
SessionStateentry for the selected backend assignment.Adopt automatically when only one untracked backend exists
If exactly one untracked backend assignment exists, the CLI can adopt it without requiring
--endpoint.Require endpoint when multiple untracked backends exist
If multiple untracked backend sessions exist, the command should fail with guidance:
Conflict handling
If the endpoint is already tracked under another local session name, the command should fail unless
--forceis provided.If the same name already points to the same endpoint, the command should be idempotent and exit successfully without side effects.
Keep-alive
By default, adoption should start the same keep-alive behavior used by CLI-created sessions.
Users should also be able to skip that:
Prototype
I implemented this in a fork to validate the behavior:
https://github.com/Formatted/google-colab-cli/tree/adopt-existing-session
The prototype includes:
colab adopt -s NAME--endpoint--force--no-keep-aliveStateStoretest provingstatusworks after adoptionLocal test suite result:
I know this repo is not currently accepting external PRs, so I’m posting this here as a feature request / design discussion rather than opening a PR.
Open questions
Would maintainers expect this command to be named
adopt,attach, or something else?Should adoption start keep-alive by default, or should it only persist local state?
Should
colab sessionsinclude a hint when it displays an untracked session, such as:Request
Would this be useful as a supported CLI workflow?
I’d love feedback from maintainers and Colab CLI users on whether adopting existing backend sessions should be first-class behavior.
All reactions