feat: Add --env KEY=VALUE flag to colab run and colab exec to inject environment variables#65
Open
mvanhorn wants to merge 1 commit into
Open
feat: Add --env KEY=VALUE flag to colab run and colab exec to inject environment variables#65mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
…environment variables
Contributor
|
Clever, I think this is probably fine. I worry a little about notebook drift - notebooks using the userdata api can't also use env vars and vice versa. But, if this scratches that itch for cli users then it seems reasonable to me. |
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.
Summary
google.colab.userdata.get() throws TimeoutException in CLI mode, so users have no clean way to pass secrets (HF_TOKEN, WANDB_API_KEY, etc.) to scripts run via colab run/colab exec. The reporter lists three options; maintainer teeler (CONTRIBUTOR, commented 2026-06-15) acknowledged it as a known issue and tagged the full userdata-API fix for later work because secrets are a separate backend API.
Changes
Add a repeatable
--env KEY=VALUEtyper.Option (List[str]) to run_command in run.py and to exec_command in execution.py. Parse each entry into a dict (splitting on the first '='), validate the key, and prepend an os.environ-setup prelude to the executed code.Fixes #48