Exemple #1
0
def init_roll_site_context(runtime_conf, session_id):
    from eggroll.roll_site.roll_site import RollSiteContext
    from eggroll.roll_pair.roll_pair import RollPairContext
    LOGGER.info("init_roll_site_context runtime_conf: {}".format(runtime_conf))
    session_instance = FateSession.get_instance()._eggroll.get_session()
    rp_context = RollPairContext(session_instance)

    role = runtime_conf.get("local").get("role")
    party_id = str(runtime_conf.get("local").get("party_id"))
    _path = file_utils.get_project_base_directory(
    ) + "/arch/conf/server_conf.json"

    server_conf = file_utils.load_json_conf(_path)
    host = server_conf.get('servers').get('proxy').get("host")
    port = server_conf.get('servers').get('proxy').get("port")

    options = {
        'self_role': role,
        'self_party_id': party_id,
        'proxy_endpoint': ErEndpoint(host, int(port))
    }

    rs_context = RollSiteContext(session_id,
                                 rp_ctx=rp_context,
                                 options=options)
    LOGGER.info("init_roll_site_context done: {}".format(rs_context.__dict__))
    return rp_context, rs_context
Exemple #2
0
def get_standalone_context(role,
                           self_party_id,
                           props_file=default_props_file,
                           roll_site_session_id=None):
    options = {}
    options[
        SessionConfKeys.CONFKEY_SESSION_DEPLOY_MODE] = DeployModes.STANDALONE
    options[CoreConfKeys.STATIC_CONF_PATH] = props_file
    os.environ["EGGROLL_RESOURCE_MANAGER_AUTO_BOOTSTRAP"] = "1"

    rp_context = rpta.get_standalone_context(options=options)

    rs_options = get_option(role,
                            self_party_id,
                            props_file,
                            deploy_mode=DeployModes.STANDALONE)
    options.update(rs_options)
    rs_context = RollSiteContext(roll_site_session_id,
                                 rp_ctx=rp_context,
                                 options=get_option(
                                     role,
                                     self_party_id,
                                     props_file,
                                     deploy_mode=DeployModes.STANDALONE))

    return rs_context
 def test_get(self):
     rp_context = get_debug_test_context(is_standalone, manager_port_host,
                                         egg_port_host, transfer_port_host,
                                         'testing')
     context = RollSiteContext("atest",
                               self_role='host',
                               self_partyId=host_partyId,
                               rs_ip=host_ip,
                               rs_port=host_rs_port,
                               rp_ctx=rp_context)
     _tag = "Hello2"
     rs = context.load(name="RsaIntersectTransferVariable.rsa_pubkey",
                       tag="{}".format(_tag))
     futures = rs.pull(get_parties)
     for future in futures:
         obj = future.result()
         if isinstance(obj, RollPair):
             key = 'hello'
             print("obj:", obj.get(key))
         else:
             print("obj:", obj)
    def test_get_rollpair(self):
        rp_context = get_debug_test_context(is_standalone, manager_port_host,
                                            egg_port_host, transfer_port_host,
                                            'testing')
        context = RollSiteContext("atest2",
                                  self_role='host',
                                  self_partyId=host_partyId,
                                  rs_ip=host_ip,
                                  rs_port=host_rs_port,
                                  rp_ctx=rp_context)

        _tag = "roll_pair_tag"
        rs = context.load(name="roll_pair_name.table", tag="{}".format(_tag))
        futures = rs.pull(get_parties)
        for future in futures:
            obj = future.result()
            if isinstance(obj, RollPair):
                key = "k1"
                print("obj:", obj.get(key))
            else:
                print("obj:", obj)
Exemple #5
0
def get_cluster_context(role, options: dict = None, props_file=default_props_file, party_id=None):
    if options is None:
        options = {}
    rp_context = rpta.get_cluster_context(options=options)

    rs_options = get_option(role, props_file)

    if party_id:
        rs_options['self_party_id'] = str(party_id)
    rs_context = RollSiteContext(roll_site_session_id, rp_ctx=rp_context,
                                 options=rs_options)

    return rs_context
    def test_remote(self):
        rp_context = get_debug_test_context(is_standalone, manager_port_guest,
                                            egg_port_guest,
                                            transfer_port_guest,
                                            'testing_guest')
        context = RollSiteContext("atest",
                                  self_role='guest',
                                  self_partyId=guest_partyId,
                                  rs_ip=guest_ip,
                                  rs_port=guest_rs_port,
                                  rp_ctx=rp_context)

        _tag = "Hello2"
        rs = context.load(name="RsaIntersectTransferVariable.rsa_pubkey",
                          tag="{}".format(_tag))
        fp = open("testA.model", 'r')
        obj = fp.read(35)
        futures = rs.push(obj, remote_parties)
        fp.close()
        for future in futures:
            role, party = future.result()
            print("result:", role, party)
    def test_remote_rollpair(self):
        rp_context = get_debug_test_context(is_standalone, manager_port_guest,
                                            egg_port_guest,
                                            transfer_port_guest,
                                            'testing_guest')
        data = [("k1", "v1"), ("k2", "v2"), ("k3", "v3"), ("k4", "v4"),
                ("k5", "v5"), ("k6", "v6")]
        context = RollSiteContext("atest2",
                                  self_role='guest',
                                  self_partyId=guest_partyId,
                                  rs_ip=guest_ip,
                                  rs_port=guest_rs_port,
                                  rp_ctx=rp_context)

        rp_options = {'include_key': True}
        rp = rp_context.load("namespace", "name").put_all(data,
                                                          options=rp_options)
        _tag = "Hello"
        rs = context.load(name="roll_pair_name.table", tag="roll_pair_tag")
        futures = rs.push(rp, remote_parties)
        for future in futures:
            role, party = future.result()
            print("result:", role, party)
