MCPcopy Index your code
hub / github.com/pathwaycom/pathway / test_apply_async_disk_cache

Function test_apply_async_disk_cache

python/pathway/tests/test_common.py:1950–1993  ·  view source on GitHub ↗
(tmp_path: pathlib.Path)

Source from the content-addressed store, hash-verified

1948
1949
1950def test_apply_async_disk_cache(tmp_path: pathlib.Path):
1951 cache_dir = tmp_path / "test_cache"
1952 counter = mock.Mock()
1953
1954 @pw.udfs.async_options(cache_strategy=pw.udfs.DiskCache())
1955 def inc(x: int) -> int:
1956 counter()
1957 return x + 1
1958
1959 input = T(
1960 """
1961 foo
1962 1
1963 2
1964 3
1965 """
1966 )
1967 result = input.select(ret=pw.apply_async(inc, pw.this.foo))
1968 expected = T(
1969 """
1970 ret
1971 2
1972 3
1973 4
1974 """
1975 )
1976
1977 # run twice to check if cache is used
1978 assert_table_equality(
1979 result,
1980 expected,
1981 persistence_config=pw.persistence.Config(
1982 pw.persistence.Backend.filesystem(cache_dir),
1983 ),
1984 )
1985 assert_table_equality(
1986 result,
1987 expected,
1988 persistence_config=pw.persistence.Config(
1989 pw.persistence.Backend.filesystem(cache_dir),
1990 ),
1991 )
1992 assert os.path.exists(cache_dir)
1993 assert counter.call_count == 3
1994
1995
1996def test_empty_join():

Callers

nothing calls this directly

Calls 3

TFunction · 0.90
filesystemMethod · 0.80
selectMethod · 0.45

Tested by

no test coverage detected