示例#1
0
def test_xenon_42_multi():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = schedule(sum)(gather_all(multiples))

    machine = Machine(
        scheduler_adaptor='slurm',
        location='ssh://fs0.das5.cs.vu.nl/home/jhidding',
        credential=xenon.CertificateCredential(
            username='******', certfile='/home/johannes/.ssh/id_rsa'),
        jobs_properties={
            'xenon.adaptors.schedulers.ssh.strictHostKeyChecking': 'false'
        })
    worker_config = XenonJobConfig(
        prefix=Path('/home/jhidding/.local/share/workon/mcfly'),
        working_dir='/home/jhidding/',
        time_out=1000000000000,
        verbose=False)  # , options=['-C', 'TitanX', '--gres=gpu:1'])

    result = run_xenon(C,
                       machine=machine,
                       worker_config=worker_config,
                       n_processes=2)

    print("The answer is:", result)
示例#2
0
def test_broker_02():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    assert run_single(C) == 42
示例#3
0
def test_broker_01():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    assert run_parallel(C, 4) == 42
示例#4
0
def test_broker_02():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    assert run_single(C) == 42
示例#5
0
def test_broker_01():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    assert run_parallel(C, 4) == 42
示例#6
0
def test_lift_01():
    a = A()
    a.x = add(1, 2)
    a.y = sub(9, 11)
    b = f(lift(a))

    result = run_single(b)
    assert result == 1
示例#7
0
def test_xenon_42():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    result = run_parallel_timing(C, 4, sys.stdout)
    assert (result == 42)
