Repository 'tool_factory_2'
hg clone https://toolshed.g2.bx.psu.edu/repos/fubar/tool_factory_2

Changeset 98:67628c7dc9f3 (2020-11-22)
Previous changeset 97:515be7318f2b (2020-11-21) Next changeset 99:d4d88d393285 (2020-11-23)
Commit message:
Uploaded
modified:
toolfactory/rgToolFactory2.py
toolfactory/rgToolFactory2.xml
b
diff -r 515be7318f2b -r 67628c7dc9f3 toolfactory/rgToolFactory2.py
--- a/toolfactory/rgToolFactory2.py Sat Nov 21 10:11:36 2020 +0000
+++ b/toolfactory/rgToolFactory2.py Sun Nov 22 06:29:33 2020 +0000
[
b'@@ -40,6 +40,8 @@\n \n from bioblend import toolshed\n \n+# import docker\n+\n import galaxyxml.tool as gxt\n import galaxyxml.tool.parameters as gxtp\n \n@@ -183,8 +185,8 @@\n             FAKEEXE,\n         )\n         self.newtarpath = "toolfactory_%s.tgz" % self.tool_name\n-        self.tooloutdir = "tfout"\n-        self.repdir = "TF_run_report_tempdir"\n+        self.tooloutdir = "./tfout"\n+        self.repdir = "./TF_run_report_tempdir"\n         self.testdir = os.path.join(self.tooloutdir, "test-data")\n         if not os.path.exists(self.tooloutdir):\n             os.mkdir(self.tooloutdir)\n@@ -641,10 +643,10 @@\n                     "## Executing Toolfactory generated command line = %s\\n" % scl\n                 )\n             sto.flush()\n-            p = subprocess.run(self.cl, shell=False, stdout=sto, stderr=ste)\n+            subp = subprocess.run(self.cl, shell=False, stdout=sto, stderr=ste)\n             sto.close()\n             ste.close()\n-            retval = p.returncode\n+            retval = subp.returncode\n         else:  # work around special case - stdin and write to stdout\n             if len(self.infiles) > 0:\n                 sti = open(self.infiles[0][IPATHPOS], "rb")\n@@ -654,9 +656,9 @@\n                 sto = open(self.outfiles[0][ONAMEPOS], "wb")\n             else:\n                 sto = sys.stdout\n-            p = subprocess.run(self.cl, shell=False, stdout=sto, stdin=sti)\n+            subp = subprocess.run(self.cl, shell=False, stdout=sto, stdin=sti)\n             sto.write("## Executing Toolfactory generated command line = %s\\n" % scl)\n-            retval = p.returncode\n+            retval = subp.returncode\n             sto.close()\n             sti.close()\n         if os.path.isfile(self.tlog) and os.stat(self.tlog).st_size == 0:\n@@ -691,14 +693,14 @@\n         rnames = [x.get("name", "?") for x in repos]\n         rids = [x.get("id", "?") for x in repos]\n         sto.write(f"############names={rnames} rids={rids}\\n")\n-        cat = "ToolFactory generated tools"\n+        tfcat = "ToolFactory generated tools"\n         if self.args.tool_name not in rnames:\n             tscat = ts.categories.get_categories()\n-            cnames = [x.get("name", "?") for x in tscat]\n+            cnames = [x.get("name", "?").strip() for x in tscat]\n             cids = [x.get("id", "?") for x in tscat]\n             catID = None\n-            if cat in cnames:\n-                ci = cnames.index(cat)\n+            if tfcat.strip() in cnames:\n+                ci = cnames.index(tfcat)\n                 catID = cids[ci]\n             res = ts.repositories.create_repository(\n                 name=self.args.tool_name,\n@@ -744,12 +746,12 @@\n             "ToolFactory",\n         ]\n         tout.write("running\\n%s\\n" % " ".join(cll))\n-        p = subprocess.run(cll, shell=False, stderr=tout, stdout=tout)\n+        subp = subprocess.run(cll, shell=False, stderr=tout, stdout=tout)\n         tout.write(\n-            "installed %s - got retcode %d\\n" % (self.args.tool_name, p.returncode)\n+            "installed %s - got retcode %d\\n" % (self.args.tool_name, subp.returncode)\n         )\n         tout.close()\n-        return p.returncode\n+        return subp.returncode\n \n     def planemo_shedload(self):\n         """\n@@ -790,12 +792,12 @@\n                 self.args.toolshed_api_key,\n             ]\n             try:\n-                p = subprocess.run(\n+                subp = subprocess.run(\n                     cll, shell=False, cwd=self.tooloutdir, stdout=tout, stderr=tout\n                 )\n             except:\n                 pass\n-            if p.returncode != 0:\n+            if subp.returncode != 0:\n                 tout.write("Repository %s exists\\n" % self.args.tool_name)\n             else:\n                 tout.write("initiated %s\\n" % self.args.tool_name)\n@@ -813,10 +815,10 @@\n             "--tar",\n             self.newtarpath,\n         ]\n-        p = subprocess.run(cll, shell=False, stdout=tout, stderr=tout)\n-        tout.write("Ran %s got %d\\n" % (" ".joi'..b'             stdout=dummy,\n             )\n+            dummy.close()\n             # if all went well, tgz is in ./test and down a nest of tmp directories lurk the output files\n             outfiles = []\n             for p in self.outfiles:\n                 oname = p[ONAMEPOS]\n                 outfiles.append(oname)\n             paths = []\n-            for root, dirs, files in os.walk(\'./test\'):\n+            for root, dirs, files in os.walk(testdir):\n                 for f in files:\n+                    tout.write(f"{root} {f}\\n")\n                     if f in outfiles:\n                         paths.append([root,f])\n-            for p in paths:\n-                src = os.path.join(p[0],p[1])\n-                dest = os.path.join(self.testdir,f"{p[1]}_sample")\n+                        tout.write(f"## found output {f}")\n+\n+            if len(paths) != len(self.outfiles):\n+                tout.write(f"## problem - outfiles not all found")\n+            for path in paths:\n+                fname = path[1]\n+                src = os.path.join(path[0],fname)\n+                dest = os.path.join(self.testdir,f"{fname}_sample")\n                 shutil.copyfile(src,dest)\n-\n         else:\n             cll = [\n-            "mkdir -p ./test","&&","rm -rf ./test/*","&&","export GALAXY_TEST_SAVE=\'./test\'", "&&", "export GALAXY_TEST_NO_CLEANUP=", \\\n-           "&&", "export GALAXY_TEST_TMP_DIR=\'./test\'", "&&", f"sh {self.args.galaxy_root}/run_tests.sh --id {self.args.tool_id} --report_file {tool_test_rep_path} functional.test_toolbox",\n+           "sh", f"{self.args.galaxy_root}/run_tests.sh", "--id", self.args.tool_name,\n+           "--report_file", tool_test_rep_path, "functional.test_toolbox",\n             ]\n-            p = subprocess.run(\n-                cll, shell=False, cwd=self.testdir, stderr=tout, stdout=tout\n+            subp = subprocess.run(\n+                cll, env = ourenv,\n+                shell=False, cwd=self.testdir, stderr=tout, stdout=tout\n             )\n         tout.close()\n-        return p.returncode\n+        return subp.returncode\n+\n \n \n     def writeShedyml(self):\n@@ -1111,6 +1128,41 @@\n         tf.close()\n         shutil.copyfile(self.newtarpath, self.args.new_tool)\n \n+    def fakeToolTar(self):\n+        """move fake outputs into test-data and prepare the tarball"""\n+        excludeme = "tool_test_output"\n+\n+        def exclude_function(tarinfo):\n+            filename = tarinfo.name\n+            return (\n+                None\n+                if filename.startswith(excludeme)\n+                else tarinfo\n+            )\n+\n+        for p in self.outfiles:\n+            oname = p[ONAMEPOS]\n+            src = os.path.join(self.testdir,oname)\n+            if os.path.isfile(src):\n+                dest = os.path.join(self.testdir, "%s_sample" % oname)\n+                shutil.copyfile(src, dest)\n+                dest = os.path.join(self.repdir, "%s.sample" % (oname))\n+                shutil.copyfile(src, dest)\n+            else:\n+                with open(src,\'w\') as fayk:\n+                    fayk.write(\'fake!\\n\')\n+                dest = os.path.join(self.testdir, "%s_sample" % oname)\n+                shutil.copyfile(src, dest)\n+                print(\n+                    "### problem - output file %s not found in tooloutdir %s so faked"\n+                    % (src, self.tooloutdir)\n+                )\n+        tf = tarfile.open(self.newtarpath, "w:gz")\n+        tf.add(name=self.tooloutdir, arcname=self.tool_name, filter=exclude_function)\n+        tf.close()\n+        shutil.copyfile(self.newtarpath, self.args.new_tool)\n+\n+\n     def moveRunOutputs(self):\n         """need to move planemo or run outputs into toolfactory collection"""\n         with os.scandir(self.tooloutdir) as outs:\n@@ -1202,7 +1254,7 @@\n         r.moveRunOutputs()\n         r.makeToolTar()\n     else:\n-        r.makeToolTar()\n+        r.fakeToolTar()\n         r.shedLoad()\n         r.eph_galaxy_load()\n         retcode = r.gal_test(genoutputs=True)  # this fails\n'
b
diff -r 515be7318f2b -r 67628c7dc9f3 toolfactory/rgToolFactory2.xml
--- a/toolfactory/rgToolFactory2.xml Sat Nov 21 10:11:36 2020 +0000
+++ b/toolfactory/rgToolFactory2.xml Sun Nov 22 06:29:33 2020 +0000
[
@@ -136,6 +136,7 @@
    <requirement type="package" version="0.14.0">bioblend</requirement>
    <requirement type="package" version="0.10.6">ephemeris</requirement>
    <requirement type="package" version="0.72.0">planemo</requirement>
+   <requirement type="package" version="4.3.1">docker-py</requirement>
 </requirements>
 
   <command ><![CDATA[