def test_cacherun_output_prefix_change(self): _ = ''' if the output files to a simple node changed trigger a recalc ''' tups = ( prefix_job, self.DIR / 'root', '/tmp/digit', ) node = force_run(*tups, verbose=0) output_changed = cache_check_changed(*tups, verbose=0, check_changed=1)[1] assert output_changed == 0 ofname = node.output.out_prefix + '.%d' % 0 # from spiper.runner import os_stat_safe # print(os_stat_safe(ofname)) import time time.sleep(0.1) Path(ofname).touch() output_changed = cache_check_changed(*tups, verbose=0)[1] assert output_changed == 1, node
def test_http_job(self): if self.LEVEL < 1: return # from spiper._types import HttpResponseCheckLength tups = (http_job1, self.DIR / 'test_http_job') cache_run_verbose(*tups) res = cache_check_changed(*tups) assert res[0] == 0 tups = (http_job2, self.DIR / 'test_http_job') res = cache_run_verbose(*tups) res = cache_check_changed(*tups) assert res[0] == 1
def test_cacherun_code_change(self): _ = ''' the defition of a script change is ambiguous here we used a tuple to identify a function ( func_code.co_code func_code.co_consts ) ''' tups = (simple_job, self.DIR / 'root', 'ATG', '/tmp/digit.txt') force_run(*tups, verbose=0) input_changed = cache_check_changed(*tups, verbose=0, check_changed=1)[0] assert input_changed == 0 tups = (self.change_job(), self.DIR / 'root', 'ATG', '/tmp/digit.txt') input_changed = cache_check_changed(*tups, verbose=0)[0] assert input_changed == 1
def test_cacherun_output_change(self): _ = ''' if the output files to a simple node changed trigger a recalc ''' tups = (simple_job, self.DIR / 'root', 'ATG', '/tmp/digit.txt') force_run(*tups, verbose=0) output_changed = cache_check_changed(*tups, verbose=0)[1] assert output_changed == 0 ofname = self.DIR / 'root.simple_job.out_txt' # from spiper.runner import os_stat_safe # print(os_stat_safe(ofname)) import time time.sleep(0.1) # subprocess.check_output(['touch','-m',ofname]) # with open(ofname,'w') as f: # pass Path(ofname).touch() # print(os_stat_safe(ofname)) output_changed = cache_check_changed(*tups, verbose=0)[1] assert output_changed == 1
def test_cacherun_input_change(self): _ = ''' if the input files / params to a simple node changed, then trigger a recalc ''' tups = (simple_job, self.DIR / 'root', 'ATG', '/tmp/digit.txt') force_run(*tups, verbose=0) input_changed = cache_check_changed(*tups, verbose=0)[0] assert input_changed == 0 import time time.sleep(0.1) Path(tups[-1]).touch() input_changed = cache_check_changed(*tups, verbose=0)[0] assert input_changed == 1 tups = (simple_job, self.DIR / 'root', 'ATG', '/tmp/digit.txt') force_run(*tups, verbose=0) input_changed = cache_check_changed(*tups, verbose=0)[0] assert input_changed == 0 tups = (simple_job, self.DIR / 'root', 'ATGC', '/tmp/digit.txt') input_changed = cache_check_changed(*tups, verbose=0)[0] assert input_changed == 1