Ejemplo n.º 1
0
def get_party_id():
    """Get your party id."""
    if not py_protocol_handler.is_activated():
        rtt_get_logger().error(
            "This API can only be called after some protocol is activated!")
        return -1
    return py_protocol_handler.get_party_id()
Ejemplo n.º 2
0
def get_protocol_config(keyword=""):
    """Get all the config info you are using now.

    Note that the parameter is not supported yet.
    """
    global _curr_config_json_str
    if not py_protocol_handler.is_activated():
        rtt_get_logger().error("This API can only be called after some protocol is activated!")
        return -1
    return _curr_config_json_str
Ejemplo n.º 3
0
def SecureGetRandomSeed(op_seed=None):
    """Returns the local seeds an operation should use given an op-specific seed.
    Args:
      op_seed: integer.

    Returns:
      A tuple of two integers that should be used for the local seed of this
      operation.
    """
    eager = context.executing_eagerly()

    if eager:
        global_seed = context.global_seed()
    else:
        global_seed = ops.get_default_graph().seed

    seeds = (0, 0)
    if global_seed is not None:
        if op_seed is None:
            # pylint: disable=protected-access
            if hasattr(ops.get_default_graph(), '_seed_used'):
                ops.get_default_graph()._seed_used = True
            if eager:
                op_seed = context.internal_operation_seed()
            else:
                op_seed = ops.get_default_graph()._last_id

        seeds = random_seed._truncate_seed(
            global_seed), random_seed._truncate_seed(op_seed)
    else:
        if op_seed is not None:
            seeds = random_seed.DEFAULT_GRAPH_SEED, random_seed._truncate_seed(
                op_seed)
        else:
            if py_protocol_handler.is_activated():
                seeds = py_protocol_handler.rand_seed(
                    0), py_protocol_handler.rand_seed(0)

    # Avoid (0, 0) as the C++ ops interpret it as nondeterminism, which would
    # random_seedbe unexpected since Python docs say nondeterminism is (None, None).
    if seeds == (0, 0):
        return (0, random_seed._MAXINT32)

    return seeds
Ejemplo n.º 4
0
def __check(task_id):
    if not py_protocol_handler.is_activated(task_id):
        errmsg = "Protocol have not activated. See rtt.activate()."
        rtt_get_logger().error(errmsg)
        raise Exception(errmsg)