comparison toolfactory/rgToolFactory2.py @ 50:bf432f4486c7 draft

Uploaded
author fubar
date Sun, 30 Aug 2020 01:45:27 -0400
parents 35a912ce0c83
children 4b71b252eacb
comparison
equal deleted inserted replaced
49:35a912ce0c83 50:bf432f4486c7
21 # essential problem is to create two command lines - one for the tool xml and a different 21 # essential problem is to create two command lines - one for the tool xml and a different
22 # one to run the executable with the supplied test data and settings 22 # one to run the executable with the supplied test data and settings
23 # Be simpler to write the tool, then run it with planemo and soak up the test outputs. 23 # Be simpler to write the tool, then run it with planemo and soak up the test outputs.
24 24
25 25
26
27 import argparse 26 import argparse
28 import logging 27 import logging
29 import os 28 import os
30 import re 29 import re
31 import shutil 30 import shutil
45 myversion = "V2.1 July 2020" 44 myversion = "V2.1 July 2020"
46 verbose = True 45 verbose = True
47 debug = True 46 debug = True
48 toolFactoryURL = "https://github.com/fubar2/toolfactory" 47 toolFactoryURL = "https://github.com/fubar2/toolfactory"
49 ourdelim = "~~~" 48 ourdelim = "~~~"
50 ALOT = 10000000 # srsly. command or test overrides use read() so just in case 49 ALOT = 10000000 # srsly. command or test overrides use read() so just in case
51 STDIOXML = """<stdio> 50 STDIOXML = """<stdio>
52 <exit_code range="100:" level="debug" description="shite happens" /> 51 <exit_code range="100:" level="debug" description="shite happens" />
53 </stdio>""" 52 </stdio>"""
54 53
55 # --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label 54 # --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label
170 "argparse", 169 "argparse",
171 "positional", 170 "positional",
172 ], 'args.parampass must be "0","positional" or "argparse"' 171 ], 'args.parampass must be "0","positional" or "argparse"'
173 self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name) 172 self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name)
174 self.tool_id = self.tool_name 173 self.tool_id = self.tool_name
175 self.tool = gxt.Tool( 174 self.newtool = gxt.Tool(
176 self.args.tool_name, 175 self.args.tool_name,
177 self.tool_id, 176 self.tool_id,
178 self.args.tool_version, 177 self.args.tool_version,
179 self.args.tool_desc, 178 self.args.tool_desc,
180 FAKEEXE, 179 FAKEEXE,
181 ) 180 )
182 if self.args.script_path:
183 self.tool.interpreter = self.executeme
184 self.tooloutdir = "tfout" 181 self.tooloutdir = "tfout"
185 self.repdir = "TF_run_report_tempdir" 182 self.repdir = "TF_run_report_tempdir"
186 self.testdir = os.path.join(self.tooloutdir, "test-data") 183 self.testdir = os.path.join(self.tooloutdir, "test-data")
187 if not os.path.exists(self.tooloutdir): 184 if not os.path.exists(self.tooloutdir):
188 os.mkdir(self.tooloutdir) 185 os.mkdir(self.tooloutdir)
203 if self.args.test_override: 200 if self.args.test_override:
204 stos = open(self.args.test_override, "r").readlines() 201 stos = open(self.args.test_override, "r").readlines()
205 self.test_override = [x.rstrip() for x in stos] 202 self.test_override = [x.rstrip() for x in stos]
206 else: 203 else:
207 self.test_override = None 204 self.test_override = None
208 if self.args.cl_prefix: # DIY CL start 205 if self.args.cl_prefix: # DIY CL start
209 clp = self.args.cl_prefix.split(" ") 206 clp = self.args.cl_prefix.split(" ")
210 for c in clp: 207 for c in clp:
211 aCL(c) 208 aCL(c)
212 aXCL(c) 209 aXCL(c)
213 else: 210 else:
214 if self.args.runmode == "Executable": 211 if self.args.runmode == "Executable":
215 if self.args.script_path: 212 if self.args.script_path:
216 aCL(self.executeme) 213 aCL(self.executeme)
217 aCL(self.sfile) 214 aCL(self.sfile)
215 aXCL(self.executeme)
218 aXCL("$runme") 216 aXCL("$runme")
219 else: 217 else:
220 aCL(self.executeme) # this little CL will just run 218 aCL(self.executeme) # this little CL will just run
221 aXCL(self.executeme) 219 aXCL(self.executeme)
222 else: 220 else:
223 if self.args.script_path: 221 if self.args.script_path:
224 aCL(self.executeme) 222 aCL(self.executeme)
225 aCL(self.sfile) 223 aCL(self.sfile)
224 aXCL(self.executeme)
226 aXCL("$runme") 225 aXCL("$runme")
227 else: 226 else:
228 aCL(self.executeme) # this little CL will just run 227 aCL(self.executeme) # this little CL will just run
229 aXCL(self.executeme) 228 aXCL(self.executeme)
230 self.elog = os.path.join(self.repdir,"%s_error_log.txt" % self.tool_name) 229 self.elog = os.path.join(self.repdir, "%s_error_log.txt" % self.tool_name)
231 self.tlog = os.path.join(self.repdir,"%s_runner_log.txt" % self.tool_name) 230 self.tlog = os.path.join(self.repdir, "%s_runner_log.txt" % self.tool_name)
232 231
233 if self.args.parampass == "0": 232 if self.args.parampass == "0":
234 self.clsimple() 233 self.clsimple()
235 else: 234 else:
236 clsuffix = [] 235 clsuffix = []
410 aparm.positional = int(oldcl) 409 aparm.positional = int(oldcl)
411 aparm.command_line_override = "$%s" % newcl 410 aparm.command_line_override = "$%s" % newcl
412 self.toutputs.append(aparm) 411 self.toutputs.append(aparm)
413 usetest = None 412 usetest = None
414 ld = None 413 ld = None
415 if test > '': 414 if test > "":
416 if test.startswith('diff'): 415 if test.startswith("diff"):
417 usetest = 'diff' 416 usetest = "diff"
418 if test.split(':')[1].isdigit: 417 if test.split(":")[1].isdigit:
419 ld = int(test.split(':')[1]) 418 ld = int(test.split(":")[1])
420 else: 419 else:
421 usetest = test 420 usetest = test
422 tp = gxtp.TestOutput(name=newcl, value="%s_sample" % newcl, format=newfmt, 421 tp = gxtp.TestOutput(
423 compare=usetest, lines_diff=ld, delta=None,) 422 name=newcl,
423 value="%s_sample" % newcl,
424 format=newfmt,
425 compare=usetest,
426 lines_diff=ld,
427 delta=None,
428 )
424 self.testparam.append(tp) 429 self.testparam.append(tp)
425 for p in self.infiles: 430 for p in self.infiles:
426 newname = p[ICLPOS] 431 newname = p[ICLPOS]
427 newfmt = p[IFMTPOS] 432 newfmt = p[IFMTPOS]
428 ndash = self.getNdash(newname) 433 ndash = self.getNdash(newname)
524 Create a Galaxy xml tool wrapper for the new script 529 Create a Galaxy xml tool wrapper for the new script
525 Uses galaxyhtml 530 Uses galaxyhtml
526 Hmmm. How to get the command line into correct order... 531 Hmmm. How to get the command line into correct order...
527 """ 532 """
528 if self.command_override: 533 if self.command_override:
529 self.tool.command_line_override = self.command_override # config file 534 self.newtool.command_line_override = self.command_override # config file
530 else: 535 else:
531 self.tool.command_line_override = self.xmlcl 536 self.newtool.command_line_override = self.xmlcl
532 # if self.args.interpreter_name:
533 # self.tool.interpreter = self.args.interpreter_name
534 if self.args.help_text: 537 if self.args.help_text:
535 helptext = open(self.args.help_text, "r").readlines() 538 helptext = open(self.args.help_text, "r").readlines()
536 helptext = [html_escape(x) for x in helptext] 539 safertext = [html_escape(x) for x in helptext]
537 self.tool.help = "".join([x for x in helptext]) 540 if self.args.script_path:
538 else: 541 scrpt = self.script.split('\n')
539 self.tool.help = ( 542 scrpt.append("```\n")
543 if len(scrpt) > 300:
544 safertext = safertext + scrpt[:100] + ['>500 lines - stuff deleted','......'] + scrpt[-100:]
545 else:
546 safertext = safertext + scrpt
547 safertext.append("\n```")
548 self.newtool.help = "".join([x for x in safertext])
549 else:
550 self.newtool.help = (
540 "Please ask the tool author (%s) for help \ 551 "Please ask the tool author (%s) for help \
541 as none was supplied at tool generation\n" 552 as none was supplied at tool generation\n"
542 % (self.args.user_email) 553 % (self.args.user_email)
543 ) 554 )
544 self.tool.version_command = None # do not want 555 self.newtool.version_command = None # do not want
545 requirements = gxtp.Requirements() 556 requirements = gxtp.Requirements()
546 if self.args.packages: 557 if self.args.packages:
547 for d in self.args.packages.split(","): 558 for d in self.args.packages.split(","):
548 if ":" in d: 559 if ":" in d:
549 packg, ver = d.split(":") 560 packg, ver = d.split(":")
550 else: 561 else:
551 packg = d 562 packg = d
552 ver = "" 563 ver = ""
553 requirements.append(gxtp.Requirement("package", packg.strip(), ver.strip())) 564 requirements.append(
554 self.tool.requirements = requirements 565 gxtp.Requirement("package", packg.strip(), ver.strip())
566 )
567 self.newtool.requirements = requirements
555 if self.args.parampass == "0": 568 if self.args.parampass == "0":
556 self.doNoXMLparam() 569 self.doNoXMLparam()
557 else: 570 else:
558 self.doXMLparam() 571 self.doXMLparam()
559 self.tool.outputs = self.toutputs 572 self.newtool.outputs = self.toutputs
560 self.tool.inputs = self.tinputs 573 self.newtool.inputs = self.tinputs
561 if ( 574 if self.args.script_path:
562 self.args.script_path
563 ):
564 configfiles = gxtp.Configfiles() 575 configfiles = gxtp.Configfiles()
565 configfiles.append(gxtp.Configfile(name="runme", text=self.script)) 576 configfiles.append(gxtp.Configfile(name="runme", text=self.script))
566 self.tool.configfiles = configfiles 577 self.newtool.configfiles = configfiles
567 tests = gxtp.Tests() 578 tests = gxtp.Tests()
568 test_a = gxtp.Test() 579 test_a = gxtp.Test()
569 for tp in self.testparam: 580 for tp in self.testparam:
570 test_a.append(tp) 581 test_a.append(tp)
571 tests.append(test_a) 582 tests.append(test_a)
572 self.tool.tests = tests 583 self.newtool.tests = tests
573 self.tool.add_comment( 584 self.newtool.add_comment(
574 "Created by %s at %s using the Galaxy Tool Factory." 585 "Created by %s at %s using the Galaxy Tool Factory."
575 % (self.args.user_email, timenow()) 586 % (self.args.user_email, timenow())
576 ) 587 )
577 self.tool.add_comment("Source in git at: %s" % (toolFactoryURL)) 588 self.newtool.add_comment("Source in git at: %s" % (toolFactoryURL))
578 self.tool.add_comment( 589 self.newtool.add_comment(
579 "Cite: Creating re-usable tools from scripts doi: \ 590 "Cite: Creating re-usable tools from scripts doi: \
580 10.1093/bioinformatics/bts573" 591 10.1093/bioinformatics/bts573"
581 ) 592 )
582 exml0 = self.tool.export() 593 exml0 = self.newtool.export()
583 exml = exml0.replace(FAKEEXE, "") # temporary work around until PR accepted 594 exml = exml0.replace(FAKEEXE, "") # temporary work around until PR accepted
584 if self.test_override: # cannot do this inside galaxyxml as it expects lxml objects for tests 595 if (
585 part1 = exml.split('<tests>')[0] 596 self.test_override
586 part2 = exml.split('</tests>')[1] 597 ): # cannot do this inside galaxyxml as it expects lxml objects for tests
587 fixed = '%s\n%s\n%s' % (part1,self.test_override,part2) 598 part1 = exml.split("<tests>")[0]
599 part2 = exml.split("</tests>")[1]
600 fixed = "%s\n%s\n%s" % (part1, self.test_override, part2)
588 exml = fixed 601 exml = fixed
589 xf = open("%s.xml" % self.tool_name, "w") 602 xf = open("%s.xml" % self.tool_name, "w")
590 xf.write(exml) 603 xf.write(exml)
591 xf.write("\n") 604 xf.write("\n")
592 xf.close() 605 xf.close()
593 # ready for the tarball 606 # ready for the tarball
594 607
595 def makeTool(self):
596 """write xmls and samples into place
597 """
598 self.makeXML()
599 if self.args.script_path:
600 stname = os.path.join(self.tooloutdir, "%s" % (self.sfile))
601 if not os.path.exists(stname):
602 shutil.copyfile(self.sfile, stname)
603 xreal = "%s.xml" % self.tool_name
604 xout = os.path.join(self.tooloutdir, xreal)
605 shutil.copyfile(xreal, xout)
606 for p in self.infiles:
607 pth = p[IPATHPOS]
608 dest = os.path.join(self.testdir, "%s_sample" % p[ICLPOS])
609 shutil.copyfile(pth, dest)
610
611 def makeToolTar(self):
612 self.newtarpath = "toolfactory_%s.tgz" % self.tool_name
613 tf = tarfile.open(self.newtarpath, "w:gz")
614 tf.add(name=self.tooloutdir, arcname=self.tool_name)
615 tf.close()
616 shutil.copyfile(self.newtarpath, self.args.new_tool)
617 if os.path.exists(self.tlog) and os.stat(self.tlog).st_size > 0:
618 shutil.copyfile(
619 self.tlog, os.path.join(self.tooloutdir, "test1_log_outfiletxt")
620 )
621
622 def moveRunOutputs(self):
623 """need to move files into toolfactory collection after any run - planemo or not
624 """
625 for p in self.outfiles:
626 naym = p[ONAMEPOS]
627 src = os.path.join(self.tooloutdir,naym)
628 if os.path.isfile(src):
629 dest = os.path.join(self.testdir, "%s_sample" % naym)
630 shutil.copyfile(naym, dest)
631 else:
632 print('### problem - output file %s not found in tooloutdir %s' % (src,self.tooloutdir))
633 with os.scandir(self.tooloutdir) as outs:
634 for entry in outs:
635 if not entry.is_file() or entry.name.startswith('.'):
636 continue
637 if "." in entry.name:
638 nayme,ext = os.path.splitext(entry.name)
639 else:
640 ext = ".txt"
641 ofn = "%s%s" % (entry.name.replace(".", "_"), ext)
642 dest = os.path.join(self.repdir, ofn)
643 src = os.path.join(self.tooloutdir,entry.name)
644 shutil.copyfile(src, dest)
645
646 def run(self): 608 def run(self):
647 """ 609 """
648 610 generate test outputs by running a command line
611 won't work if command or test override in play - planemo is the
612 easiest way to generate test outputs for that case so is
613 automagically selected
649 """ 614 """
650 s = "run cl=%s" % str(self.cl) 615 s = "run cl=%s" % str(self.cl)
651
652 logging.debug(s) 616 logging.debug(s)
653 scl = " ".join(self.cl) 617 scl = " ".join(self.cl)
654 err = None 618 err = None
655 if self.args.parampass != "0": 619 if self.args.parampass != "0":
656 ste = open(self.elog, "wb") 620 ste = open(self.elog, "wb")
701 """ 665 """
702 planemo shed_create --shed_target testtoolshed 666 planemo shed_create --shed_target testtoolshed
703 planemo shed_update --check_diff --shed_target testtoolshed 667 planemo shed_update --check_diff --shed_target testtoolshed
704 """ 668 """
705 if os.path.exists(self.tlog): 669 if os.path.exists(self.tlog):
706 tout = open(self.tlog,'a') 670 tout = open(self.tlog, "a")
707 else: 671 else:
708 tout = open(self.tlog,'w') 672 tout = open(self.tlog, "w")
709 cll = ["planemo", "shed_create", "--shed_target", "local"] 673 cll = ["planemo", "shed_create", "--shed_target", "local"]
710 try: 674 try:
711 p = subprocess.run(cll, shell=False, cwd=self.tooloutdir, stdout=tout, stderr = tout) 675 p = subprocess.run(
676 cll, shell=True, cwd=self.tooloutdir, stdout=tout, stderr=tout
677 )
712 except: 678 except:
713 pass 679 pass
714 if p.returncode != 0: 680 if p.returncode != 0:
715 print("Repository %s exists" % self.args.tool_name) 681 print("Repository %s exists" % self.args.tool_name)
716 else: 682 else:
727 "--shed_key", 693 "--shed_key",
728 self.args.toolshed_api_key, 694 self.args.toolshed_api_key,
729 "--tar", 695 "--tar",
730 self.newtarpath, 696 self.newtarpath,
731 ] 697 ]
732 print("Run", " ".join(cll)) 698 p = subprocess.run(cll, shell=True)
733 p = subprocess.run(cll, shell=False)
734 print("Ran", " ".join(cll), "got", p.returncode) 699 print("Ran", " ".join(cll), "got", p.returncode)
735 tout.close() 700 tout.close()
736 return p.returncode 701 return p.returncode
737 702
738 def planemo_test(self, genoutputs=True): 703 def planemo_test(self, genoutputs=True):
739 """planemo is a requirement so is available 704 """planemo is a requirement so is available for testing
705 and for generating test outputs if command or test overrides are supplied
706 test outputs are sent to repdir for display
740 """ 707 """
741 xreal = "%s.xml" % self.tool_name 708 xreal = "%s.xml" % self.tool_name
742 if os.path.exists(self.tlog): 709 if os.path.exists(self.tlog):
743 tout = open(self.tlog,'a') 710 tout = open(self.tlog, "a")
744 else: 711 else:
745 tout = open(self.tlog,'w') 712 tout = open(self.tlog, "w")
746 if genoutputs: 713 if genoutputs:
747 cll = [ 714 cll = [
748 "planemo", 715 "planemo",
749 "test", 716 "test",
750 "--galaxy_root", 717 "--galaxy_root",
751 self.args.galaxy_root, 718 self.args.galaxy_root,
752 "--update_test_data", 719 "--update_test_data",
720 "--galaxy_python_version",
721 "3.6",
722 "--no_conda_auto_install",
723 "--no_conda_auto_init",
753 xreal, 724 xreal,
754 ] 725 ]
755 else: 726 else:
756 cll = ["planemo", "test", "--galaxy_root", self.args.galaxy_root, xreal] 727 cll = ["planemo", "test", "--galaxy_python_version",
757 try: 728 "3.6", "--galaxy_root",
758 p = subprocess.run(cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout) 729 self.args.galaxy_root,
759 except: 730 "--no_conda_auto_install",
760 pass 731 "--no_conda_auto_init",
732 xreal,]
733 p = subprocess.run(
734 cll, shell=True, cwd=self.tooloutdir, stderr=tout, stdout=tout
735 )
736 if genoutputs:
737 with os.scandir(self.testdir) as outs:
738 for entry in outs:
739 if entry.is_file():
740 dest = os.path.join(self.repdir, entry.name)
741 src = os.path.join(self.testdir, entry.name)
742 shutil.copyfile(src, dest)
743 tout.write(
744 "Copied output %s to %s after planemo test\n" % (src, dest)
745 )
761 tout.close() 746 tout.close()
762 return p.returncode 747 return p.returncode
763 748
764 def eph_galaxy_load(self): 749 def eph_galaxy_load(self):
765 """ 750 """load the new tool from the local toolshed after planemo uploads it
766 """ 751 """
767 if os.path.exists(self.tlog): 752 if os.path.exists(self.tlog):
768 tout = open(self.tlog,'a') 753 tout = open(self.tlog, "a")
769 else: 754 else:
770 tout = open(self.tlog,'w') 755 tout = open(self.tlog, "w")
771 cll = [ 756 cll = [
772 "shed-tools", 757 "shed-tools",
773 "install", 758 "install",
774 "-g", 759 "-g",
775 self.args.galaxy_url, 760 self.args.galaxy_url,
797 print("installed %s" % self.args.tool_name) 782 print("installed %s" % self.args.tool_name)
798 tout.close() 783 tout.close()
799 return p.returncode 784 return p.returncode
800 785
801 def writeShedyml(self): 786 def writeShedyml(self):
787 """for planemo
788 """
802 yuser = self.args.user_email.split("@")[0] 789 yuser = self.args.user_email.split("@")[0]
803 yfname = os.path.join(self.tooloutdir, ".shed.yml") 790 yfname = os.path.join(self.tooloutdir, ".shed.yml")
804 yamlf = open(yfname, "w") 791 yamlf = open(yfname, "w")
805 odict = { 792 odict = {
806 "name": self.tool_name, 793 "name": self.tool_name,
807 "owner": yuser, 794 "owner": yuser,
808 "type": "unrestricted", 795 "type": "unrestricted",
809 "description": self.args.tool_desc, 796 "description": self.args.tool_desc,
797 "synopsis": self.args.tool_desc,
798 "category": "TF Generated Tools",
810 } 799 }
811 yaml.dump(odict, yamlf, allow_unicode=True) 800 yaml.dump(odict, yamlf, allow_unicode=True)
812 yamlf.close() 801 yamlf.close()
813 802
814 803 def makeTool(self):
815 def install_load(self): 804 """write xmls and input samples into place
816 _ = self.planemo_test(genoutputs=True) 805 """
817 testres = self.planemo_test(genoutputs=False) 806 self.makeXML()
818 if testres == 0: 807 if self.args.script_path:
819 if self.args.make_Tool == "install": 808 stname = os.path.join(self.tooloutdir, "%s" % (self.sfile))
820 self.planemo_shedload() 809 if not os.path.exists(stname):
821 self.eph_galaxy_load() 810 shutil.copyfile(self.sfile, stname)
822 else: 811 xreal = "%s.xml" % self.tool_name
823 os.stderr.write( 812 xout = os.path.join(self.tooloutdir, xreal)
824 "Planemo test failed - tool %s was not installed" % self.args.tool_name 813 shutil.copyfile(xreal, xout)
825 ) 814 for p in self.infiles:
815 pth = p[IPATHPOS]
816 dest = os.path.join(self.testdir, "%s_sample" % p[ICLPOS])
817 shutil.copyfile(pth, dest)
818 dest = os.path.join(self.repdir, "%s.%s" % (p[ICLPOS], p[IFMTPOS]))
819 shutil.copyfile(pth, dest)
820
821 def makeToolTar(self):
822 """ move outputs into test-data and prepare the tarball
823 """
824 for p in self.outfiles:
825 src = p[ONAMEPOS]
826 if os.path.isfile(src):
827 dest = os.path.join(self.testdir, "%s_sample" % src)
828 shutil.copyfile(src, dest)
829 dest = os.path.join(self.repdir, "%s.%s" % (src, p[OFMTPOS]))
830 shutil.copyfile(src, dest)
831 else:
832 print(
833 "### problem - output file %s not found in tooloutdir %s"
834 % (src, self.tooloutdir)
835 )
836 self.newtarpath = "toolfactory_%s.tgz" % self.tool_name
837 tf = tarfile.open(self.newtarpath, "w:gz")
838 tf.add(name=self.tooloutdir, arcname=self.tool_name)
839 tf.close()
840 shutil.copyfile(self.newtarpath, self.args.new_tool)
841
842 def moveRunOutputs(self):
843 """need to move planemo or run outputs into toolfactory collection
844 """
845 with os.scandir(self.tooloutdir) as outs:
846 for entry in outs:
847 if not entry.is_file() or entry.name.startswith("."):
848 continue
849 if "." in entry.name:
850 nayme, ext = os.path.splitext(entry.name)
851 else:
852 ext = ".txt"
853 ofn = "%s%s" % (entry.name.replace(".", "_"), ext)
854 dest = os.path.join(self.repdir, ofn)
855 src = os.path.join(self.tooloutdir, entry.name)
856 shutil.copyfile(src, dest)
857
826 858
827 def main(): 859 def main():
828 """ 860 """
829 This is a Galaxy wrapper. It expects to be called by a special purpose tool.xml as: 861 This is a Galaxy wrapper. It expects to be called by a special purpose tool.xml as:
830 <command interpreter="python">rgBaseScriptWrapper.py --script_path "$scriptPath" 862 <command interpreter="python">rgBaseScriptWrapper.py --script_path "$scriptPath"
855 a("--parampass", default="positional") 887 a("--parampass", default="positional")
856 a("--tfout", default="./tfout") 888 a("--tfout", default="./tfout")
857 a("--new_tool", default="new_tool") 889 a("--new_tool", default="new_tool")
858 a("--runmode", default=None) 890 a("--runmode", default=None)
859 a("--galaxy_url", default="http://localhost:8080") 891 a("--galaxy_url", default="http://localhost:8080")
860 a("--galaxy_api_key", default="fbdd3c2eecd191e88939fffc02eeeaf8") 892 a("--galaxy_api_key", default="fakekey")
861 a("--toolshed_url", default="http://localhost:9009") 893 a("--toolshed_url", default="http://localhost:9009")
862 a("--toolshed_api_key", default="d46e5ed0e242ed52c6e1f506b5d7f9f7") 894 a("--toolshed_api_key", default="fakekey")
863 a("--galaxy_root", default="/home/ross/galaxy") 895 a("--galaxy_root", default="/galaxy-central")
864 896
865 args = parser.parse_args() 897 args = parser.parse_args()
866 assert not args.bad_user, ( 898 assert not args.bad_user, (
867 'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file' 899 'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file'
868 % (args.bad_user, args.bad_user) 900 % (args.bad_user, args.bad_user)
876 for i, x in enumerate(args.additional_parameters): 908 for i, x in enumerate(args.additional_parameters):
877 args.additional_parameters[i] = args.additional_parameters[i].replace('"', "") 909 args.additional_parameters[i] = args.additional_parameters[i].replace('"', "")
878 r = ScriptRunner(args) 910 r = ScriptRunner(args)
879 r.writeShedyml() 911 r.writeShedyml()
880 r.makeTool() 912 r.makeTool()
881 if args.make_Tool == "runonly": 913 if args.command_override or args.test_override:
914 retcode = r.planemo_test(genoutputs=True) # this fails :( - see PR
915 r.moveRunOutputs()
916 r.makeToolTar()
917 retcode = r.planemo_test(genoutputs=False)
918 r.moveRunOutputs()
919 if args.make_Tool == "gentestinstall":
920 r.planemo_shedload()
921 r.eph_galaxy_load()
922 else:
882 retcode = r.run() 923 retcode = r.run()
883 if retcode: 924 if retcode:
884 sys.stderr.write( 925 sys.stderr.write(
885 "## Run failed with return code %d. Cannot build yet. Please fix and retry" 926 "## Run failed with return code %d. Cannot build yet. Please fix and retry"
886 % retcode 927 % retcode
887 ) 928 )
888 sys.exit(1) 929 sys.exit(1)
889 else: 930 else:
890 r.moveRunOutputs() 931 r.moveRunOutputs()
891 elif args.make_Tool in ["gentestinstall", "generate", "gentest"]: 932 r.makeToolTar()
892 retcode = r.run() 933 if args.make_Tool in ["gentestinstall", "gentest"]:
893 if retcode: 934 r.planemo_test(genoutputs=False)
894 sys.stderr.write( 935 r.moveRunOutputs()
895 "## Run failed with return code %d. Cannot build yet. Please fix and retry" 936 if args.make_Tool == "gentestinstall":
896 % retcode 937 r.planemo_shedload()
897 ) 938 r.eph_galaxy_load()
898 sys.exit(1)
899 r.moveRunOutputs()
900 r.makeToolTar()
901 if args.make_Tool in ["gentestinstall","gentest"]:
902 r.planemo_test(genoutputs=False)
903 r.moveRunOutputs()
904 r.planemo_shedload()
905 r.eph_galaxy_load()
906 else:
907 retcode = r.planemo_test(genoutputs=True) # this fails :(
908 r.moveRunOutputs()
909 r.makeToolTar()
910 retcode = r.planemo_test(genoutputs=False)
911 r.moveRunOutputs()
912 if args.make_Tool == "planemotestinstall":
913 r.planemo_shedload()
914 r.eph_galaxy_load()
915 # if retcode:
916 # sys.exit(retcode) # indicate failure to job runner
917 939
918 940
919 if __name__ == "__main__": 941 if __name__ == "__main__":
920 main() 942 main()