File: test_callables.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 (71 lines) | stat: -rw-r--r-- 1,974 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
69
70
71
# this file contains some tests of passing complicated
# callables as parameters to apps, mainly to check that
# they are serialised correctly with serialization based
# executors.

import importlib
import pathlib
from functools import partial

import parsl


@parsl.python_app
def app(x):
    return True


def test_check_base_app():
    app(0).result()


def somefunc(*args):
    pass


def test_check_this_module_function():
    app(somefunc).result()


def test_check_this_module_function_partial():
    app(partial(somefunc, 1)).result()


def test_check_import_module_function():
    from parsl.tests.callables_helper import some_aux_func
    app(some_aux_func).result()


def test_check_import_module_function_partial():
    from parsl.tests.callables_helper import some_aux_func
    app(partial(some_aux_func, 1)).result()


def test_check_importlib_file_function():
    helper_path = pathlib.Path(__file__).parent / "callables_helper.py"
    spec = importlib.util.spec_from_file_location("dynamically_loaded_module", helper_path)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    some_aux_func = module.some_aux_func
    app(some_aux_func).result()


def test_check_importlib_file_function_partial():
    helper_path = pathlib.Path(__file__).parent / "callables_helper.py"
    spec = importlib.util.spec_from_file_location("dynamically_loaded_module", helper_path)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    some_aux_func = module.some_aux_func
    app(partial(some_aux_func, 1)).result()


def test_check_importlib_module_function():
    module = importlib.import_module("parsl.tests.callables_helper")
    some_aux_func = module.some_aux_func
    app(some_aux_func).result()


def test_check_importlib_module_partial():
    module = importlib.import_module("parsl.tests.callables_helper")
    some_aux_func = module.some_aux_func
    app(partial(some_aux_func, 1)).result()