Esempio n. 1
0
    def __init__(self,
                 server_or_cluster_def,
                 job_name=None,
                 task_index=None,
                 protocol=None,
                 start=True):
        """Creates a new server with the given definition.

    The `job_name`, `task_index`, and `protocol` arguments are optional, and
    override any information also provided in `server_or_cluster_def`.

    Args:
      server_or_cluster_def: A `tf.train.ServerDef` or
        `tf.train.ClusterDef` protocol buffer, or a
        `tf.train.ClusterSpec` object, describing the server to be
        created and/or the cluster of which it is a member.
      job_name: (Optional.) If not specified in `server_or_cluster_def`,
        specifies the name of the job of which this server is a member.
      task_index: (Optional.) If not specified in `server_or_cluster_def`,
        specifies the task index of this server in its job.
      protocol: (Optional.) If not specified in `server_or_cluster_def`,
        specifies the protocol to be used by this server. Acceptable
        values include `"grpc"`.
      start: (Optional.) Boolean, indicating whether to start the server
        after creating it. Defaults to `True`.
    """
        server_def = _make_server_def(server_or_cluster_def, job_name,
                                      task_index, protocol)
        self._server = pywrap_tensorflow.NewServer(
            server_def.SerializeToString())
        if start:
            self.start()
Esempio n. 2
0
  def __init__(self, server_def, start=True):
    """Creates a new server with the given definition.

    Args:
      server_def: A `tf.ServerDef` protocol buffer, describing the server to
        be created (and the cluster of which it is a member).
      start: (Optional.) Boolean, indicating whether to start the server after
        creating it. Defaults to `True`.
    """
    if not isinstance(server_def, tensorflow_server_pb2.ServerDef):
      raise TypeError("server_def must be a tf.ServerDef")

    self._server = pywrap_tensorflow.NewServer(server_def.SerializeToString())
    if start:
      self.start()
Esempio n. 3
0
    def __init__(self,
                 server_or_cluster_def,
                 job_name=None,
                 task_index=None,
                 protocol=None,
                 start=True):
        """Creates a new server with the given definition.

    The `job_name`, `task_index`, and `protocol` arguments are optional, and
    override any information provided in `server_or_cluster_def`.

    Args:
      server_or_cluster_def: A `tf.train.ServerDef` or
        `tf.train.ClusterDef` protocol buffer, or a
        `tf.train.ClusterSpec` object, describing the server to be
        created and/or the cluster of which it is a member.
      job_name: (Optional.) Specifies the name of the job of which the server
        is a member. Defaults to the value in `server_or_cluster_def`, if
        specified.
      task_index: (Optional.) Specifies the task index of the server in its
        job. Defaults to the value in `server_or_cluster_def`, if specified.
        Otherwise defaults to 0 if the server's job has only one task.
      protocol: (Optional.) Specifies the protocol to be used by the server.
        Acceptable values include `"grpc"`. Defaults to the value in
        `server_or_cluster_def`, if specified. Otherwise defaults to `"grpc"`.
      start: (Optional.) Boolean, indicating whether to start the server
        after creating it. Defaults to `True`.
    """
        server_def = _make_server_def(server_or_cluster_def, job_name,
                                      task_index, protocol)
        try:
            self._server = pywrap_tensorflow.NewServer(
                server_def.SerializeToString())
        except pywrap_tensorflow.StatusNotOK as e:
            # pylint: disable=protected-access
            raise errors._make_specific_exception(None, None, e.error_message,
                                                  e.code)
            # pylint: enable=protected-access
        if start:
            self.start()