Пример #1
0
    def setUpClass(cls):
        env = Warp17Env()
        tstamp = env.get_uniq_stamp()
        dirpath = '/tmp/warp17-test-' + tstamp

        if not os.path.exists(dirpath):
            os.mkdir(dirpath)

        print "Logs and outputs in " + dirpath

        out_file = dirpath + '/' + cls.__name__ + '.out'
        log_file = dirpath + '/' + cls.__name__ + '.log'

        Warp17BaseUnitTestCase.oargs = Warp17OutputArgs(out_file)

        Warp17BaseUnitTestCase.lh = LogHelper(name=cls.__name__,
                                              filename=log_file)

        Warp17BaseUnitTestCase.env = env

        Warp17BaseUnitTestCase.warp17_call = partial(warp17_method_call,
                                                     env.get_host_name(),
                                                     env.get_rpc_port(),
                                                     Warp17_Stub)
        Warp17UnitTestCase.longMessage = True
Пример #2
0
    def setUpClass(cls):
        env = Warp17Env()
        tstamp = env.get_uniq_stamp()
        dirpath = '/tmp/warp17-test-' + tstamp

        if not os.path.exists(dirpath):
            os.mkdir(dirpath)

        print "Logs and outputs in " + dirpath

        out_file = dirpath + '/' + cls.__name__ + '.out'
        log_file = dirpath + '/' + cls.__name__ + '.log'

        oargs = Warp17OutputArgs(out_file)
        Warp17UnitTestCase.lh = LogHelper(name=cls.__name__, filename=log_file)

        Warp17UnitTestCase.env = env

        Warp17UnitTestCase.warp17_call = partial(warp17_method_call,
                                                 env.get_host_name(),
                                                 env.get_rpc_port(),
                                                 Warp17_Stub)

        Warp17UnitTestCase.warp17_proc = warp17_start(env=env,
                                                      output_args=oargs)
        # Wait until WARP17 actually starts.
        warp17_wait(env=env, logger=Warp17UnitTestCase.lh)
        # Detailed error messages
        Warp17UnitTestCase.longMessage = True
Пример #3
0
sys.path.append('../api/generated/py')
import warp17_service_pb2

from google.protobuf.service import RpcChannel
from google.protobuf.service import RpcController

import socket
import struct
import random

from helpers import LogHelper
from helpers import Warp17Exception

WARP17_RPC_LOG_FILE='/tmp/warp17-rpc.log'

lh = LogHelper(name=__name__, filename=WARP17_RPC_LOG_FILE)

def read_bytes_from_sock(sock, bytes_to_read, msg, controller):
    buf = bytearray(bytes_to_read)
    view = memoryview(buf)
    while bytes_to_read:
        byte_cnt = sock.recv_into(view, bytes_to_read)
        if byte_cnt == 0:
            controller.SetFailed('Failed to receive all the ' + msg + ' data')
            return None
        view = view[byte_cnt:]
        bytes_to_read -= byte_cnt

    return buf

class Warp17RpcDefines():
Пример #4
0
        total_test_num += test_triple_num
        total_gold_num += gold_triple_num
        # clear the matching triple dictionary for the next AMR pair
        match_triple_dict.clear()
        sent_num += 1
    if verbose:
        log_helper.debug(
            "Total match number, total triple number in AMR 1, and total triple number in AMR 2:"
        )
        log_helper.debug(total_match_num_soft, total_test_num, total_gold_num)
        log_helper.debug(
            "---------------------------------------------------------------------------------"
        )
    # output document-level smatch score (a single f-score for all AMR pairs in two files)
    return compute_f(total_match_num_soft, total_test_num, total_gold_num)

if __name__ == "__main__":
    parser = None
    args = None
    # only support python version 2.5 or later
    import argparse
    parser = build_arg_parser()
    args = parser.parse_args()
    from helpers import LogHelper
    if args.v:
        ll = 1
    else:
        ll = 5
    log_helper = LogHelper(ll)
    main(args)