cuOpt Thin Client API Example

SAK

 1import os
 2from cuopt_thin_client import CuOptServiceClient
 3
 4# Load the credentials from the environment or some other way
 5sak = os.environ["CUOPT_CLIENT_SAK"]
 6
 7cuopt_service_client = CuOptServiceClient(
 8    sak=sak,
 9)
10
11optimized_routes = cuopt_service_client.get_optimized_routes("/path/to/cuopt/problem/data")

The problem data file should contain JSON data as shown in the request body for the Get Routes Open-API spec. The data may be written as a plain text file, and it may optionally be compressed with zlib. The data may also be written from Python using the pickle module.

SSA (Deprecated)

 1import os
 2from cuopt_thin_client import CuOptServiceClient
 3
 4# Load the credentials from the environment or some other way
 5cuopt_client_id = os.environ["CUOPT_CLIENT_ID"]
 6cuopt_client_secret = os.environ["CUOPT_CLIENT_SECRET"]
 7
 8cuopt_service_client = CuOptServiceClient(
 9    client_id=cuopt_client_id,
10    client_secret=cuopt_client_secret
11)
12
13optimized_routes = cuopt_service_client.get_optimized_routes("/path/to/cuopt/problem/data")

The problem data file should contain JSON data as shown in the request body for the Get Routes Open-API spec. The data may be written as a plain text file, and it may optionally be compressed with zlib. The data may also be written from Python using the pickle module.

cuOpt Thin Client CLI Example

Put your client id and secret in a credentials.json file as below:

SAK

{
    "CUOPT_CLIENT_SAK" : "PASTE_YOUR_SAK",
}

Invoke the CLI

cuopt_cli cuopt_problem_data.json -c credentials.json

Alternatively, you may set CUOPT_CLIENT_SAK in your environment and omit the -c argument to cuopt_cli

SSA (Deprecated)

{
    "CUOPT_CLIENT_ID" : "PASTE_YOUR_CLIENT_ID_HERE",
    "CUOPT_CLIENT_SECRET" : "PASTE_YOUR_CLIENT_SECRET_HERE"
}

Invoke the CLI

cuopt_cli cuopt_problem_data.json -c credentials.json

Alternatively, you may set CUOPT_CLIENT_ID and CUOPT_CLIENT_SECRET in your environment and omit the -c argument to cuopt_cli