File: test_from_slides.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 (33 lines) | stat: -rw-r--r-- 698 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
import os

import pytest

from parsl.app.app import bash_app, python_app
from parsl.data_provider.files import File


@bash_app
def echo(message, outputs=[]):
    return 'echo {m} &> {o}'.format(m=message, o=outputs[0])


@python_app
def cat(inputs=[]):
    with open(inputs[0].filepath) as f:
        return f.readlines()


@pytest.mark.staging_required
def test_slides():
    """Testing code snippet from slides """

    if os.path.exists('hello1.txt'):
        os.remove('hello1.txt')

    hello = echo("Hello World!", outputs=[File('hello1.txt')])

    message = cat(inputs=[hello.outputs[0]])

    # Waits. This need not be in the slides.
    print(hello.result())
    print(message.result())