From 7ba4d54d8baa938dccd8f793b4c744abde0d45f0 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2013 19:17:13 -0600 Subject: [PATCH] Lazy load tool test cases. Running any tool test, will force everything in toolbox to parse out, but at least just starting Galaxy doesn't require parsing all test cases. --- lib/galaxy/tools/__init__.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index fe836bb3d74..3125ceab227 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1219,14 +1219,9 @@ class Tool( object, Dictifiable ): for key, value in uihints_elem.attrib.iteritems(): self.uihints[ key ] = value # Tests - tests_elem = root.find( "tests" ) - if tests_elem: - try: - self.tests = parse_tests_elem( self, tests_elem ) - except: - log.exception( "Failed to parse tool tests" ) - else: - self.tests = None + self.__tests_elem = root.find( "tests" ) + self.__tests_populated = False + # Requirements (dependencies) self.requirements = parse_requirements_from_xml( root ) # Determine if this tool can be used in workflows @@ -1237,6 +1232,21 @@ class Tool( object, Dictifiable ): self.trackster_conf = TracksterConfig.parse( trackster_conf ) else: self.trackster_conf = None + + @property + def tests( self ): + if not self.__tests_populated: + tests_elem = self.__tests_elem + if tests_elem: + try: + self.__tests = parse_tests_elem( self, tests_elem ) + except: + log.exception( "Failed to parse tool tests" ) + else: + self.__tests = None + self.__tests_populated = True + return self.__tests + def parse_inputs( self, root ): """ Parse the "" element and create appropriate `ToolParameter`s.