Example #1
0
def _test_workflow_chain(scheduler, wf_scheduler):
    from wowp.actors import FuncActor
    from wowp.actors.mapreduce import PassWID
    import math
    import random
    import six

    sin = FuncActor(math.sin)
    asin = FuncActor(math.asin)
    # first workflow
    asin.inports['inp'] += sin.outports['out']
    wf1 = sin.get_workflow()
    # second workflow
    passwid = PassWID()
    wf2 = passwid.get_workflow()
    # connect the two workflows
    wf2.inports['inp'] += wf1.outports['out']

    wf1.scheduler = wf_scheduler
    wf2.scheduler = wf_scheduler

    inp = random.random()
    scheduler.run_workflow(wf1, inp=inp)
    res1 = wf1.outports['out'].pop_all()
    res2 = wf2.outports['out'].pop_all()
    # wf1 wmpty output
    assert not res1
    # wf2 has output
    assert res2
    assert len(res2) == 1
    if six.PY3:
        assert math.isclose(res2[0]['inp'], inp)
    else:
        assert math.fabs(res2[0]['inp'] - inp) < 1e-10
Example #2
0
def test_map_linear():
    ra = FuncActor(range)
    func = math.sin
    map_act = Map(FuncActor, args=(func, ))
    map_act.inports['inp'] += ra.outports['out']

    wf = ra.get_workflow()
    sch = LinearizedScheduler()

    inp = 5
    sch.run_workflow(wf, inp=inp)
    result = wf.outports.out.pop_all()
    assert len(result) == 1
    assert all((a, b) for a, b in zip_longest(result[0], map(func, range(inp))))
Example #3
0
def _call_workflow(scheduler, wf_scheduler):
    if (isinstance(scheduler, ThreadedScheduler)
            or isinstance(wf_scheduler, ThreadedScheduler)):
        # skip temporarily
        raise nose.SkipTest

    import math
    sin = FuncActor(math.sin)
    asin = FuncActor(math.asin)

    asin.inports['inp'] += sin.outports['out']

    wf = sin.get_workflow()
    wf.scheduler = wf_scheduler

    x = math.pi / 2
    res = wf(scheduler=scheduler, inp=x)
    assert res['out'].pop() == math.asin(math.sin(x))
Example #4
0
def _run_workflow(scheduler, wf_scheduler):
    if (isinstance(scheduler, ThreadedScheduler)
            or isinstance(wf_scheduler, ThreadedScheduler)):
        # skip temporarily
        raise nose.SkipTest

    import math
    sin = FuncActor(math.sin)
    asin = FuncActor(math.asin)

    asin.inports['inp'] += sin.outports['out']

    wf = sin.get_workflow()
    wf.scheduler = wf_scheduler

    x = math.pi / 2
    scheduler.run_workflow(wf, inp=x)
    res = {port.name: port.pop_all() for port in wf.outports}
    assert res['out'].pop() == math.asin(math.sin(x))
Example #5
0
from wowp.actors import FuncActor
import math

sin = FuncActor(math.sin)
asin = FuncActor(math.asin)

asin.inports['inp'] += sin.outports['out']

WORKFLOW = sin.get_workflow()

INPUTS = {
    'inp': math.pi / 2
}