Secret

Secrets such as provider keys and environment variables can be set when defining compute. These are set at launch time and accessible during the scope of your program.

Factory Method

kubetorch.secret(name: str | None = None, provider: str | None = None, values: Dict | None = None, path: str | None = None, env_vars: Dict | None = None) Secret

Builds an instance of Secret. At most one of values, path, and env_vars can be provided, to maintain one source of truth. If None are provided, will infer the values from the default path or env vars for a given provider.

Parameters:
  • name (str, optional) – Name to assign the resource. If none is provided, resource name defaults to the provider name.

  • provider (str, optional) – Provider corresponding to the secret (e.g. “aws”, “gcp”). To see all supported provider types, run kt.Secret.builtin_providers(as_str=True).

  • values (Dict, optional) – Dictionary mapping of secret keys and values.

  • path (str, optional) – Path where the secret values are held.

  • env_vars (Dict, optional) – Dictionary mapping secret keys to the corresponding environment variable key.

Returns:

The resulting secret object.

Return type:

Secret

Examples:

import kubetorch as kt local_secret = kt.secret(name="in_memory_secret", values={"secret_key": "secret_val"}) aws_secret = kt.secret(provider="aws") gcp_secret = kt.secret(provider="gcp", path="~/.gcp/credentials") lamdba_secret = kt.secret(provider="lambda", values={"api_key": "xxxxx"})

Class

class kubetorch.Secret(name: str | None = None, provider: str | None = None, values: Dict | None = None, path: str | None = None, env_vars: Dict | None = None, **kwargs)
__init__(name: str | None = None, provider: str | None = None, values: Dict | None = None, path: str | None = None, env_vars: Dict | None = None, **kwargs)

Secret class. Built-in provider classes contain default path and/or environment variable mappings, based on it’s expected usage.

Note

Currently supported built-in providers: anthropic, aws, azure, gcp, github, huggingface, lambda, langchain, openai, pinecone, ssh, wandb.

property name

Name of the secret.

property values

Secret values.

classmethod builtin_providers(as_str: bool = False) List

Return list of all Kubetorch providers (as class objects) supported out of the box.

Parameters:

as_str (bool, optional) – Whether to return the providers as a string or as a class. (Default: False)