def test_cli(self): Path('/tmp/test_remote/').rmtree_p() stdout = LoggedShellCommand([ 'python3','-m','spiper run', 'spiper_mock_flow@https://github.com/shouldsee/spiper_mock_flow/tarball/8b01372', 'TOPLEVEL:run_and_backup', '/tmp/test_remote/root','1','2','/tmp/test_remote/root.backup' ]) assert '[workflow]done' in stdout.splitlines()[-1]
def tarball_dangerous_cache(self,prefix, input_prefix = File, _output=[ File('tar_gz'), File('cmd')]): with input_prefix.dirname(): stdout = LoggedShellCommand([ 'tar', '-cvzf', self.output.tar_gz, input_prefix.basename()+'*', ], self.output.cmd) return self
def workflow(self, prefix, seed =int , L=int, _output = [ File('log'), ]): print('\n[Flow running] mock=%s'%getattr(self.runner.func,'__name__','None')) curr = self.runner(random_seq, prefix, seed, L) curr1 = self.config_runner(tag='const')(random_seq, prefix, 0, 100) curr = self.runner(transcribe, prefix, curr.output.seq,) curr = self.runner(mutate, prefix, curr.output.fasta) stdout = LoggedShellCommand(['ls -lhtr',prefix.dirname()], self.output.log).rstrip() self.runner(copy_file, prefix+'.source.py', __file__) return self
def get_genepred(self,prefix, _resp = spiper.types.HttpResponseContentHeader('https://hgdownload.soe.ucsc.edu/goldenPath/currentGenomes/Wuhan_seafood_market_pneumonia_virus/database/ncbiGene.txt.gz'), _IMAGE = Depend('docker://quay.io/biocontainers/ucsc-genepredtogtf:377--h35c10e6_2'), _output = ['genepred','gtf','cmd'], ): CMD = ['curl','-LC0',_resp.url, '|','gzip -d | cut -f2- >',self.output.genepred, ] LoggedShellCommand(CMD, self.output.cmd,mode='w') CMD = ['genePredToGtf','file',self.output.genepred, self.output.gtf] LoggedSingularityCommand(CMD, _IMAGE, self.output.cmd,mode='a')
def workflow(self, prefix, seed =int , L=int, _output = [ File('log'), ]): _ = ''' A workflow is not a Node() ''' print('\n[Flow running] mock=%s'%getattr(self.runner.func,'__name__','None')) ### [ToDo] (func, prefix) must be unique within each workflow # self.data = {} curr = self.runner(random_seq, prefix, seed, L) curr1 = self.config_runner(tag='temp')(random_seq, prefix, 0, 100) curr = self.runner(transcribe, prefix, curr.output.seq,) curr = self.runner(mutate, prefix, curr.output.fasta) stdout = LoggedShellCommand(['ls -lhtr',prefix.dirname()],).rstrip() return self
def main(force_run=force_run,prefix=None): # spiper.rcParams['dir_layout'] = dir_layout if prefix is None: prefix = Path('/tmp/spiper.test_run/root') prefix.dirname().rmtree_p() print('\n---------------------Run1---\n## got') if __name__ == '__main__' else None res1 = force_run(gen_files, prefix,verbose=0) res2 = force_run(tarball_dangerous_cache, prefix, res1.prefix_named, verbose=1) res1 = force_run(gen_files, prefix,verbose=0) res2 = force_run(tarball_dangerous_cache, prefix, res1.prefix_named, verbose=1) s = ''' ## expect [cache_run] {"job_name"="tarball_dangerous_cache"_"input_ident_changed"=1_"output_ident_chanegd"=0} * This change to input is ignored because tarball_dangerous_cache(input_prefix=File) would not expand to match the files during input validation The type specified in def line will be used for detecting a timestamp/filesize change '''.strip() print(s) if __name__ == '__main__' else None print('---------------------Run2---\n## got') if __name__ == '__main__' else None res1 = force_run(gen_files, prefix) res2 = force_run(tarball_prefix_cache, prefix, res1.prefix_named, verbose=1) res1 = force_run(gen_files, prefix) res2 = force_run(tarball_prefix_cache, prefix, res1.prefix_named, verbose=1) s = ''' ## expect [cache_run] {"job_name"="tarball_prefix_cache"_"input_ident_changed"=1_"output_ident_chanegd"=0} * Because tarball_prefix_cache(input_prefix=Prefix) is expanded into the appropriate files during input validation. * Note that the Prefix only expands into a shallow match and does not recurse into sub-directory during input validation '''.strip() print(s) if __name__ == '__main__' else None print('------Output Directory. (dir_layout={spiper.rcParams.dir_layout})--------\n'.format(spiper=spiper), LoggedShellCommand(['echo [ls]',prefix,'&&','ls','-lhtr',prefix.dirname(),],'/dev/null')) return res1,res2
def make_tar( self, prefix, input_file=File, _output=['tar_gz'] ): with input_file.dirname() as d: print('taring %r'%d) stdout = LoggedShellCommand(['tar','-zvcf',self.output.tar_gz, '*'], '/dev/null') return self