Endpoint Predictions¶
Once endpoints have been created, users can send tasks to them to make predictions. The following code snippet shows how to send tasks to endpoints.
EndpointRequest ¶
EndpointRequest(url: Optional[str] = None, args: Optional[Dict] = None, callback_url: Optional[str] = None, callback_auth_kind: Optional[Literal['basic', 'mtls']] = None, callback_auth_username: Optional[str] = None, callback_auth_password: Optional[str] = None, callback_auth_cert: Optional[str] = None, callback_auth_key: Optional[str] = None, return_pickled: Optional[bool] = False, request_id: Optional[str] = None)
Represents a single request to either a SyncEndpoint, StreamingEndpoint, or AsyncEndpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url |
Optional[str]
|
A url to some file that can be read in to a ModelBundle's predict function. Can be an image, raw text, etc.
Note: the contents of the file located at Exactly one of |
None
|
args |
Optional[Dict]
|
A Dictionary with arguments to a ModelBundle's predict function. If the predict function has signature
Exactly one of |
None
|
return_pickled |
Optional[bool]
|
Whether the output should be a pickled python object, or directly returned serialized json. |
False
|
callback_url |
Optional[str]
|
The callback url to use for this task. If None, then the default_callback_url of the endpoint is used. The endpoint must specify "callback" as a post-inference hook for the callback to be triggered. |
None
|
callback_auth_kind |
Optional[Literal['basic', 'mtls']]
|
The default callback auth kind to use for async endpoints. Either "basic" or "mtls". This can be overridden in the task parameters for each individual task. |
None
|
callback_auth_username |
Optional[str]
|
The default callback auth username to use. This only applies if callback_auth_kind is "basic". This can be overridden in the task parameters for each individual task. |
None
|
callback_auth_password |
Optional[str]
|
The default callback auth password to use. This only applies if callback_auth_kind is "basic". This can be overridden in the task parameters for each individual task. |
None
|
callback_auth_cert |
Optional[str]
|
The default callback auth cert to use. This only applies if callback_auth_kind is "mtls". This can be overridden in the task parameters for each individual task. |
None
|
callback_auth_key |
Optional[str]
|
The default callback auth key to use. This only applies if callback_auth_kind is "mtls". This can be overridden in the task parameters for each individual task. |
None
|
request_id |
Optional[str]
|
(deprecated) A user-specifiable id for requests. Should be unique among EndpointRequests made in the same batch call. If one isn't provided the client will generate its own. |
None
|
EndpointResponseFuture ¶
Represents a future response from an Endpoint. Specifically, when the EndpointResponseFuture is ready,
then its get method will return an actual instance of EndpointResponse.
This object should not be directly instantiated by the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client |
An instance of |
required | |
endpoint_name |
str
|
The name of the endpoint. |
required |
async_task_id |
str
|
An async task id. |
required |
get ¶
Retrieves the EndpointResponse for the prediction request after it completes. This method blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout |
Optional[float]
|
The maximum number of seconds to wait for the response. If None, then the method will block indefinitely until the response is ready. |
None
|
EndpointResponse ¶
EndpointResponse(client, status: str, result_url: Optional[str] = None, result: Optional[str] = None, traceback: Optional[str] = None)
Represents a response received from a Endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client |
An instance of |
required | |
status |
str
|
A string representing the status of the request, i.e. |
required |
result_url |
Optional[str]
|
A string that is a url containing the pickled python object from the Endpoint's predict function. Exactly one of |
None
|
result |
Optional[str]
|
A string that is the serialized return value (in json form) of the Endpoint's predict function.
Specifically, one can Exactly one of |
None
|
traceback |
Optional[str]
|
The stack trace if the inference endpoint raised an error. Can be used for debugging |
None
|
EndpointResponseStream ¶
Bases: Iterator
Represents a stream response from an Endpoint. This object is iterable and yields
EndpointResponse objects.
This object should not be directly instantiated by the user.