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

Changeset 63:b3254219d4fb (2020-11-10)
Previous changeset 62:881bd8c81ac9 (2020-10-26) Next changeset 64:30847b2e105d (2020-11-10)
Commit message:
Uploaded
modified:
toolfactory/rgToolFactory2.py
toolfactory/rgToolFactory2.xml
removed:
toolfactory/test-data/pyrevpos.python
b
diff -r 881bd8c81ac9 -r b3254219d4fb toolfactory/rgToolFactory2.py
--- a/toolfactory/rgToolFactory2.py Mon Oct 26 02:51:54 2020 +0000
+++ b/toolfactory/rgToolFactory2.py Tue Nov 10 02:33:46 2020 +0000
[
b'@@ -23,6 +23,7 @@\n \n \n import argparse\n+import copy\n import logging\n import os\n import re\n@@ -33,6 +34,9 @@\n import tempfile\n import time\n \n+from bioblend import galaxy\n+from bioblend import toolshed\n+\n import galaxyxml.tool as gxt\n import galaxyxml.tool.parameters as gxtp\n \n@@ -154,13 +158,13 @@\n         self.cl = []\n         self.xmlcl = []\n         self.is_positional = self.args.parampass == "positional"\n-        if self.args.packages:\n-            self.executeme = self.args.packages.split(",")[0].split(":")[0]\n-        else:\n+        if self.args.sysexe:\n             self.executeme = self.args.sysexe\n-        assert (\n-            self.executeme is not None\n-        ), "No system or managed executable passed in. Cannot build"\n+        else:\n+            if self.args.packages:\n+                self.executeme = self.args.packages.split(",")[0].split(":")[0]\n+            else:\n+                self.executeme = None\n         aCL = self.cl.append\n         aXCL = self.xmlcl.append\n         assert args.parampass in [\n@@ -477,9 +481,9 @@\n                 )\n             aparm.positional = self.is_positional\n             if self.is_positional:\n-                aninput.positional = int(oldcl)\n+                aparm.positional = int(oldcl)\n             self.tinputs.append(aparm)\n-            self.tparm = gxtp.TestParam(newname, value=newval)\n+            tparm = gxtp.TestParam(newname, value=newval)\n             self.testparam.append(tparm)\n \n     def doNoXMLparam(self):\n@@ -508,7 +512,7 @@\n             self.tinputs.append(aninput)\n             tp = gxtp.TestParam(name=newname, value="%s_sample" % newname)\n             self.testparam.append(tp)\n-        if len(self.outfiles > 0):\n+        if len(self.outfiles) > 0:\n             newname = self.outfiles[0][OCLPOS]\n             newfmt = self.outfiles[0][OFMTPOS]\n             anout = gxtp.OutputData(newname, format=newfmt, num_dashes=0)\n@@ -531,8 +535,9 @@\n         if self.args.help_text:\n             helptext = open(self.args.help_text, "r").readlines()\n             safertext = [html_escape(x) for x in helptext]\n-            if self.args.script_path:\n-                scrpt = self.script.split(\'\\n\')\n+            if False and self.args.script_path:\n+                scrp = self.script.split(\'\\n\')\n+                scrpt = [\'   %s\' % x for x in scrp] # try to stop templating\n                 scrpt.insert(0,"```\\n")\n                 if len(scrpt) > 300:\n                     safertext = safertext + scrpt[:100] + [\'>500 lines - stuff deleted\',\'......\'] + scrpt[-100:]\n@@ -593,6 +598,7 @@\n             part2 = exml.split("</tests>")[1]\n             fixed = "%s\\n%s\\n%s" % (part1, self.test_override, part2)\n             exml = fixed\n+        exml = exml.replace(\'range="1:"\', \'range="1000:"\')\n         xf = open("%s.xml" % self.tool_name, "w")\n         xf.write(exml)\n         xf.write("\\n")\n@@ -606,8 +612,6 @@\n         easiest way to generate test outputs for that case so is\n         automagically selected\n         """\n-        s = "run cl=%s" % str(self.cl)\n-        logging.debug(s)\n         scl = " ".join(self.cl)\n         err = None\n         if self.args.parampass != "0":\n@@ -623,7 +627,7 @@\n                 else:\n                     sto = open(self.tlog, "w")\n                 sto.write(\n-                        "## Executing Toolfactory generated command line = %s\\n" % scl\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@@ -634,12 +638,15 @@\n             if len(self.infiles) > 0:\n                 sti = open(self.infiles[0][IPATHPOS], "rb")\n             else:\n-                sti = sys.stdin    \n+                sti = sys.stdin\n             if len(self.outfiles) > 0:\n                 sto = open(self.outfiles[0][ONAMEPOS], "wb")\n             else:\n                 sto = sys.stdout\n             p = subprocess.run(self.cl, shell=False, stdout'..b'   cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout\n+                )\n+            tout.write("eph_test Ran %s got %d" % (" ".join(cll), p.returncode))\n+            tout.close()\n+            return p.returncode\n+\n+    def planemo_test(self, genoutputs=True):\n+        """planemo is a requirement so is available for testing\n+        and for generating test outputs if command or test overrides are supplied\n+        test outputs are sent to repdir for display\n+        """\n+        xreal = "%s.xml" % self.tool_name\n+        if os.path.exists(self.tlog):\n+            tout = open(self.tlog, "a")\n+        else:\n+            tout = open(self.tlog, "w")\n+        if genoutputs:\n+            dummy,tfile = tempfile.mkstemp()\n+            cll = [\n+                "planemo",\n+                "test",\n+                "--galaxy_root",\n+                self.args.galaxy_root,\n+                "--update_test_data",\n+                xreal,\n+            ]\n+            p = subprocess.run(\n+                    cll, shell=False, cwd=self.tooloutdir, stderr=dummy, stdout=dummy,\n+                )\n+            dummy.close() # throw all the log away as it will be rerun after outputs are generated\n+        else:\n+            cll = ["planemo", "test", "--galaxy_root",\n+                self.args.galaxy_root,\n+                xreal,]\n+            p = subprocess.run(\n+                    cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout\n+                )\n+        tout.close()\n+        return p.returncode\n+\n+\n+\n     def writeShedyml(self):\n         """for planemo\n         """\n@@ -872,11 +961,15 @@\n     a("--tfout", default="./tfout")\n     a("--new_tool", default="new_tool")\n     a("--galaxy_url", default="http://localhost:8080")\n+    a("--toolshed_url", default="http://localhost:9009") # make sure this is NOT 127.0.0.1 - it won\'t work if tool_sheds_conf.xml has localhost\n+    #a("--galaxy_api_key", default="1e62ddad74fe9bf112859f4e9efea48b")\n+    #a("--toolshed_api_key", default="9154c91f2a162bf12fda15764f43846c")\n+\n+    a("--toolshed_api_key", default="fakekey")\n     a("--galaxy_api_key", default="fakekey")\n-    a("--toolshed_url", default="http://localhost:9009")\n-    a("--toolshed_api_key", default="fakekey")\n     a("--galaxy_root", default="/galaxy-central")\n \n+\n     args = parser.parse_args()\n     assert not args.bad_user, (\n         \'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file\'\n@@ -893,32 +986,16 @@\n     r = ScriptRunner(args)\n     r.writeShedyml()\n     r.makeTool()\n-    if args.command_override or args.test_override:\n-        retcode = r.planemo_test(genoutputs=True)  # this fails :( - see PR\n-        r.moveRunOutputs()\n-        r.makeToolTar()\n-        retcode = r.planemo_test(genoutputs=False)\n-        r.moveRunOutputs()\n-        if args.make_Tool == "gentestinstall":\n-            r.planemo_shedload()\n-            r.eph_galaxy_load()\n-    else:\n-        retcode = r.run()\n-        if retcode:\n-            sys.stderr.write(\n-                "## Run failed with return code %d. Cannot build yet. Please fix and retry"\n-                % retcode\n-            )\n-            sys.exit(1)\n-        else:\n-            r.moveRunOutputs()\n-            r.makeToolTar()\n-            if args.make_Tool in ["gentestinstall", "gentest"]:\n-                r.planemo_test(genoutputs=False)\n-                r.moveRunOutputs()\n-                if args.make_Tool == "gentestinstall":\n-                    r.planemo_shedload()\n-                    r.eph_galaxy_load()\n+    retcode = r.planemo_test(genoutputs=True)  # this fails :( - see PR\n+    r.moveRunOutputs()\n+    r.makeToolTar()\n+    retcode = r.planemo_test(genoutputs=False)\n+    r.moveRunOutputs()\n+    if args.make_Tool == "gentestinstall":\n+        retcode = r.planemo_shedload() #r.shedLoad()\n+        print(f\'planemo_shedload returned {retcode}\')\n+        r.eph_galaxy_load()\n+\n \n \n if __name__ == "__main__":\n'
b
diff -r 881bd8c81ac9 -r b3254219d4fb toolfactory/rgToolFactory2.xml
--- a/toolfactory/rgToolFactory2.xml Mon Oct 26 02:51:54 2020 +0000
+++ b/toolfactory/rgToolFactory2.xml Tue Nov 10 02:33:46 2020 +0000
[
b'@@ -1,4 +1,4 @@\n-<tool id="rgtf2" name="toolfactory" version="2.01" profile="16.04" >\n+<tool id="rgtf2" name="toolfactory" version="2.00" profile="16.04" >\n   <description>Scripts into tools v2.0</description>\n   <macros>\n      <xml name="tool_metadata">\n@@ -56,7 +56,7 @@\n               <mapping initial="none"/>\n             </sanitizer>\n             </param>\n-            <param name="input_help" type="text" value="parameter_help" label="This will become help text on the form."\n+            <param name="input_help" type="text" value="" label="This will become help text on the form."\n              help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation">\n             <sanitizer invalid_char="">\n               <valid initial="string.printable"> <remove value=\'~~~\'/> </valid>\n@@ -85,13 +85,13 @@\n      <xml name="additparam">\n         <param name="edit_params" type="select" display="radio" label="Add any additional parameters to the generated tool form so they are user editable?"\n              help="If no (default), users will NOT be able to alter any additional parameters. If yes, these will appear on the tool form as text fields with no validation or sanitizing">\n-            <option value="yes">Yes, allow user to edit all additional parameters on the generated tool form</option>\n-            <option value="no" selected="true">No - use the fixed values for all additional parameters - no user editing</option>\n+            <option value="yes" selected="true">Yes, allow user to edit all additional parameters on the generated tool form</option>\n+            <option value="no">No - use the fixed values for all additional parameters - no user editing</option>\n         </param>\n \n         <repeat name="additional_parameters" title="Pass additional parameters to the script"\n              help="See examples below to see how these can be parsed by scripts in the various languages">\n-          <param name="param_name" type="text" value="parameter_name" label="Choose the name for this parameter">\n+          <param name="param_name" type="text" value="" label="Choose the name for this parameter - MUST not be blank!">\n             <sanitizer invalid_char="">\n               <valid initial="string.letters,string.digits"/>\n               <mapping initial="none"/>\n@@ -109,14 +109,14 @@\n               <mapping initial="none"/>\n             </sanitizer>\n           </param>\n-          <param name="param_label" type="text" value="parameter_label" label="Enter this parameter\'s label for the form"\n+          <param name="param_label" type="text" value="" label="Enter this parameter\'s label for the form"\n              help="Note that \'~~~\' is an internal delimiter so must not appear in this text field - please work around this technical limitation" >\n             <sanitizer invalid_char="">\n               <valid initial="string.printable"> <remove value=\'~~~\'/> </valid>\n               <mapping initial="none"/>\n             </sanitizer>\n           </param>\n-          <param name="param_help" type="text" value="parameter_help" label="Help for this parameter"\n+          <param name="param_help" type="text" value="" label="Help for this parameter"\n              help="Note that three consecutive ~ cannot be used in this text field - please work around this technical limitation" >\n             <sanitizer invalid_char="">\n               <valid initial="string.printable"> <remove value=\'~~~\'/> </valid>\n@@ -134,8 +134,9 @@\n <requirements>\n        <requirement type="package" version="0.72.0" >planemo</requirement>\n        <requirement type="package" version="0.4.11" >galaxyxml</requirement>\n+\n </requirements>\n-  \n+\n   <command ><![CDATA[\n #import os\n #set dev_env = os.environ.get(\'GALAXY_DEVELOPMENT_ENVIRONMENT\', \'0\') == \'1\'\n@@ -154,21 +155,23 @@\n --test_override "$testoverride"\n        #end if\n     #end if\n-    #if $interexe.dependency_model == "managed":\n---packages "$interexe.packages"\n-    #else:\n-'..b'elected="true">No. Use automatically generated command/test XML </option>\n             <option value="yes">Yes. XML needed to override autogenerated command and/or test segments will be pasted below</option>\n-        </param> \n+        </param>\n         <when value="no">\n             <param name="command_override" type="hidden"  value="" />\n             <param name="test_override" type="hidden"  value="" />\n@@ -315,26 +313,57 @@\n                  </valid>\n                  <mapping initial="none"/>\n               </sanitizer>\n-            </param> \n+            </param>\n         </when>\n     </conditional>\n \n     <conditional name="makeMode">\n         <param name="make_Tool" type="select" display="radio" label="Choose the steps you want to run. The TF Docker container is recommended for local installation"\n-          help="Testing and installation in this Galaxy are optional" >\n-        <option value="runonly">Run this configuration in Galaxy (will run Planemo if command or test override in play)</option>\n-        <option value="generate">Generate a toolshed ready archive.</option>\n+          help="Installation in this Galaxy is optional" >\n         <option value="gentest" selected="true">Test with planemo after generating.</option>\n         <option value="gentestinstall">Install in this Galaxy after generation and testing. Must have local ToolShed as in the TF Docker container</option>\n         </param>\n-        <when value="runonly"/>\n-        <when value="generate">\n-            <expand macro="tool_metadata" />\n-        </when>\n        <when value="gentest">\n+           <param name="galaxy_apikey" value="" type="hidden"  ></param>\n+           <param name="toolshed_apikey" value="" type="hidden"  ></param>\n+           <param name="galaxy_url" value="" type="hidden"  ></param>\n+           <param name="toolshed_url" value="" type="hidden"  ></param>\n             <expand macro="tool_metadata" />\n         </when>\n        <when value="gentestinstall">\n+            <param name="galaxy_url" type="text" value="http://localhost:8080" label="URL for the Galaxy server where the new tool should be installed"\n+             help="Default is localhost">\n+              <sanitizer>\n+                 <valid initial="string.printable">\n+                 </valid>\n+                 <mapping initial="none"/>\n+              </sanitizer>\n+            </param>\n+          <param name="galaxy_apikey" type="text" value="" label="API key for the Galaxy to install the new tool"\n+             help="Cut and paste from the admin user properties screen">\n+              <sanitizer>\n+                 <valid initial="string.letters,string.digits">\n+                 </valid>\n+                 <mapping initial="none"/>\n+              </sanitizer>\n+            </param>\n+           <param name="toolshed_url" type="text" value="http://localhost:9009" label="URL for the Toolshed where the new tool should be installed"\n+             help="Default value is localhost:9009">\n+              <sanitizer>\n+                 <valid initial="string.printable">\n+                 </valid>\n+                 <mapping initial="none"/>\n+              </sanitizer>\n+            </param>\n+           <param name="toolshed_apikey" type="text" value="" label="API key for the local toolshed to use when installing the tool"\n+             help="Cut and paste from the admin user properties screen">\n+              <sanitizer>\n+                 <valid initial="string.letters,string.digits">\n+                 </valid>\n+                 <mapping initial="none"/>\n+              </sanitizer>\n+            </param>\n+\n             <expand macro="tool_metadata" />\n         </when>\n     </conditional>\n@@ -372,6 +401,7 @@\n     <param name="choosescript" value="yes" />\n     <param name="script_path" value="$runme"/>\n     <output name="new_tool" file="toolfactory_pyrevpos_tgz_sample" compare="sim_size" delta="6000" />\n+\n </test>\n </tests>\n <help>\n@@ -461,7 +491,7 @@\n \n \n \n-Paper_ \n+Paper_\n \n *Licensing*\n \n'
b
diff -r 881bd8c81ac9 -r b3254219d4fb toolfactory/test-data/pyrevpos.python
--- a/toolfactory/test-data/pyrevpos.python Mon Oct 26 02:51:54 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,13 +0,0 @@
-# reverse order of text by row
-import sys
-inp = sys.argv[1]
-outp = sys.argv[2]
-i = open(inp,'r').readlines()
-o = open(outp,'w')
-for row in i:
-   rs = row.rstrip()
-   rs = list(rs)
-   rs.reverse()
-   o.write(''.join(rs))
-o.close() 
-