File: test_pipeline.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 (35 lines) | stat: -rw-r--r-- 848 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
import argparse

import pytest

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


@python_app
def increment(x):
    return x + 1


@python_app
def slow_increment(x):
    import time
    time.sleep(0.001)
    return x + 1


@pytest.mark.parametrize("depth", (2, 3))
def test_increment(depth):
    """Test simple pipeline A->B...->N"""
    futs = [increment(0)]
    futs.extend(increment(futs[i - 1]) for i in range(1, depth))
    assert sum(f.result() for f in futs) == sum(range(1, depth + 1))


@pytest.mark.parametrize("depth", (2, 3))
def test_increment_slow(depth):
    """Test simple pipeline A->B...->N with delay"""
    futs = [slow_increment(0)]
    futs.extend(slow_increment(futs[i - 1]) for i in range(1, depth))
    assert sum(f.result() for f in futs) == sum(range(1, depth + 1))