Exemplo n.º 1
0
def run_interaction_two_steps(step1_name, S1, E1, step2_name, S2, E2):
    root1 = tempfile.mkdtemp()
    os.makedirs(os.path.join(root1, CHALLENGE_PREVIOUS_STEPS_DIR))
    print('Root: %s' % root1)

    def step1_evaluator():
        set_step(step1_name)
        wrap_evaluator(E1, root=root1)

    def step1_solution():
        set_step(step1_name)
        wrap_solution(S1, root=root1)

    p_e = Process(target=step1_evaluator)
    p_e.start()
    p_s = Process(target=step1_solution)
    p_s.start()
    p_s.join()
    p_e.join()

    cr1 = read_challenge_results(root1)

    print('cr1: %s' % json.dumps(cr1.to_yaml(), indent=4))

    if cr1.status in ['error', 'failed']:
        return cr1, None

    root2 = tempfile.mkdtemp()
    print('Root2: %s' % root2)

    os.makedirs(os.path.join(root2, CHALLENGE_PREVIOUS_STEPS_DIR))
    l = os.path.join(root2, CHALLENGE_PREVIOUS_STEPS_DIR, step1_name)
    os.link(root1, l)

    def step2_evaluator():
        set_step(step2_name)
        wrap_evaluator(E2, root=root2)

    def step2_solution():
        set_step(step2_name)
        wrap_solution(S2, root=root2)

    p_e = Process(target=step2_evaluator)
    p_e.start()
    p_s = Process(target=step2_solution)
    p_s.start()
    p_s.join()
    p_e.join()

    cr2 = read_challenge_results(root2)
    print('cr2: %s' % json.dumps(cr2.to_yaml(), indent=4))
    return cr1, cr2
Exemplo n.º 2
0
def run_interaction_two_steps(step1_name, s1, e1, step2_name, s2, e2):
    root1 = tempfile.mkdtemp()
    os.makedirs(os.path.join(root1, CHALLENGE_PREVIOUS_STEPS_DIR))
    logger.info("Root: %s" % root1)

    p_e = Process(target=i2_step1_evaluator, args=(root1, e1))
    p_e.start()
    p_s = Process(target=i2_step1_solution, args=(root1, s1))
    p_s.start()
    p_s.join()
    p_e.join()

    cr1 = read_challenge_results(root1)

    logger.info("cr1: %s" % json.dumps(cr1.to_yaml(), indent=4))

    if cr1.status in ["error", "failed"]:
        return cr1, None

    root2 = tempfile.mkdtemp()
    logger.info("Root2: %s" % root2)

    os.makedirs(os.path.join(root2, CHALLENGE_PREVIOUS_STEPS_DIR))
    l = os.path.join(root2, CHALLENGE_PREVIOUS_STEPS_DIR, step1_name)
    # os.link(root1, l)
    shutil.copytree(root1, l)

    p_e = Process(
        target=i2_step2_evaluator,
        args=(
            root2,
            e2,
        ),
    )
    p_e.start()
    p_s = Process(
        target=i2_step2_solution,
        args=(
            root2,
            s2,
        ),
    )
    p_s.start()
    p_s.join()
    p_e.join()

    cr2 = read_challenge_results(root2)
    logger.info("cr2: %s" % json.dumps(cr2.to_yaml(), indent=4))
    return cr1, cr2
def run_interaction(S, E):
    root = tempfile.mkdtemp()
    print('Root: %s' % root)

    def process_evaluator():
        wrap_evaluator(E, root=root)

    def process_solution():
        wrap_solution(S, root=root)

    p_e = Process(target=process_evaluator)
    p_e.start()
    p_s = Process(target=process_solution)
    p_s.start()
    p_e.join()

    #
    # E.prepare(cie)
    # cie.after_prepare()
    # cis = ChallengeInterfaceSolutionConcrete(root)
    # S.run(cis)
    # cis.after_run()
    # E.score(cie)
    # cie.after_score()
    cr = read_challenge_results(root)
    return cr
Exemplo n.º 4
0
def run_interaction(S, E):
    root = tempfile.mkdtemp()
    print("Root: %s" % root)
    os.environ["challenge_name"] = "test-challenge"
    os.environ["challenge_step_name"] = "test-challenge-step"

    p_e = Process(target=process_evaluator, args=(E, root))
    p_e.start()
    p_s = Process(target=process_solution, args=(S, root))
    p_s.start()
    p_e.join()

    cr = read_challenge_results(root)
    return cr
Exemplo n.º 5
0
def run_interaction(S, E):
    root = tempfile.mkdtemp()
    print('Root: %s' % root)

    def process_evaluator():
        wrap_evaluator(E, root=root)

    def process_solution():
        wrap_solution(S, root=root)

    p_e = Process(target=process_evaluator)
    p_e.start()
    p_s = Process(target=process_solution)
    p_s.start()
    p_e.join()

    cr = read_challenge_results(root)
    return cr