comparison toolfactory/rgToolFactory2.py @ 117:b1a29d3d50d6 draft

Uploaded
author fubar
date Sun, 06 Dec 2020 01:21:06 +0000
parents bf7b4b603bf9
children e43c43396a70
comparison
equal deleted inserted replaced
116:b1ea31ea3f00 117:b1a29d3d50d6
633 ): # cannot do this inside galaxyxml as it expects lxml objects for tests 633 ): # cannot do this inside galaxyxml as it expects lxml objects for tests
634 part1 = exml.split("<tests>")[0] 634 part1 = exml.split("<tests>")[0]
635 part2 = exml.split("</tests>")[1] 635 part2 = exml.split("</tests>")[1]
636 fixed = "%s\n%s\n%s" % (part1, self.test_override, part2) 636 fixed = "%s\n%s\n%s" % (part1, self.test_override, part2)
637 exml = fixed 637 exml = fixed
638 exml = exml.replace('range="1:"', 'range="1000:"') 638 #exml = exml.replace('range="1:"', 'range="1000:"')
639 xf = open("%s.xml" % self.tool_name, "w") 639 xf = open("%s.xml" % self.tool_name, "w")
640 xf.write(exml) 640 xf.write(exml)
641 xf.write("\n") 641 xf.write("\n")
642 xf.close() 642 xf.close()
643 # ready for the tarball 643 # ready for the tarball
754 client = docker.from_env() 754 client = docker.from_env()
755 tvol = client.volumes.create() 755 tvol = client.volumes.create()
756 tvolname = tvol.name 756 tvolname = tvol.name
757 destdir = "/toolfactory/ptest" 757 destdir = "/toolfactory/ptest"
758 imrep = os.path.join(destdir, repname) 758 imrep = os.path.join(destdir, repname)
759 # need to keep the container running so keep it open with tail -f. 759 # need to keep the container running so keep it open with sleep
760 # will stop and destroy it when we are done 760 # will stop and destroy it when we are done
761 container = client.containers.run( 761 container = client.containers.run(
762 planemoimage, 762 planemoimage,
763 "sleep 120m", 763 "sleep 120m",
764 detach=True, 764 detach=True,
784 tout.write(f"#### error: {e} from {ptestcl}\n") 784 tout.write(f"#### error: {e} from {ptestcl}\n")
785 cl = f"planemo test --test_output {imrep} --no_cleanup --test_data {destdir}/tfout/test-data --galaxy_root /home/biodocker/galaxy-central {ptestpath}" 785 cl = f"planemo test --test_output {imrep} --no_cleanup --test_data {destdir}/tfout/test-data --galaxy_root /home/biodocker/galaxy-central {ptestpath}"
786 try: 786 try:
787 prun(container, tout, cl) 787 prun(container, tout, cl)
788 except: 788 except:
789 pass 789 e = sys.exc_info()[0]
790 tout.write(f"#### error: {e} from {ptestcl}\n")
790 testouts = tempfile.mkdtemp(suffix=None, prefix="tftemp", dir=".") 791 testouts = tempfile.mkdtemp(suffix=None, prefix="tftemp", dir=".")
791 self.copy_from_container(destdir, testouts, container) 792 self.copy_from_container(destdir, testouts, container)
792 src = os.path.join(testouts, "ptest") 793 src = os.path.join(testouts, "ptest")
793 if os.path.isdir(src): 794 if os.path.isdir(src):
794 shutil.copytree(src, ".", dirs_exist_ok=True) 795 shutil.copytree(src, ".", dirs_exist_ok=True)
928 929
929 def exclude_function(tarinfo): 930 def exclude_function(tarinfo):
930 filename = tarinfo.name 931 filename = tarinfo.name
931 return None if filename.endswith(excludeme) else tarinfo 932 return None if filename.endswith(excludeme) else tarinfo
932 933
934 if os.path.exists(self.tlog):
935 tout = open(self.tlog, "a")
936 else:
937 tout = open(self.tlog, "w")
933 for p in self.outfiles: 938 for p in self.outfiles:
934 oname = p[ONAMEPOS] 939 oname = p[ONAMEPOS]
935 tdest = os.path.join(self.testdir, "%s_sample" % oname) 940 tdest = os.path.join(self.testdir, "%s_sample" % oname)
936 if not os.path.isfile(tdest): 941 if not os.path.isfile(tdest):
937 src = os.path.join(self.testdir, oname) 942 src = os.path.join(self.testdir, oname)
938 if os.path.isfile(src): 943 if os.path.isfile(src):
939 shutil.copyfile(src, tdest) 944 shutil.copyfile(src, tdest)
940 dest = os.path.join(self.repdir, "%s.sample" % (oname)) 945 dest = os.path.join(self.repdir, "%s.sample" % (oname))
941 shutil.copyfile(src, dest) 946 shutil.copyfile(src, dest)
942 else: 947 else:
943 print( 948 tout.write(
944 "### problem - output file %s not found in testdir %s" 949 "###Output file %s not found in testdir %s. This is normal during the first Planemo run that generates test outputs"
945 % (tdest, self.testdir) 950 % (tdest, self.testdir)
946 ) 951 )
947 tf = tarfile.open(self.newtarpath, "w:gz") 952 tf = tarfile.open(self.newtarpath, "w:gz")
948 tf.add(name=self.tooloutdir, arcname=self.tool_name, filter=exclude_function) 953 tf.add(name=self.tooloutdir, arcname=self.tool_name, filter=exclude_function)
949 tf.close() 954 tf.close()