gRPC Client¶
-
class
Client
(host=None, port=None, auth=None, certificate=None, channel=None, **grpc_client_kwargs)[source]¶ Low-level gRPC client for interacting with the Workflows backend. Not intended for users to use directly.
Parameters: - host (str, optional) – The backend host to connect to. Defaults to the correct value. Only override when debugging
- port (int, optional) – The backend port to connect to. Defaults to the correct value. Only override when debugging.
- auth (Auth, optional) – The authentication instance to use. Defaults to
Auth.get_default_client()
. - certificate (bytes, optional) – The certificate to use when connecting to the backend service.
- channel (grpc.Channel, optional) – A pre-configured channel to use.
- **grpc_client_kwargs (dict, optional) – Additional arguments to use when creating the client instance.
Refer to
GrpcClient.__init__()
to see available options.
Examples
>>> from descarteslabs.workflows import Client, Int >>> my_client = Client(auth=non_default_auth) >>> Int(1).compute(client=my_client) 1 >>> Int(1).publish("One", client=my_client) <descarteslabs.workflows.models.workflow.Workflow object at 0x...>
Attributes:
DEFAULT_TIMEOUT
STREAM_TIMEOUT
api
The available Client operations, as a dict. certificate
The Client SSL certificate. channel
The GRPC channel of the Client. token
The Client token. Methods:
INSECURE_CHANNEL_FACTORY
(target[, options, …])Creates an insecure Channel to a server. SECURE_CHANNEL_FACTORY
(target, credentials)Creates a secure Channel to a server. close
()Close the GRPC channel associated with the Client. get_default_client
()Retrieve the default client. health
([timeout])Check the health of the GRPC server (SERVING, NOT_SERVING, UNKNOWN). set_default_client
(client)Change the default client to the given client. -
static
INSECURE_CHANNEL_FACTORY
(target, options=None, compression=None)¶ Creates an insecure Channel to a server.
The returned Channel is thread-safe.
Parameters: - target – The server address
- options – An optional list of key-value pairs (channel_arguments in gRPC Core runtime) to configure the channel.
- compression – An optional value indicating the compression method to be used over the lifetime of the channel. This is an EXPERIMENTAL option.
Returns: A Channel.
-
static
SECURE_CHANNEL_FACTORY
(target, credentials, options=None, compression=None)¶ Creates a secure Channel to a server.
The returned Channel is thread-safe.
Parameters: - target – The server address.
- credentials – A ChannelCredentials instance.
- options – An optional list of key-value pairs (channel_arguments in gRPC Core runtime) to configure the channel.
- compression – An optional value indicating the compression method to be used over the lifetime of the channel. This is an EXPERIMENTAL option.
Returns: A Channel.
-
close
()¶ Close the GRPC channel associated with the Client.
-
classmethod
get_default_client
()¶ Retrieve the default client.
This client is used whenever you don’t explicitly set the client.
-
health
(timeout=None)¶ Check the health of the GRPC server (SERVING, NOT_SERVING, UNKNOWN).
Example
>>> from descarteslabs.client.grpc import GrpcClient >>> GrpcClient().health() SERVING
-
classmethod
set_default_client
(client)¶ Change the default client to the given client.
This is the client that will be used whenever you don’t explicitly set the client
-
DEFAULT_TIMEOUT
= 5¶
-
STREAM_TIMEOUT
= 86400¶
-
property
api
¶ The available Client operations, as a dict.
-
property
certificate
¶ The Client SSL certificate.
-
property
channel
¶ The GRPC channel of the Client.
-
property
token
¶ The Client token.