File: test_tutorial_1.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 (46 lines) | stat: -rw-r--r-- 1,437 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
import argparse

import pytest

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

local_config = config


@bash_app
def sim_mol_dyn(i, dur, outputs=[], stdout=None, stderr=None):
    # The bash app function, requires that the bash script is assigned to the special variable
    # cmd_line. Positional and Keyword args to the fn() are formatted into the cmd_line string
    cmd_line = """echo "{0}" > {outputs[0]}
    sleep {1};
    ls ;
    """
    return cmd_line


@pytest.mark.skip('hangs in pytest')
def test_data_future_result():
    """Testing the behavior of a result call on DataFutures
    """
    # We call sim_mol_dyn with
    sim_fut = sim_mol_dyn(5, 0, outputs=['sim.out'],
                          stdout='stdout.txt', stderr='stderr.txt')
    data_futs = sim_fut.outputs
    print("Launching and waiting on data_futs")
    print("Done?   : ", data_futs[0].done())
    print("Result? : ", data_futs[0].result(timeout=1))


@pytest.mark.skip('hangs in pytest')
def test_app_future_result():
    """Testing the behavior of a result call on AppFutures
    """
    # We call sim_mol_dyn with
    sim_fut = sim_mol_dyn(5, 0.5, outputs=['sim.out'],
                          stdout='stdout.txt', stderr='stderr.txt')
    sim_fut.outputs
    print("Launching and waiting on data_futs")
    print("Done?   : ", sim_fut.done())
    print("Result? : ", sim_fut.result(timeout=1))