def test_copy(): h1 = HighLevelGraph( {"a": {"a": "b"}, "b": {"b": 1}}, {"a": {"b"}, "b": set()}, ) h1.get_all_dependencies() assert h1.key_dependencies h2 = h1.copy() for k in ("layers", "dependencies", "key_dependencies"): v1 = getattr(h1, k) v2 = getattr(h2, k) assert v1 is not v2 assert v1 == v2
async def test_pack_MaterializedLayer_handles_futures_in_graph_properly( c, s, a, b): fut = c.submit(inc, 1) hlg = HighLevelGraph( { "l1": MaterializedLayer({ "x": fut, "y": (inc, "x"), "z": (inc, "y") }) }, {"l1": set()}, ) # fill hlg.key_dependencies cache. This excludes known futures, so only # includes a subset of all dependencies. Previously if the cache was present # the future dependencies would be missing when packed. hlg.get_all_dependencies() packed = hlg.__dask_distributed_pack__(c, ["z"], {}) unpacked = HighLevelGraph.__dask_distributed_unpack__(packed) assert unpacked["deps"] == {"x": {fut.key}, "y": {fut.key}, "z": {"y"}}