示例#8
0
def test_broker_logging():
    A = log_add(1, 1)
    B = sub(3, A)

    multiples = [mul(log_add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    with NCDisplay(title="Running the test") as display:
        assert run_parallel_with_display(C, 4, display) == 42
示例#9
0
def test_xenon_42():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    result = run_parallel_timing(C, 4, sys.stdout)
    assert(result == 42)
示例#10
0
def test_broker_logging():
    A = log_add(1, 1)
    B = sub(3, A)

    multiples = [mul(log_add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    with NCDisplay(title="Running the test") as display:
        assert run_parallel_with_display(C, 4, display) == 42
示例#11
0
def test_global_prov():
    a = add(4, 5)
    b = sub(a, 3)
    c = mul(b, 7)
    d = mul(b, 7)
    e = sub(c, 3)
    f = sub(c, 5)

    set_global_provenance(c._workflow, base())

    assert c._workflow.prov is not None
    assert b._workflow.prov is not None
    assert c._workflow.prov != b._workflow.prov

    set_global_provenance(d._workflow, base())
    set_global_provenance(e._workflow, base())
    set_global_provenance(f._workflow, base())

    assert c._workflow.prov == d._workflow.prov
    assert b._workflow.prov != e._workflow.prov
    assert f._workflow.prov != e._workflow.prov
示例#12
0
def test_prov_04():
    db_file = "prov3.json"

    A = add2(1, 1)
    B = sub(3, A)

    multiples = [mul(add2(i, B), A) for i in range(6)]
    C = accumulate(gather(*multiples))

    result = run_parallel_opt(C, 4, serial.base, db_file)
    assert result == 42
    os.unlink(db_file)
示例#13
0
def test_global_prov():
    a = add(4, 5)
    b = sub(a, 3)
    c = mul(b, 7)
    d = mul(b, 7)
    e = sub(c, 3)
    f = sub(c, 5)

    set_global_provenance(c._workflow, base())

    assert c._workflow.prov is not None
    assert b._workflow.prov is not None
    assert c._workflow.prov != b._workflow.prov

    set_global_provenance(d._workflow, base())
    set_global_provenance(e._workflow, base())
    set_global_provenance(f._workflow, base())

    assert c._workflow.prov == d._workflow.prov
    assert b._workflow.prov != e._workflow.prov
    assert f._workflow.prov != e._workflow.prov
示例#14
0
def test_prov_03():
    db_file = "prov2.json"

    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(gather(*multiples))

    result = run_parallel(C, 4, serial.base, db_file, JobKeeper(keep=True))
    assert result == 42
    os.unlink(db_file)
示例#15
0
def test_prov_00():
    reg = serial.base()
    a = add(3, 4)
    b = sub(3, 4)
    c = add(3, 4)
    d = add(4, 3)

    enc = [reg.deep_encode(x._workflow.root_node) for x in [a, b, c, d]]
    key = [prov_key(o) for o in enc]
    assert key[0] == key[2]
    assert key[1] != key[0]
    assert key[3] != key[0]
示例#16
0
def test_prov_02():
    db_file = "prov1.json"

    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = accumulate(gather(*multiples))

    result = run_single(C, serial.base, db_file)
    assert result == 42
    os.unlink(db_file)
示例#17
0
def test_xenon_42_simple(xenon_server):
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = schedule(sum)(gather_all(multiples))

    machine = Machine()
    worker_config = XenonJobConfig(verbose=True)

    result = run_xenon_simple(C, machine=machine, worker_config=worker_config)

    assert (result == 42)
示例#18
0
def test_get_intermediate_results():
    r1 = add(1, 1)
    r2 = sub(3, r1)

    def foo(a, b, c):
        return mul(add(a, b), c)

    r3 = [foo(i, r2, r1) for i in range(6)]
    r4 = accumulate(noodles.gather_all(r3))

    run_single(r4)

    assert noodles.result(r1) == 2
    assert noodles.result(r2) == 1
    assert [noodles.result(r) for r in r3] == [2, 4, 6, 8, 10, 12]
    assert noodles.result(r4) == 42
示例#19
0
def test_xenon_42_multi(xenon_server):
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    C = schedule(sum)(gather_all(multiples))

    machine = Machine()
    worker_config = XenonJobConfig(queue_name='multi', verbose=True)

    result = run_xenon(C,
                       machine=machine,
                       worker_config=worker_config,
                       n_processes=2)

    assert (result == 42)
示例#20
0
def test_add_job():
    db = JobDB(':memory:', registry=serial.base)

    wf = sub(1, 1)
    job = Job(wf._workflow, wf._workflow.root)
    key, node = db.register(job)
    msg, value = db.add_job_to_db(key, node)
    assert msg == 'initialized'

    duplicates = db.store_result_in_db(ResultMessage(key, 'done', 0, None))
    assert duplicates == ()

    key, node = db.register(job)
    msg, result = db.add_job_to_db(key, node)
    assert msg == 'retrieved'
    assert result.value == 0
示例#21
0
def test_xenon_42():
    A = log_add(1, 1)
    B = sub(3, A)

    multiples = [mul(log_add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    xenon_config = XenonConfig(jobs_scheme='local')

    job_config = RemoteJobConfig(registry=serial.base, time_out=1000)

    with XenonKeeper() as Xe, NCDisplay() as display:
        result = run_xenon(C,
                           Xe,
                           "cache.json",
                           2,
                           xenon_config,
                           job_config,
                           display=display)

    assert (result == 42)
示例#22
0
def test_xenon_42():
    A = log_add(1, 1)
    B = sub(3, A)

    multiples = [mul(log_add(i, B), A) for i in range(6)]
    C = accumulate(noodles.gather(*multiples))

    xenon_config = XenonConfig(
        jobs_scheme='local'
    )

    job_config = RemoteJobConfig(
        registry=serial.base,
        time_out=1000
    )

    with XenonKeeper() as Xe, NCDisplay() as display:
        result = run_xenon(
            C, Xe, "cache.json", 2, xenon_config, job_config,
            display=display)

    assert(result == 42)
示例#23
0
def test_truthfulness():
    w = sub(4, add(3, 2))
    a = cond(True, w, should_not_run())
    b = cond(False, should_not_run(), w)
    result = run_single(mul(a, b))
    assert result == 1
示例#24
0
def test_truthfulness():
    w = sub(4, add(3, 2))
    a = cond(True, w, should_not_run())
    b = cond(False, should_not_run(), w)
    result = run_single(mul(a, b))
    assert result == 1
示例#25
0
文件: minimal.py 项目: NLeSC/noodles
from noodles.tutorial import (add, sub, mul)
from draw_workflow import draw_workflow

u = add(5, 4)
v = sub(u, 3)
w = sub(u, 2)
x = mul(v, w)

draw_workflow("callgraph-a.pdf", x._workflow)

示例#26
0
from noodles.tutorial import (add, sub, mul)
from noodles.draw_workflow import draw_workflow

u = add(5, 4)
v = sub(u, 3)
w = sub(u, 2)
x = mul(v, w)

draw_workflow("callgraph-a.pdf", x._workflow)
示例#27
0
def truthfulness():
    w = sub(4, add(3, 2))
    a = cond(True, w, should_not_run())
    b = cond(False, should_not_run(), w)
    return mul(a, b)
示例#28
0
def lift_object():
    a = A()
    a.x = add(1, 2)
    a.y = sub(9, 11)
    return f(noodles.lift(a))
示例#29
0
文件: run.py 项目: cwmeijer/noodles
def test_42():
    A = add(1, 1)
    B = sub(3, A)

    multiples = [mul(add(i, B), A) for i in range(6)]
    return accumulate(noodles.gather(*multiples))