File: test_69a.py

package info (click to toggle)
python-parsl 2025.01.13%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,072 kB
  • sloc: python: 23,817; makefile: 349; sh: 276; ansic: 45
file content (68 lines) | stat: -rw-r--r-- 1,902 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'''
Regression tests for issue #69
'''
import pytest

from parsl.app.app import bash_app, python_app
from parsl.tests.configs.local_threads import config

local_config = config


@bash_app
def echo_slow_message(msg, sleep=0, fu=None, outputs=[], stderr='std.err', stdout='std.out'):
    cmd_line = 'sleep {sleep}; echo {0} > {outputs[0]}'
    return cmd_line


@python_app
def sleep(sleep_dur=0.1):
    import time
    time.sleep(sleep_dur)
    return True


@pytest.mark.skip('fails in pytest')
def test_immediate_datafuture():
    """Test DataFuture string representation, for AppFutures launched with parent
    """

    import time
    fu = echo_slow_message("Hello world", sleep=1, outputs=["hello.1.txt"])
    d_fu = fu.outputs[0]

    time.sleep(0.1)
    state_2 = d_fu.__str__()
    print("State_2 : ", state_2, "Fu:", fu.parent)
    assert "running" in state_2, "DataFuture should now be running"

    d_fu.result()
    state_3 = d_fu.__str__()
    print("State_3 : ", state_3, "Fu:", fu.parent)
    assert "finished" in state_3, "DataFuture should now be finished"


@pytest.mark.skip('fails in pytest')
def test_delayed_datafuture():
    """Test DataFuture string representation, for AppFutures with delayed parent
    """

    import time
    sleep_fu = sleep()

    fu = echo_slow_message("Hello world", sleep=1, fu=sleep_fu,
                           outputs=["hello.1.txt"])
    d_fu = fu.outputs[0]
    state_1 = d_fu.__str__()
    print("State_1 : ", state_1, "Fu:", fu.parent)
    assert "pending" in state_1, "DataFuture should now be pending"

    time.sleep(0.2)
    state_2 = d_fu.__str__()
    print("State_2 : ", state_2, "Fu:", fu.parent)
    assert "running" in state_2, "DataFuture should now be running"

    d_fu.result()
    state_3 = d_fu.__str__()
    print("State_3 : ", state_3, "Fu:", fu.parent)
    assert "finished" in state_3, "DataFuture should now be finished"