-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add Kaggle Secrets documentation #1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -394,3 +394,24 @@ kaggle kernels topics show owner/kernel-slug/12345 | |
| **Purpose:** | ||
|
|
||
| This command displays a full discussion topic along with all of its comments rendered in an indented tree structure. | ||
|
|
||
| ## Using Secrets in Kernels | ||
|
|
||
| If your kernel needs to access sensitive information (like API keys or passwords) without exposing them in your code, you should use **Kaggle Secrets**. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you should highlight that secrets can't be defined via the CLI and you must define them in the notebook editor. But I think what we really want is to have CLI support. Is there a way to attach / detach a secret from the notebook using the CLI? Should we add one? (e.g. Should the kernels-metadata.json have a list of secrets to attach) Should we add a way to set / delete secrets from the CLI? e.g. The flow would be you create a secret with |
||
|
|
||
| ### 1. Add Secrets on Kaggle.com | ||
| 1. Open your notebook in the Kaggle Notebook Editor. | ||
| 2. In the menu, select **Add-ons** -> **Secrets**. | ||
| 3. Add your secrets as key-value pairs (e.g., Label: `MY_API_KEY`, Value: `your-actual-key-value`). | ||
|
|
||
| ### 2. Access Secrets in your Code | ||
| Use the `UserSecretsClient` from the `kaggle_secrets` package to retrieve your secrets at runtime: | ||
|
|
||
| ```python | ||
| from kaggle_secrets import UserSecretsClient | ||
|
|
||
| # Retrieve the secret value using the label you defined | ||
| secret_value = UserSecretsClient().get_secret("MY_API_KEY") | ||
| ``` | ||
|
|
||
| **Note:** The `kaggle_secrets` package is pre-installed and only functional within the Kaggle notebook execution environment. It will not work when running scripts locally. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? We don't highlight the other sections.