Add a "maxseconds" attribute to the "test" tag in tool configs. Allows the tool writer to decide how long Galaxy should wait for tool execution to complete. Resolves issue #219.

This commit is contained in:
Nate Coraor
2009-11-12 11:07:05 -05:00
parent 702bad5d25
commit d2102123d9
4 changed files with 14 additions and 10 deletions
+2 -1
View File
@@ -547,7 +547,8 @@ class Tool:
self.tests = []
for i, test_elem in enumerate( tests_elem.findall( 'test' ) ):
name = test_elem.get( 'name', 'Test-%d' % (i+1) )
test = ToolTestBuilder( self, name )
maxseconds = int( test_elem.get( 'maxseconds', '120' ) )
test = ToolTestBuilder( self, name, maxseconds )
try:
for param_elem in test_elem.findall( "param" ):
attrib = dict( param_elem.attrib )
+2 -1
View File
@@ -11,9 +11,10 @@ class ToolTestBuilder( object ):
dynamic TestCase class (the unittest framework is very class oriented,
doing dynamic tests in this was allows better integration)
"""
def __init__( self, tool, name ):
def __init__( self, tool, name, maxseconds ):
self.tool = tool
self.name = name
self.maxseconds = maxseconds
self.required_files = []
self.inputs = []
self.outputs = []
+9 -7
View File
@@ -513,10 +513,10 @@ class TwillTestCase( unittest.TestCase ):
hid = elem.get('hid')
hids.append(hid)
return hids
def verify_dataset_correctness( self, filename, hid=None, wait=True ):
def verify_dataset_correctness( self, filename, hid=None, wait=True, maxseconds=120 ):
"""Verifies that the attributes and contents of a history item meet expectations"""
if wait:
self.wait() #wait for job to finish
self.wait( maxseconds=maxseconds ) #wait for job to finish
data_list = self.get_history_as_data_list()
self.assertTrue( data_list )
if hid is None: # take last hid
@@ -906,21 +906,23 @@ class TwillTestCase( unittest.TestCase ):
tc.fv( "1","hgta_doGalaxyQuery", "Send query to Galaxy" )
self.submit_form( button="Send query to Galaxy" )#, **output_params ) #AssertionError: Attempting to set field 'fbQual' to value '['whole']' in form 'None' threw exception: no matching forms! control: <RadioControl(fbQual=[whole, upstreamAll, endAll])>
def wait( self, maxiter=20 ):
def wait( self, maxseconds=120 ):
"""Waits for the tools to finish"""
count = 0
sleep_amount = 0.1
slept = 0
self.home()
while count < maxiter:
count += 1
while slept <= maxseconds:
self.visit_page( "history" )
page = tc.browser.get_html()
if page.find( '<!-- running: do not change this comment, used by TwillTestCase.wait -->' ) > -1:
time.sleep( sleep_amount )
slept += sleep_amount
sleep_amount *= 2
if slept + sleep_amount > maxseconds:
sleep_amount = maxseconds - slept # don't overshoot maxseconds
else:
break
self.assertNotEqual(count, maxiter)
assert slept < maxseconds
# Dataset Security stuff
# Tests associated with users
+1 -1
View File
@@ -63,7 +63,7 @@ class ToolTestCase( TwillTestCase ):
# Check the result
assert len( testdef.outputs ) == 1, "ToolTestCase does not deal with multiple outputs properly yet."
for name, file in testdef.outputs:
self.verify_dataset_correctness( file )
self.verify_dataset_correctness( file, maxseconds=testdef.maxseconds )
self.delete_history( id=self.security.encode_id( latest_history.id ) )
def __expand_grouping( self, tool_inputs, declared_inputs, prefix='' ):