コード例 #1
0
def test_runjobs(tmpdir):
    p21 = Proc()
    p21.forks = 3
    p21.input = 'a, b'
    p21.input = [(1, 2), (3, 4), (5, 6)]
    p21.output = 'a:{{i.a}}, b:{{i.b}}'
    p21.script = 'echo Hello world!'
    p21._preRunTidy()
    p21._runJobs()
    assert p21.channel == [('1', '2'), ('3', '4'), ('5', '6')]
    assert p21.channel.a.flatten() == ['1', '3', '5']
    assert p21.channel.b.flatten() == ['2', '4', '6']
コード例 #2
0
def test_postruntidy(tmpdir, caplog):
    p22 = Proc()
    p22.resume = 'skip+'
    p22.callback = lambda p: p.props.update({'channel': p.channel.cbind(1, 2)})
    p22._postRunTidy()
    assert p22.channel == [(1, 2)]

    p23 = Proc()
    p23.forks = 5
    p23.input = 'a, b'
    p23.input = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
    p23.output = 'a:{{i.a}}, b:{{i.b}}'
    p23.script = 'echo Hello world!'
    p23.errhow = 'ignore'
    p23.callback = lambda p: setattr(p, 'forks', 10)
    p23._preRunTidy()
    p23._runJobs()
    p23.jobs[0].state = STATES.BUILTFAILED
    p23.jobs[1].state = STATES.SUBMITFAILED
    p23.jobs[2].state = STATES.DONE
    p23.jobs[3].state = STATES.DONECACHED
    p23.jobs[4].state = STATES.ENDFAILED
    p23._postRunTidy()
    assert ' Jobs (Cached: 1, Succ: 1, B.Fail: 1, S.Fail: 1, R.Fail: 1)' in caplog.text
    assert 'Failed but ignored (totally 3).' in caplog.text
    assert p23.forks == 10

    p23.errhow = 'terminate'
    caplog.clear()
    with pytest.raises(SystemExit):
        p23._postRunTidy()
    assert 'Cached: 4' in caplog.text
    assert 'Succeeded: 3' in caplog.text
    assert 'Building failed: 1' in caplog.text
    assert 'Submission failed: 2' in caplog.text
    assert 'Running failed: 5' in caplog.text