C3 AI Documentation Home

Configure and Use Gurobi Keys in C3 AI Environments and Apps

This page provides guidance on how to effectively setup and utilize a Gurobi License Key on a Cluster, Environment, or Application.

Steps

Create the Gurobi License Credential

To set up a Gurobi license for GurobiPy authentication, which can be used by Gurobi#setEnvAuth, you must first configure the Gurobi credentials. Depending on your needs, this auth can be set at the CLUSTER, ENV, or APP level. To set the params for the Gurobi environment (gp.env) run the following command (python example listed below)

Python
// The definition for #configureSecret is
// Gurobi.configureSecret(params: !?map<string, any>, secretName: string)

Gurobi.configureSecret(
  {
    "GURO_PAR_ISVNAME": 'xxxxxx',
    "GURO_PAR_ISVAPPNAME": 'yyyyyyy',
    "GURO_PAR_ISVKEY": 'wwwwwww',
    "GURO_PAR_ISVEXPIRATION": zzzzzz,
  },
  'NAME_OF_SECRET' // will use {@link Gurobi.Auth.DEFAULT_NAME 'default'} name if not provided
);

This sets the scope of the license based on the following:

ConfigOverride.CLUSTER if executed form c3-c3 app.

ConfigOverride.ENV if executed form <env>-c3 app.

ConfigOverride.APP if executed form <env>-<app> app.

If Gurobi.configureSecret is called with params equal to null or None, it removes the existing secret for the current scope.

Using a Configured Gurobi Credential

Once a Gurobi license has been setup for you, you can pass this credential to your Gurobi environment (gp.env) with the Gurobi.setEnvAuth method. This inplace method will update your gp.Env object with the values configured by Gurobi#configureSecret. A python example is listed below.

Python
import gurobipy as gp
# empty=True is required for Gurobi.setEnvAuth to work properly
env = gp.Env(empty=True, params={"TimeLimit", 7}) 
c3.Gurobi.setEnvAuth(env, 'GUROBI_SECRET_NAME')

The method will fail if the secret with the provided name is not configured. If unsure about the name of your Gurobi credentials, use Gurobi.listSecretNames() to list all current configured Gurobi credentials.

Use a Configured Gurobi Credential in an Application

If Gurobi is used as part of your Application logic (ex. being used in a Workflow, Batch job, or being called by an end user), you must create a Gurobi environment in the process you wish to use Gurobi in. Once created, the credential can be set in the same manner as above. While setting up your App’s logic, please verify the following to ensure the credential works properly.

  1. The credential has been set at the appropriate level. For example, ensuring that the named credential used in the App code was not referencing a credential set for the developer’s SNE.

  2. If a user with permissions lower than c3.Developer is expected to call a process that checks for the Gurobi credential, extend the desired user’s role to allow Gurobi-type calls.

Was this page helpful?