Documentation ¶
Index ¶
- Constants
- type Endpoint
- type PredictClient
- func (p *PredictClient) AddHeader(headerName, headerValue string)
- func (p *PredictClient) BytesPredict(requestData []byte) ([]byte, error)
- func (p *PredictClient) Init() error
- func (p *PredictClient) Predict(request Request) (Response, error)
- func (p *PredictClient) SetEndpoint(endpointName string)
- func (p *PredictClient) SetEndpointType(endpointType string)
- func (p *PredictClient) SetHost(host string)
- func (p *PredictClient) SetHttpTransport(transport *http.Transport)
- func (p *PredictClient) SetRetryCount(cnt int)
- func (p *PredictClient) SetServiceName(serviceName string)
- func (p *PredictClient) SetTimeout(timeout int)
- func (p *PredictClient) SetToken(token string)
- func (p *PredictClient) Shutdown()
- func (p *PredictClient) StringPredict(str string) (string, error)
- func (p *PredictClient) TFPredict(request TFRequest) (*TFResponse, error)
- func (p *PredictClient) TorchPredict(request TorchRequest) (*TorchResponse, error)
- type PredictError
- type QueueClient
- func (q *QueueClient) Attributes() (types.Attributes, error)
- func (q *QueueClient) Commit(ctx context.Context, indexes ...uint64) error
- func (q *QueueClient) Del(ctx context.Context, indexes ...uint64) error
- func (q *QueueClient) End(ctx context.Context, force bool) error
- func (q *QueueClient) Get(ctx context.Context, index uint64, length int, timeout time.Duration, ...) (dfs []types.DataFrame, err error)
- func (q *QueueClient) GetByIndex(ctx context.Context, index uint64) (dfs []types.DataFrame, err error)
- func (q *QueueClient) GetByRequestId(ctx context.Context, requestId string) (dfs []types.DataFrame, err error)
- func (q *QueueClient) Put(ctx context.Context, data []byte, tags types.Tags) (index uint64, requestId string, err error)
- func (q *QueueClient) Truncate(ctx context.Context, index uint64) error
- func (q *QueueClient) Watch(ctx context.Context, index, window uint64, indexOnly bool, autocommit bool) (types.Watcher, error)
- type QueueUser
- type Request
- type Response
- type TFRequest
- func (tr *TFRequest) AddFeedBool(inputName string, shape []int64, content []bool)
- func (tr *TFRequest) AddFeedFloat32(inputName string, shape []int64, content []float32)
- func (tr *TFRequest) AddFeedFloat64(inputName string, shape []int64, content []float64)
- func (tr *TFRequest) AddFeedInt32(inputName string, shape []int64, content []int32)
- func (tr *TFRequest) AddFeedInt64(inputName string, shape []int64, content []int64)
- func (tr *TFRequest) AddFeedString(inputName string, shape []int64, content [][]byte)
- func (tr *TFRequest) AddFetch(outName string)
- func (tr *TFRequest) SetSignatureName(sigName string)
- func (tr TFRequest) ToString() (string, error)
- type TFResponse
- func (tresp *TFResponse) GetBoolVal(outputName string) []bool
- func (tresp *TFResponse) GetDoubleVal(outputName string) []float64
- func (tresp *TFResponse) GetFloatVal(outputName string) []float32
- func (tresp *TFResponse) GetInt64Val(outputName string) []int64
- func (tresp *TFResponse) GetIntVal(outputName string) []int32
- func (tresp *TFResponse) GetStringVal(outputName string) [][]byte
- func (tresp *TFResponse) GetTensorShape(outputName string) []int64
- type TorchRequest
- func (tr *TorchRequest) AddFeedFloat32(index int, shape []int64, content []float32)
- func (tr *TorchRequest) AddFeedFloat64(index int, shape []int64, content []float64)
- func (tr *TorchRequest) AddFeedInt32(index int, shape []int64, content []int32)
- func (tr *TorchRequest) AddFeedInt64(index int, shape []int64, content []int64)
- func (tr *TorchRequest) AddFetch(outIndex int32)
- func (tr TorchRequest) ToString() (string, error)
- type TorchResponse
- func (resp *TorchResponse) GetDoubleVal(outIndex int) []float64
- func (resp *TorchResponse) GetFloatVal(outIndex int) []float32
- func (resp *TorchResponse) GetInt64Val(outIndex int) []int64
- func (resp *TorchResponse) GetIntVal(outIndex int) []int32
- func (resp *TorchResponse) GetTensorShape(outIndex int) []int64
Constants ¶
const ( // Default endpoint is the gateway mode EndpointTypeDefault = "DEFAULT" // Vipserver endpoint is only used for services which registered // vipsever domains in alibaba internal clusters EndpointTypeVipserver = "VIPSERVER" // Direct endpoint is used for direct accessing to the services' instances // both inside a eas service and in user's client ecs EndpointTypeDirect = "DIRECT" // use eas docker to deploy service, but not use pai eas EndpointTypeDocker = "DOCKER" )
const ( ErrorCodeServiceDiscovery = 510 ErrorCodeCreateRequest = 511 ErrorCodePerformRequest = 512 ErrorCodeReadResponse = 513 )
const ( HeaderRequestId = "X-Eas-Queueservice-Request-Id" HeaderAuthorization = "Authorization" DefaultGroupName = "eas" )
const ( TfType_DT_FLOAT tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_FLOAT TfType_DT_DOUBLE tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_DOUBLE TfType_DT_INT32 tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_INT32 TfType_DT_UINT8 tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_UINT8 TfType_DT_INT16 tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_INT16 TfType_DT_INT8 tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_INT8 TfType_DT_STRING tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_STRING TfType_DT_INT64 tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_INT64 TfType_DT_BOOL tf_predict_protos.ArrayDataType = tf_predict_protos.ArrayDataType_DT_BOOL )
TfType_DT_INVALID and listed types use ALL_CAPS names here to consist with other language's sdk.
const ( // TorchType_DT_FLOAT and listed types use ALL_CAPS names here to consist with other language's sdk. TorchType_DT_FLOAT torch_predict_protos.ArrayDataType = torch_predict_protos.ArrayDataType_DT_FLOAT TorchType_DT_DOUBLE torch_predict_protos.ArrayDataType = torch_predict_protos.ArrayDataType_DT_DOUBLE TorchType_DT_INT32 torch_predict_protos.ArrayDataType = torch_predict_protos.ArrayDataType_DT_INT32 TorchType_DT_UINT8 torch_predict_protos.ArrayDataType = torch_predict_protos.ArrayDataType_DT_UINT8 TorchType_DT_INT16 torch_predict_protos.ArrayDataType = torch_predict_protos.ArrayDataType_DT_INT16 TorchType_DT_INT8 torch_predict_protos.ArrayDataType = torch_predict_protos.ArrayDataType_DT_INT8 TorchType_DT_INT64 torch_predict_protos.ArrayDataType = torch_predict_protos.ArrayDataType_DT_INT64 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PredictClient ¶
type PredictClient struct {
// contains filtered or unexported fields
}
PredictClient for accessing prediction service by creating a fixed size connection pool to perform the request through established persistent connections.
func NewPredictClient ¶
func NewPredictClient(endpointName string, serviceName string) *PredictClient
NewPredictClient returns an instance of PredictClient
func (*PredictClient) AddHeader ¶
func (p *PredictClient) AddHeader(headerName, headerValue string)
func (*PredictClient) BytesPredict ¶
func (p *PredictClient) BytesPredict(requestData []byte) ([]byte, error)
BytesPredict send the raw request data in byte array through http connections, retry the request automatically when an error occurs
func (*PredictClient) Init ¶
func (p *PredictClient) Init() error
Init initializes the predict client to create and enable endpoint discovery
func (*PredictClient) Predict ¶
func (p *PredictClient) Predict(request Request) (Response, error)
Predict for request
func (*PredictClient) SetEndpoint ¶
func (p *PredictClient) SetEndpoint(endpointName string)
SetEndpoint sets service's endpoint for client
func (*PredictClient) SetEndpointType ¶
func (p *PredictClient) SetEndpointType(endpointType string)
SetEndpointType sets endpoint type for client
func (*PredictClient) SetHost ¶
func (p *PredictClient) SetHost(host string)
func (*PredictClient) SetHttpTransport ¶
func (p *PredictClient) SetHttpTransport(transport *http.Transport)
SetHttpTransport sets http transport argument for go http client
func (*PredictClient) SetRetryCount ¶
func (p *PredictClient) SetRetryCount(cnt int)
SetRetryCount sets max retry count for client
func (*PredictClient) SetServiceName ¶
func (p *PredictClient) SetServiceName(serviceName string)
SetServiceName sets target service name for client
func (*PredictClient) SetTimeout ¶
func (p *PredictClient) SetTimeout(timeout int)
SetTimeout set the request timeout for client, 5000ms by default
func (*PredictClient) SetToken ¶
func (p *PredictClient) SetToken(token string)
SetToken function sets service's access token for client
func (*PredictClient) Shutdown ¶
func (p *PredictClient) Shutdown()
Shutdown after called this client instance should not be used again
func (*PredictClient) StringPredict ¶
func (p *PredictClient) StringPredict(str string) (string, error)
StringPredict function send input data and return predicted result
func (*PredictClient) TFPredict ¶
func (p *PredictClient) TFPredict(request TFRequest) (*TFResponse, error)
TFPredict function send input data and return TensorFlow predicted result
func (*PredictClient) TorchPredict ¶
func (p *PredictClient) TorchPredict(request TorchRequest) (*TorchResponse, error)
TorchPredict function send input data and return PyTorch predicted result
type PredictError ¶
PredictError is a custom err type
func NewPredictError ¶
func NewPredictError(code int, url string, msg string) *PredictError
NewPredictError constructs an error
type QueueClient ¶
type QueueClient struct { WebsocketWatch bool // codecs for data frame and attributes. DCodec types.DataFrameCodec ACodec types.AttributesCodec // contains filtered or unexported fields }
QueueClient is client of queue server, which also implements queue service interface
func NewQueueClient ¶
func NewQueueClient(endpoint, queueName, token string) (*QueueClient, error)
func (*QueueClient) Attributes ¶
func (q *QueueClient) Attributes() (types.Attributes, error)
func (*QueueClient) Commit ¶
func (q *QueueClient) Commit(ctx context.Context, indexes ...uint64) error
func (*QueueClient) GetByIndex ¶
func (*QueueClient) GetByRequestId ¶
type QueueUser ¶
type QueueUser struct {
// contains filtered or unexported fields
}
func NewQueueUser ¶
type TFRequest ¶
type TFRequest struct {
RequestData tf_predict_protos.PredictRequest
}
TFRequest class for tensorflow data and requests
func (*TFRequest) AddFeedBool ¶
AddFeedBool function adds boolean values input data for TFRequest
func (*TFRequest) AddFeedFloat32 ¶
AddFeedFloat32 function adds float values input data for TFRequest
func (*TFRequest) AddFeedFloat64 ¶
AddFeedFloat64 function adds double values input data for TFRequest
func (*TFRequest) AddFeedInt32 ¶
AddFeedInt32 function adds int values input data for TFRequest
func (*TFRequest) AddFeedInt64 ¶
AddFeedInt64 function adds int64 values input data for TFRequest
func (*TFRequest) AddFeedString ¶
AddFeedString function adds string values input data for TFRequest
func (*TFRequest) SetSignatureName ¶
SetSignatureName set signature name for TensorFlow request
type TFResponse ¶
type TFResponse struct {
Response tf_predict_protos.PredictResponse
}
TFResponse class for Pytf predicted results
func (*TFResponse) GetBoolVal ¶
func (tresp *TFResponse) GetBoolVal(outputName string) []bool
GetBoolVal returns []bool slice as output data
func (*TFResponse) GetDoubleVal ¶
func (tresp *TFResponse) GetDoubleVal(outputName string) []float64
GetDoubleVal returns []float64 slice as output data
func (*TFResponse) GetFloatVal ¶
func (tresp *TFResponse) GetFloatVal(outputName string) []float32
GetFloatVal returns []float32 slice as output data
func (*TFResponse) GetInt64Val ¶
func (tresp *TFResponse) GetInt64Val(outputName string) []int64
GetInt64Val returns []int64 slice as output data
func (*TFResponse) GetIntVal ¶
func (tresp *TFResponse) GetIntVal(outputName string) []int32
GetIntVal returns []int32 slice as output data
func (*TFResponse) GetStringVal ¶
func (tresp *TFResponse) GetStringVal(outputName string) [][]byte
GetStringVal returns []string slice as output data
func (*TFResponse) GetTensorShape ¶
func (tresp *TFResponse) GetTensorShape(outputName string) []int64
GetTensorShape returns []int64 slice as shape of tensor outindexed
type TorchRequest ¶
type TorchRequest struct {
RequestData torch_predict_protos.PredictRequest
}
TorchRequest class for PyTorch data and requests
func (*TorchRequest) AddFeedFloat32 ¶
func (tr *TorchRequest) AddFeedFloat32(index int, shape []int64, content []float32)
AddFeedFloat32 function adds float values input data for torchrequest
func (*TorchRequest) AddFeedFloat64 ¶
func (tr *TorchRequest) AddFeedFloat64(index int, shape []int64, content []float64)
AddFeedFloat64 function adds double values input data for torchrequest
func (*TorchRequest) AddFeedInt32 ¶
func (tr *TorchRequest) AddFeedInt32(index int, shape []int64, content []int32)
AddFeedInt32 function adds int values input data for torchrequest
func (*TorchRequest) AddFeedInt64 ¶
func (tr *TorchRequest) AddFeedInt64(index int, shape []int64, content []int64)
AddFeedInt64 function adds int64 values input data for torchrequest
func (*TorchRequest) AddFetch ¶
func (tr *TorchRequest) AddFetch(outIndex int32)
AddFetch add OutputFilter (outIndex) for response
func (TorchRequest) ToString ¶
func (tr TorchRequest) ToString() (string, error)
ToString for interface
type TorchResponse ¶
type TorchResponse struct {
Response torch_predict_protos.PredictResponse
}
TorchResponse class for PyTorch predicted results
func (*TorchResponse) GetDoubleVal ¶
func (resp *TorchResponse) GetDoubleVal(outIndex int) []float64
GetDoubleVal returns []float64 slice as output data
func (*TorchResponse) GetFloatVal ¶
func (resp *TorchResponse) GetFloatVal(outIndex int) []float32
GetFloatVal returns []float32 slice as output data
func (*TorchResponse) GetInt64Val ¶
func (resp *TorchResponse) GetInt64Val(outIndex int) []int64
GetInt64Val returns []int64 slice as output data
func (*TorchResponse) GetIntVal ¶
func (resp *TorchResponse) GetIntVal(outIndex int) []int32
GetIntVal returns []int32 slice as output data
func (*TorchResponse) GetTensorShape ¶
func (resp *TorchResponse) GetTensorShape(outIndex int) []int64
GetTensorShape returns []int64 slice as shape of tensor outindexed