mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Workflow modules: Adjust spacing to new guidelines.
This commit is contained in:
@@ -15,9 +15,9 @@ from galaxy.tools.parameters import check_param, DataToolParameter, DummyDataset
|
||||
from galaxy.util.bunch import Bunch
|
||||
from galaxy.util.json import from_json_string, to_json_string
|
||||
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
|
||||
class WorkflowModule( object ):
|
||||
|
||||
def __init__( self, trans ):
|
||||
@@ -31,6 +31,7 @@ class WorkflowModule( object ):
|
||||
Create a new instance of the module with default state
|
||||
"""
|
||||
return Class( trans )
|
||||
|
||||
@classmethod
|
||||
def from_dict( Class, trans, d ):
|
||||
"""
|
||||
@@ -38,6 +39,7 @@ class WorkflowModule( object ):
|
||||
dictionary `d`.
|
||||
"""
|
||||
return Class( trans )
|
||||
|
||||
@classmethod
|
||||
def from_workflow_step( Class, trans, step ):
|
||||
return Class( trans )
|
||||
@@ -51,10 +53,13 @@ class WorkflowModule( object ):
|
||||
|
||||
def get_type( self ):
|
||||
return self.type
|
||||
|
||||
def get_name( self ):
|
||||
return self.name
|
||||
|
||||
def get_tool_id( self ):
|
||||
return None
|
||||
|
||||
def get_tooltip( self, static_path='' ):
|
||||
return None
|
||||
|
||||
@@ -62,14 +67,19 @@ class WorkflowModule( object ):
|
||||
|
||||
def get_state( self ):
|
||||
return None
|
||||
|
||||
def get_errors( self ):
|
||||
return None
|
||||
|
||||
def get_data_inputs( self ):
|
||||
return []
|
||||
|
||||
def get_data_outputs( self ):
|
||||
return []
|
||||
|
||||
def update_state( self ):
|
||||
pass
|
||||
|
||||
def get_config_form( self ):
|
||||
raise TypeError( "Abstract method" )
|
||||
|
||||
@@ -84,18 +94,23 @@ class WorkflowModule( object ):
|
||||
|
||||
def get_runtime_inputs( self ):
|
||||
raise TypeError( "Abstract method" )
|
||||
|
||||
def get_runtime_state( self ):
|
||||
raise TypeError( "Abstract method" )
|
||||
|
||||
def encode_runtime_state( self, trans, state ):
|
||||
raise TypeError( "Abstract method" )
|
||||
|
||||
def decode_runtime_state( self, trans, string ):
|
||||
raise TypeError( "Abstract method" )
|
||||
|
||||
def update_runtime_state( self, trans, state, values ):
|
||||
raise TypeError( "Abstract method" )
|
||||
|
||||
def execute( self, trans, state ):
|
||||
raise TypeError( "Abstract method" )
|
||||
|
||||
|
||||
class InputDataModule( WorkflowModule ):
|
||||
type = "data_input"
|
||||
name = "Input dataset"
|
||||
@@ -105,12 +120,14 @@ class InputDataModule( WorkflowModule ):
|
||||
module = Class( trans )
|
||||
module.state = dict( name="Input Dataset" )
|
||||
return module
|
||||
|
||||
@classmethod
|
||||
def from_dict( Class, trans, d, secure=True ):
|
||||
module = Class( trans )
|
||||
state = from_json_string( d["tool_state"] )
|
||||
module.state = dict( name=state.get( "name", "Input Dataset" ) )
|
||||
return module
|
||||
|
||||
@classmethod
|
||||
def from_workflow_step( Class, trans, step ):
|
||||
module = Class( trans )
|
||||
@@ -172,6 +189,7 @@ class InputDataModule( WorkflowModule ):
|
||||
def execute( self, trans, state ):
|
||||
return None, dict( output=state.inputs['input'])
|
||||
|
||||
|
||||
class ToolModule( WorkflowModule ):
|
||||
|
||||
type = "tool"
|
||||
@@ -286,6 +304,7 @@ class ToolModule( WorkflowModule ):
|
||||
|
||||
def get_data_inputs( self ):
|
||||
data_inputs = []
|
||||
|
||||
def callback( input, value, prefixed_name, prefixed_label ):
|
||||
if isinstance( input, DataToolParameter ):
|
||||
data_inputs.append( dict(
|
||||
@@ -293,6 +312,7 @@ class ToolModule( WorkflowModule ):
|
||||
label=prefixed_label,
|
||||
multiple=input.multiple,
|
||||
extensions=input.extensions ) )
|
||||
|
||||
visit_input_values( self.tool.inputs, self.state.inputs, callback )
|
||||
return data_inputs
|
||||
|
||||
@@ -338,6 +358,7 @@ class ToolModule( WorkflowModule ):
|
||||
|
||||
make_runtime_key = incoming.get( 'make_runtime', None )
|
||||
make_buildtime_key = incoming.get( 'make_buildtime', None )
|
||||
|
||||
def item_callback( trans, key, input, value, error, old_value, context ):
|
||||
# Dummy value for Data parameters
|
||||
if isinstance( input, DataToolParameter ):
|
||||
@@ -354,6 +375,7 @@ class ToolModule( WorkflowModule ):
|
||||
return value, None
|
||||
else:
|
||||
return value, error
|
||||
|
||||
# Update state using incoming values
|
||||
errors = self.tool.update_state( self.trans, self.tool.inputs, self.state.inputs, incoming, item_callback=item_callback )
|
||||
self.errors = errors or None
|
||||
@@ -370,6 +392,7 @@ class ToolModule( WorkflowModule ):
|
||||
input_connections_by_name = {}
|
||||
# Any connected input needs to have value DummyDataset (these
|
||||
# are not persisted so we need to do it every time)
|
||||
|
||||
def callback( input, value, prefixed_name, prefixed_label ):
|
||||
replacement = None
|
||||
if isinstance( input, DataToolParameter ):
|
||||
@@ -379,9 +402,12 @@ class ToolModule( WorkflowModule ):
|
||||
else:
|
||||
replacement = DummyDataset()
|
||||
return replacement
|
||||
|
||||
visit_input_values( self.tool.inputs, self.state.inputs, callback )
|
||||
|
||||
|
||||
class WorkflowModuleFactory( object ):
|
||||
|
||||
def __init__( self, module_types ):
|
||||
self.module_types = module_types
|
||||
|
||||
|
||||
Reference in New Issue
Block a user