File: test_execute_task.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 (29 lines) | stat: -rw-r--r-- 816 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
import os

import pytest

from parsl.executors.execute_task import execute_task
from parsl.serialize.facade import pack_res_spec_apply_message


def addemup(*args: int, name: str = "apples"):
    total = sum(args)
    return f"{total} {name}"


@pytest.mark.local
def test_execute_task():
    args = (1, 2, 3)
    kwargs = {"name": "boots"}
    buff = pack_res_spec_apply_message(addemup, args, kwargs, {})
    res = execute_task(buff)
    assert res == addemup(*args, **kwargs)


@pytest.mark.local
def test_execute_task_resource_spec():
    resource_spec = {"num_nodes": 2, "ranks_per_node": 2, "num_ranks": 4}
    buff = pack_res_spec_apply_message(addemup, (1, 2), {}, resource_spec)
    execute_task(buff)
    for key, val in resource_spec.items():
        assert os.environ[f"PARSL_{key.upper()}"] == str(val)