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

Changeset 76:46db8143adb7 (2020-11-16)
Previous changeset 75:25dd9364a32a (2020-11-14) Next changeset 77:1fa49a9a4ec5 (2020-11-16)
Commit message:
Uploaded
modified:
toolfactory/rgToolFactory2.py
toolfactory/rgToolFactory2.xml
b
diff -r 25dd9364a32a -r 46db8143adb7 toolfactory/rgToolFactory2.py
--- a/toolfactory/rgToolFactory2.py Sat Nov 14 23:35:27 2020 +0000
+++ b/toolfactory/rgToolFactory2.py Mon Nov 16 02:42:49 2020 +0000
[
@@ -24,6 +24,8 @@
 
 
 import argparse
+import datetime
+import json
 import logging
 import os
 import re
@@ -179,6 +181,7 @@
             self.args.tool_desc,
             FAKEEXE,
         )
+        self.newtarpath = "toolfactory_%s.tgz" % self.tool_name
         self.tooloutdir = "tfout"
         self.repdir = "TF_run_report_tempdir"
         self.testdir = os.path.join(self.tooloutdir, "test-data")
@@ -815,8 +818,9 @@
         tout.close()
         return p.returncode
 
-    def eph_test(self):
-        """"""
+    def eph_test(self, genoutputs=True):
+        """problem getting jobid - ephemeris upload is the job before the one we want - but depends on how many inputs
+        """
         if os.path.exists(self.tlog):
             tout = open(self.tlog, "a")
         else:
@@ -833,10 +837,41 @@
             "--owner",
             "fubar",
         ]
-        p = subprocess.run(
-            cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout
-        )
-        tout.write("eph_test Ran %s got %d" % (" ".join(cll), p.returncode))
+        if genoutputs:
+            dummy, tfile = tempfile.mkstemp()
+            p = subprocess.run(
+               cll, shell=False, stderr=dummy, stdout=dummy
+            )
+
+            with open('tool_test_output.json','rb') as f:
+                s = json.loads(f.read())
+                print('read %s' % s)
+                cl = s['tests'][0]['data']['job']['command_line'].split()
+                n = cl.index('--script_path')
+                jobdir = cl[n+1]
+                jobdir = jobdir.replace('"','')
+                jobdir = jobdir.split('/configs')[0]
+                print('jobdir=%s' % jobdir)
+
+                #"/home/ross/galthrow/database/jobs_directory/000/649/configs/tmptfxu51gs\"
+            src = os.path.join(jobdir,'working',self.newtarpath)
+            if os.path.exists(src):
+                dest = os.path.join(self.testdir, self.newtarpath)
+                shutil.copyfile(src, dest)
+            else:
+                tout.write('No toolshed archive found after first ephemeris test - not a good sign')
+            ephouts = os.path.join(jobdir,'working','tfout','test-data')
+            with os.scandir(ephouts) as outs:
+                for entry in outs:
+                    if not entry.is_file():
+                        continue
+                    dest = os.path.join(self.tooloutdir, entry.name)
+                    src = os.path.join(ephouts, entry.name)
+                    shutil.copyfile(src, dest)
+        else:
+            p = subprocess.run(
+               cll, shell=False,  stderr=tout, stdout=tout)
+            tout.write("eph_test Ran %s got %d" % (" ".join(cll), p.returncode))
         tout.close()
         return p.returncode
 
@@ -940,7 +975,6 @@
                     "### problem - output file %s not found in tooloutdir %s"
                     % (src, self.tooloutdir)
                 )
-        self.newtarpath = "toolfactory_%s.tgz" % self.tool_name
         tf = tarfile.open(self.newtarpath, "w:gz")
         tf.add(name=self.tooloutdir, arcname=self.tool_name, filter=exclude_function)
         tf.close()
@@ -962,6 +996,7 @@
                 shutil.copyfile(src, dest)
 
 
+
 def main():
     """
     This is a Galaxy wrapper. It expects to be called by a special purpose tool.xml as:
@@ -976,7 +1011,7 @@
     a("--cl_prefix", default=None)
     a("--sysexe", default=None)
     a("--packages", default=None)
-    a("--tool_name", default=None)
+    a("--tool_name", default="newtool")
     a("--tool_dir", default=None)
     a("--input_files", default=[], action="append")
     a("--output_files", default=[], action="append")
@@ -996,15 +1031,11 @@
     a("--new_tool", default="new_tool")
     a("--galaxy_url", default="http://localhost:8080")
     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
-    # a("--galaxy_api_key", default="1e62ddad74fe9bf112859f4e9efea48b")
-    # a("--toolshed_api_key", default="9154c91f2a162bf12fda15764f43846c")
-
+        "--toolshed_url", default="http://localhost:9009")
+    # make sure this is identical to tool_sheds_conf.xml  localhost != 127.0.0.1 so validation fails
     a("--toolshed_api_key", default="fakekey")
     a("--galaxy_api_key", default="fakekey")
     a("--galaxy_root", default="/galaxy-central")
-
     args = parser.parse_args()
     assert not args.bad_user, (
         'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to "admin_users" in the Galaxy configuration file'
@@ -1031,9 +1062,8 @@
         r.makeToolTar()
         retcode = r.planemo_test(genoutputs=False)
         r.moveRunOutputs()
+        print(f"second planemo_test returned {retcode}")
         if args.make_Tool == "gentestinstall":
-            retcode = r.planemo_shedload()  # r.shedLoad()
-            print(f"planemo_shedload returned {retcode}")
             r.eph_galaxy_load()
 
 
b
diff -r 25dd9364a32a -r 46db8143adb7 toolfactory/rgToolFactory2.xml
--- a/toolfactory/rgToolFactory2.xml Sat Nov 14 23:35:27 2020 +0000
+++ b/toolfactory/rgToolFactory2.xml Mon Nov 16 02:42:49 2020 +0000
b
@@ -132,8 +132,8 @@
   </macros>
 
 <requirements>
-    <requirement type="package" >galaxyxml</requirement>
-    <requirement type="package" >bioblend</requirement>
+    <requirement type="package">galaxyxml</requirement>
+    <requirement type="package">bioblend</requirement>
     <requirement type="package">planemo</requirement>
     <container type="docker">quay.io/fubar2/toolfactorybiocontainer</container>
 </requirements>
@@ -142,9 +142,9 @@
 #import os
 #set dev_env = os.environ.get('GALAXY_DEVELOPMENT_ENVIRONMENT', '0') == '1'
 #if not $dev_env and ( $__user_email__ not in $__admin_users__ ):
-rgToolFactory2.py --bad_user $__user_email__
+python3 $__tool_directory__/rgToolFactory2.py --bad_user $__user_email__
  #else:
-rgToolFactory2.py
+python3 $__tool_directory__/rgToolFactory2.py
     #if len(str($cl_prefix)) > 3:
 --cl_prefix "$cl_prefix"
     #end if