コード例 #1
0
    def test_reduce(self):
        def concat(a, b):
            return a + b

        pickled_function = cloudpickle.dumps(concat)

        store_locator = ErStoreLocator(store_type="levelDb",
                                       namespace="ns",
                                       name='name')
        job = ErJob(id="1",
                    name="reduce",
                    inputs=[ErStore(store_locator=store_locator)],
                    functors=[ErFunctor(name="reduce", body=pickled_function)])

        channel = grpc.insecure_channel(
            target='localhost:20000',
            options=[('grpc.max_send_message_length', -1),
                     ('grpc.max_receive_message_length', -1)])

        roll_pair_stub = command_pb2_grpc.CommandServiceStub(channel)
        request = ErCommandRequest(
            seq=1,
            uri='com.webank.eggroll.rollpair.component.RollPair.reduce',
            args=[job.to_proto().SerializeToString()])

        result = roll_pair_stub.call(request.to_proto())
        time.sleep(1200)
コード例 #2
0
    def test_scalar_mul_raw(self):
        def scalar_mul(v):
            pub_key, private_key = rpt_engine.keygen()

            return rpt_engine.slcmul(rpt_engine.load(v, 1, 1, 1), 2.0, pub_key,
                                     private_key)

        pickled_function = cloudpickle.dumps(scalar_mul)

        store_locator = ErStoreLocator(store_type="levelDb",
                                       namespace="ns",
                                       name='mat_a')
        functor = ErFunctor(name="mapValues", body=pickled_function)

        job = ErJob(id="1",
                    name="mapValues",
                    inputs=[ErStore(store_locator=store_locator)],
                    functors=[functor])

        channel = grpc.insecure_channel(
            target='localhost:20000',
            options=[('grpc.max_send_message_length', -1),
                     ('grpc.max_receive_message_length', -1)])

        roll_pair_stub = command_pb2_grpc.CommandServiceStub(channel)

        request = ErCommandRequest(
            seq=1,
            uri='com.webank.eggroll.rollpair.component.RollPair.mapValues',
            args=[job.to_proto().SerializeToString()])

        # print(f"ready to call")
        result = roll_pair_stub.call(request.to_proto())

        time.sleep(1200)