Kaggle / kaggle-api

Official Kaggle API
Apache License 2.0
6.01k stars 1.06k forks source link

Can we add parameters/secrets while pushing the kernels ? #582

Open bleakprestiger opened 1 month ago

stevemessick commented 1 month ago

Could you give us a little more detail? An example of what you want to do would be great.

YuenSzeHong commented 1 month ago

Could you give us a little more detail? An example of what you want to do would be great.

I guess he ment user secrets (like api keys that we dont want to expose)

stevemessick commented 1 month ago

No, I do not think we want to do that. I think it would introduce security issues. @rosbo Could you confirm?

The way to manage your API key is with the kaggle_secrets package. See: https://www.kaggle.com/code/harupy/how-to-use-kaggle-api-as-a-python-library

This package is only available in Kaggle notebooks and is a secure way to set up user name and key.

rosbo commented 1 month ago

@stevemessick To clarify, kaggle_secrets is used to access secrets in a notebook (i.e. get the secret value).

from kaggle_secrets import UserSecretsClient

secret_value = UserSecretsClient().get_secret("YOUR_SECRET_NAME")

kaggle_secrets doesn't allow setting the value, it only reads the value. Currently, the value must be set from Notebook Editor > Add-ons > Secrets. Another thing to note is that secrets are set at your account level. Then, you can decide which secrets you want to attach to a specific notebook. If you update the value of a secret, the new value will be used by all notebooks using that secret.

@bleakprestiger Are you asking for an option to "attach" a given list of secrets automatically when calling kaggle kernels push?

Or are you asking for new methods in the CLI to set user secrets. Something along the lines of:

kaggle secrets set MY_API_KEY abcdefghijk123

Thank you

bleakprestiger commented 1 month ago

yes @rosbo, can we attach a given list of secrets when pushing the kernels ? Also can we pass some input variables while pushing the kernels ?