File: test_memoize_ignore_args.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 (30 lines) | stat: -rw-r--r-- 739 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
from parsl.app.app import python_app


@python_app(cache=True, ignore_for_cache=[])
def random_uuid(x):
    import uuid
    return str(uuid.uuid4())


@python_app(cache=True, ignore_for_cache=['x'])
def random_uuid_def(x):
    import uuid
    return str(uuid.uuid4())


def test_memo_different():
    # explicitly call result() before launching next app so that
    # the executions are serialized and the x result will be in
    # memo table
    x = random_uuid(x=0).result()
    y = random_uuid(x=1).result()

    assert x != y, "Memoized results were used incorrectly"


def test_memo_same_at_definition():
    x = random_uuid_def(x=0).result()
    y = random_uuid_def(x=1).result()

    assert x == y, "Memoized results were not used"