Build Your Own Self-Hosted Thin Client#
Overview#
The thin client and CLI provide ease of access to the cuOpt service, but these are just references on how to communicate with the cuOpt service. Underlying details of the API have been discussed below if you want to create your own thin client.
Note
Please don’t use cuopt_self_host_client.py
or cuopt_sh_client.py
as your thin client name, just to avoid confusion in case if you had installed cuopt thin client from pypi.
Invoking cuOpt Service#
Sending cuOpt Request when Payload is a File#
The requestBody
contains a JSON object which will be processed by cuOpt.
Example with JSON data as a direct string:
1curl --location 'http://ip:port/cuopt/requests' \
2--header 'Content-Type: application/json' \
3-d 'JSON_DATA'
Example with JSON data as a file:
1curl --location 'http://ip:port/cuopt/requests' \
2--header 'Content-Type: application/json' \
3--header 'CUOPT-DATA-FILE: data_file_path' \
4-d '{}'
JSON_DATA
should follow the Open-API spec described for cuOpt input.
cuOpt Result Retrieval#
The cuOpt service employs an asynchronous interface for invocation and result retrieval. When you make an invocation request, the system will submit your problem to the solver and return a request id.
1{
2 "reqId": "ef4c1967-d543-467c-af7e-8c7899d75be8",
3}
Polling for a response:
You must poll the request id for a response. The response may contain a solution, or it may contain an error,
1curl --location 'http://ip:port/cuopt/requests/{request-id}'
HTTP Status 200 completed result
HTTP Status 202 polling response
HTTP Status 4xx for any server level failures
For best performance, it is expected that clients will not close connections until it is determined that no further communication with a server is necessary.