Server

The RPC server.

class lorien.tune.rpc.server.RPCService(target: str)

The RPC service for tuning AutoTVM tasks.

get_job_configs_str(token: str) str

Request job configs in string (YAML format).

Returns

  • token (str) -- The client token.

  • job_configs_str (str) -- The job configs in string.

init(socket_port: str, job_configs: lorien.tune.job.JobConfigs) str

Initialize job configurations. The client that calls this method will acquire the root token to call other methods that requires root permission.

Parameters
  • socket_port (str) -- A string of client socket port. Usually can be retrieved by client_conn._channel.stream.sock.getsockname()[1].

  • job_configs (JobConfigs) -- The job configurations.

is_init() bool

Check if the server is initialized.

Returns

init -- True if job configuration is ready; False otherwise.

Return type

bool

match_socket_port(socket_port: str) Optional[rpyc.core.protocol.Connection]

Check if the given socket name matches the list maintained in the server.

Parameters

socket_port (str) -- A string of client socket port. Usually can be retrieved by client_conn._channel.stream.sock.getsockname()[1].

Returns

conn -- The corresponding server side connection. None if no match.

Return type

Optional[Connection]

num_workers() int

Get the number of live workers.

Returns

n_workers -- The number of live workers.

Return type

int

on_connect(conn: rpyc.core.protocol.Connection)

Will be called automatically when a new connection is established. We maintain the socket information in order to track the future incoming client requests. Especially, when a client is disconnected, we are capable of recycling its job back to the job queue.

Note

We cannot use the socket name as the key to tokens, because the stream will be closed prior to call on_disconnect and the socket name will be unavailable to match the token.

Parameters

conn (Connection) -- The new connection on the server side.

on_disconnect(conn: rpyc.core.protocol.Connection)

Will be called automatically when a connection object is being cleaned. When a connection of a registered worker is cleaned, we invalid its token and recycle its running job back to the job queue.

Parameters

conn (Connection) -- The new connection on the server side.

register_worker(socket_port: str, target: str) Tuple[bool, str]

Let client register itself as a tuning worker.

Parameters
  • socket_port (str) -- A string of client socket port. Usually can be retrieved by client_conn._channel.stream.sock.getsockname()[1].

  • target (str) -- The client expected the target string for checking.

Returns

token_or_msg -- A tuple of (success, token or error message).

Return type

Tuple[bool, str]

request_job(token: str) str

Request one job to tune.

Parameters

token (str) -- The client token.

Returns

job -- The job in string format.

Return type

str

send_result(token: str, job_n_result: Tuple[str, str]) str

Accept a serialized result from workers.

Parameters
  • token (str) -- The client token.

  • job_n_result (Tuple[str, str]) -- A string pair of job and result.

Returns

msg -- The result message for client.

Return type

str

lorien.tune.rpc.server.need_root(func: Callable)

A decorator that ensures RPC functions can only be called by a client with the root token.

Parameters

func (Callable) -- The RPC server methods that requires root permission.

Returns

_check_n_run -- A function with the an additional argument to accept a client token for checking.

Return type

Callable