Exemple #8
0
    def __init__(self, rp_ctx, rs_session_id, party, proxy_endpoint):
        LOGGER.debug(
            f"[federation.eggroll]init federation: "
            f"rp_session_id={rp_ctx.session_id}, rs_session_id={rs_session_id}, "
            f"party={party}, proxy_endpoint={proxy_endpoint}"
        )

        options = {
            "self_role": party.role,
            "self_party_id": party.party_id,
            "proxy_endpoint": proxy_endpoint,
        }
        self._rsc = RollSiteContext(rs_session_id, rp_ctx=rp_ctx, options=options)
        LOGGER.debug(f"[federation.eggroll]init federation context done")
Exemple #9
0
def get_debug_test_context(is_standalone=False,
        manager_port=4670,
        egg_port=20001,
        transfer_port=20002,
        session_id='testing',
        role='host',
        props_file=default_props_file):
    rp_context = rpta.get_debug_test_context(is_standalone=is_standalone,
                                             manager_port=manager_port,
                                             egg_port=egg_port,
                                             transfer_port=transfer_port,
                                             session_id=session_id)

    rs_context = RollSiteContext(roll_site_session_id, rp_ctx=rp_context,
                                 options=get_option(role, props_file))

    return rs_context
Exemple #10
0
    def __init__(self, rp_ctx, rs_session_id, party, proxy_endpoint):
        LOGGER.debug(f"[federation.eggroll]init federation: "
                     f"rp_session_id={rp_ctx.session_id}, rs_session_id={rs_session_id}, "
                     f"party={party}, proxy_endpoint={proxy_endpoint}")

        from eggroll.core.meta_model import ErEndpoint
        if isinstance(proxy_endpoint, str):
            splited = proxy_endpoint.split(':')
            proxy_endpoint = ErEndpoint(host=splited[0].strip(), port=int(splited[1].strip()))

        options = {
            'self_role': party.role,
            'self_party_id': party.party_id,
            'proxy_endpoint': proxy_endpoint
        }
        self._rsc = RollSiteContext(rs_session_id, rp_ctx=rp_ctx, options=options)
        LOGGER.debug(f"[federation.eggroll]init federation context done")
Exemple #11
0
def get_cluster_context(role,
                        options: dict = None,
                        props_file=default_props_file,
                        party_id=None,
                        roll_site_session_id=None):
    if options is None:
        options = {}
    options['session_id'] = '_'.join([roll_site_session_id, role, party_id])
    print("session_id: ", options['session_id'])

    options[CoreConfKeys.STATIC_CONF_PATH] = props_file
    rp_context = rpta.get_cluster_context(options=options)

    rs_options = get_option(role, self_party_id=party_id, conf_file=props_file)

    rs_context = RollSiteContext(roll_site_session_id,
                                 rp_ctx=rp_context,
                                 options=rs_options)

    return rs_context
Exemple #12
0
def get_debug_test_context(is_standalone=False,
                           manager_port=4670,
                           command_port=20001,
                           transfer_port=20002,
                           role='host',
                           self_party_id=None,
                           props_file=default_props_file,
                           roll_site_session_id=None):
    rp_context = rpta.get_debug_test_context(
        is_standalone=is_standalone,
        manager_port=manager_port,
        egg_port=command_port,
        transfer_port=transfer_port,
        session_id='_'.join([roll_site_session_id, role,
                             str(self_party_id)]))

    rs_context = RollSiteContext(roll_site_session_id=roll_site_session_id,
                                 rp_ctx=rp_context,
                                 options=get_option(
                                     role=role,
                                     self_party_id=self_party_id,
                                     conf_file=props_file))

    return rs_context
Exemple #13
0
def get_standalone_context(role, props_file=default_props_file):
    rp_context = rpta.get_standalone_context()
    rs_context = RollSiteContext(roll_site_session_id, rp_ctx=rp_context,
                                 options=get_option(role, props_file))

    return rs_context
Exemple #14
0
def get_debug_rs_context(rp_context, rs_session_id, options):
    return RollSiteContext(rs_session_id, rp_ctx=rp_context, options=options)