def inner(): o = Dummy() ppg.CachedAttributeLoadingJob("x", o, "a", "shu")
def inner(): o = Dummy() ppg.CachedAttributeLoadingJob(55, o, "c", lambda: 55)
def inner(): o = Dummy() ppg.CachedAttributeLoadingJob("out/C", o, 354, lambda: 55)
def inner(): ppg.CachedAttributeLoadingJob(5, o, "a", lambda: 55)
def inner(): ppg.CachedAttributeLoadingJob("out/A", o2, "a", cache)
def test_accepts(self): import pathlib write("aaa", "hello") write("bbb", "hello") write("ccc", "hello") a = ppg.FileTimeInvariant(pathlib.Path("aaa")) a1 = ppg.MultiFileInvariant([pathlib.Path("bbb"), "ccc"]) b = ppg.FileGeneratingJob( pathlib.Path("b"), lambda of: write(of, "bb" + read("aaa") + read("bbb") + read("ccc") ), ) b.depends_on(a) b.depends_on(a1) dd = Dummy() def mf(): write("c", "cc" + read("g")) write("d", "dd" + read("h") + dd.attr) write("e", "ee" + read("i") + read("j")) c = ppg.MultiFileGeneratingJob( [pathlib.Path("c"), "d", pathlib.Path("e")], mf) c.depends_on(b) d = ppg.FunctionInvariant(pathlib.Path("f"), lambda x: x + 1) c.depends_on(d) e = ppg.ParameterInvariant(pathlib.Path("c"), "hello") c.depends_on(e) f = ppg.TempFileGeneratingJob(pathlib.Path("g"), lambda: write("g", "gg")) c.depends_on(f) def tmf(): write("h", "hh") write("i", "ii") g = ppg.MultiTempFileGeneratingJob([pathlib.Path("h"), "i"], tmf) c.depends_on(g) def tpf(): write("j", "jjjj") write("k", "kkkk") h = ppg.TempFilePlusGeneratingJob(pathlib.Path("j"), pathlib.Path("k"), tpf) c.depends_on(h) i = ppg.CachedDataLoadingJob(pathlib.Path("l"), lambda: write("l", "llll"), lambda res: res) c.depends_on(i) m = ppg.CachedAttributeLoadingJob(pathlib.Path("m"), dd, "attr", lambda: "55") c.depends_on(m) ppg.run_pipegraph() assert read("aaa") == "hello" assert read("b") == "bbhellohellohello" assert read("c") == "ccgg" assert read("d") == "ddhh55" assert read("e") == "eeiijjjj" assert not (os.path.exists("g")) assert not (os.path.exists("h")) assert not (os.path.exists("i")) assert not (os.path.exists("j")) assert read("k") == "kkkk"
def inner(): ppg.CachedAttributeLoadingJob("out/a", o, "a", 55)
def test_use_cores(self): o = Dummy() ca = ppg.CachedAttributeLoadingJob("out/C", o, "c", lambda: 55) assert ca.use_cores(5) is ca assert ca.lfg.cores_needed == 5
def inner(): o = Dummy() ppg.CachedAttributeLoadingJob(123, o, "a", lambda: 123)
def test_depends_on_returns_self(self): o = Dummy() jobA = ppg.CachedAttributeLoadingJob("out/A", o, "shu", lambda: write("out/A", "shu")) jobB = ppg.FileGeneratingJob("out/B", lambda: write("out/B", "shu")) assert jobA.depends_on(jobB) is jobA
def test_throws_on_non_function_func(self): o = Dummy() with pytest.raises(ValueError): ppg.CachedAttributeLoadingJob("out/mycalc", lambda: 5, o, "a") # wrong argument order
def load_data(self): cf = Path(ppg.util.global_pipegraph.cache_folder) / "FastTagCounters" cf.mkdir(exist_ok=True) return (ppg.CachedAttributeLoadingJob( cf / self.cache_name, self, "_data", self.calc_data).depends_on(self.aligned_lane.load()).use_cores(-1))