예제 #1
0
def test_initial_checkpoint_write(n=2):
    """1. Launch a few apps and write the checkpoint once a few have completed
    """
    config = fresh_config()
    config.checkpoint_mode = 'manual'
    parsl.load(config)
    results = launch_n_random(n)

    cpt_dir = parsl.dfk().checkpoint()

    cptpath = cpt_dir + '/dfk.pkl'
    print("Path exists : ", os.path.exists(cptpath))
    assert os.path.exists(cptpath), "DFK checkpoint missing: {0}".format(
        cptpath)

    cptpath = cpt_dir + '/tasks.pkl'
    print("Path exists : ", os.path.exists(cptpath))
    assert os.path.exists(cptpath), "Tasks checkpoint missing: {0}".format(
        cptpath)

    run_dir = parsl.dfk().run_dir

    parsl.dfk().cleanup()
    parsl.clear()

    return run_dir, results
예제 #2
0
def test_summary(caplog):

    parsl.load(fresh_config())

    succeed().result()
    fail().exception()

    parsl.dfk().cleanup()
    parsl.clear()

    assert "Summary of tasks in DFK:" in caplog.text
    assert "Tasks in state States.exec_done: 1" in caplog.text
    assert "Tasks in state States.failed: 1" in caplog.text
예제 #3
0
def test_lazy_behavior():
    """Testing that lazy errors work"""

    config = fresh_config()
    parsl.load(config)

    @python_app
    def divide(a, b):
        return a / b

    futures = []
    for i in range(0, 10):
        futures.append(divide(10, 0))

    for f in futures:
        assert isinstance(f.exception(), ZeroDivisionError)
        assert f.done()

    parsl.clear()
    return
예제 #4
0
def test_lazy_behavior():
    """Testing lazy errors to work"""

    config = fresh_config()
    config.lazy_errors = True
    parsl.load(config)

    @App('python')
    def divide(a, b):
        return a / b

    items = []
    for i in range(0, 1):
        items.append(divide(10, i))

    while True:
        if items[0].done:
            break

    parsl.clear()
    return
예제 #5
0
import argparse
import os

import parsl
from parsl.app.app import App
from parsl.tests.configs.local_threads import fresh_config

local_config = fresh_config()
local_config.retries = 2


@App('python')
def sleep_then_fail(inputs=[], sleep_dur=0.1):
    import time
    import math
    time.sleep(sleep_dur)
    math.ceil("Trigger TypeError")
    return 0


@App('bash')
def succeed_on_retry(filename, success_on=2, stdout="succeed.out"):
    """If the input file does not exist it creates it.
    Then, if the file contains success_on lines it exits with 0
    """

    return """if [[ ! -e {0} ]]; then touch {0}; fi;
    tries=`wc -l {0} | cut -f1 -d' '`
    echo $tries >> {0}

    if [[ "$tries" -eq "{success_on}" ]]