File: test_pack_resource_spec.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 (23 lines) | stat: -rw-r--r-- 641 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
import pytest

from parsl.serialize import pack_res_spec_apply_message, unpack_res_spec_apply_message


def double(x: int, y: int = 2) -> int:
    return x * y


@pytest.mark.local
def test_pack_and_unpack():
    args = (5,)
    kwargs = {'y': 10}
    resource_spec = {'num_nodes': 4}
    packed = pack_res_spec_apply_message(double, args, kwargs, resource_specification=resource_spec)

    unpacked = unpack_res_spec_apply_message(packed)
    assert len(unpacked) == 4
    u_fn, u_args, u_kwargs, u_res_spec = unpacked
    assert u_fn == double
    assert u_args == args
    assert u_kwargs == kwargs
    assert u_res_spec == resource_spec