configure()
Configure client library with Banyan credentials.
configure(user_id=None, api_key=None, ec2_key_pair_name=None)
Description
This function configures banyan-python to use your Banyan credentials.
It looks for configuration information in three places in the following order of precedence.
- Function arguments (e.g.,
configure(...)
) - Environment variables. (e.g.,
BANYAN_USER_ID
andBANYAN_API_KEY
) - Configuration (config) file located at
$HOME/.banyan/banyanconfig.toml
Regardless of how the configuration is specified, after this function is
called, a configuration (config) file is created at the location
$HOME/.banyan/banyanconfig.toml
where $HOME
is the home directory of
the machine where the banyan-python client library is being run. The
configuration file should be in the following format:
[aws]
ec2_key_pair_name = "MySSHKeyPair"
region = "us-west-2"
[banyan]
api_key = "1234567890abcdefghijklmnopqrstuv"
user_id = "98876543210zyxwvutsrqponmlkjihgf"
After calling this function once, your credentials will be saved in the
configuration file and the saved credentials will be used from then onwards. To
update the saved credentials, simply call the configure
function again.
Optional Parameters
All these parameters are optional because if no parameters are specified,
either environment variables or the configuration file at
$HOME/.banyan/banyanconfig.toml
will be used (as specified above).
user_id
Banyan User Id for user. Can be found on the "Account" page of the Banyan dashboard.
api_key
(str
)
Banyan API Key for user. Can be found on the "Account" page of the Banyan dashboard.
ec2_key_pair_name
(str
)
Name of the AWS EC2 Key Pair that should be used when creating a cluster. The key pair file can be used to SSH into the cluster, once it is created.
Validate that an ec2_key_pair_name has been provided
in the configuration. This is useful when, for example, configuring the client
before creating a cluster, since an ec2_key_pair_name is required for cluster
creation. Defaults to False
Returns (dict
)
Banyan config dictionary, containing the latest configuration.
{
"banyan": {
"user_id": "98876543210zyxwvutsrqponmlkjihgf",
"api_key": "1234567890abcdefghijklmnopqrstuv"
},
"aws": {
"ec2_key_pair_name": "MySSHKeyPair",
"region": "us-west-2"
}
}
Example Usage
# To authenticate using environment variables and banyanconfig.toml
configure()
# To authenticate using given User ID and API Key
configure("user_id"="98876543210zyxwvutsrqponmlkjihgf", "api_key"="1234567890abcdefghijklmnopqrstuv")