From 6b464c49f339b91a7d956446cd5234058302fec0 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 30 May 2014 16:12:40 -0500 Subject: [PATCH] All tool_data_table paths must now be declared with field name "path"... ... or they will not work correctly with the LWR. This is making explicit a convention that was already followed by all devteam tools. If need arises for multiple paths in the same data table or there is an important tool out there that does not label it's paths as "path" let me know and we can try to implement some XML markup in the tool_data_table.xml file to declare these fields as paths. Use new assumption to cleanup what LWR considers unstructured paths (unstructured paths is no longer even a good name for this concept unfortunately). --- .../jobs/runners/lwr_client/path_mapper.py | 3 --- lib/galaxy/tools/wrappers.py | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/jobs/runners/lwr_client/path_mapper.py b/lib/galaxy/jobs/runners/lwr_client/path_mapper.py index 9ff70d29209..758c0901638 100644 --- a/lib/galaxy/jobs/runners/lwr_client/path_mapper.py +++ b/lib/galaxy/jobs/runners/lwr_client/path_mapper.py @@ -53,9 +53,6 @@ class PathMapper(object): return remote_path def check_for_arbitrary_rewrite(self, local_path): - if not os.path.exists(local_path): - return None, [] - path = str(local_path) # Use false_path if needed. action = self.action_mapper.action(path, path_type.UNSTRUCTURED) if not action.staging_needed: diff --git a/lib/galaxy/tools/wrappers.py b/lib/galaxy/tools/wrappers.py index 62f4f8ce679..2001966761c 100644 --- a/lib/galaxy/tools/wrappers.py +++ b/lib/galaxy/tools/wrappers.py @@ -5,6 +5,15 @@ from galaxy.util import odict from logging import getLogger log = getLogger( __name__ ) +# Fields in .log files corresponding to paths, must have one of the following +# field names and all such fields are assumed to be paths. This is to allow +# remote ComputeEnvironments (such as one used by LWR) determine what values to +# rewrite or transfer... +PATH_ATTRIBUTES = [ "path" ] +# ... by default though - don't rewrite anything (if no ComputeEnviornment +# defined or ComputeEnvironment doesn't supply a rewriter). +DEFAULT_PATH_REWRITER = lambda x: x + class ToolParameterValueWrapper( object ): """ @@ -88,9 +97,6 @@ class InputValueWrapper( ToolParameterValueWrapper ): return getattr( self.value, key ) -DEFAULT_PATH_REWRITER = lambda x: x - - class SelectToolParameterWrapper( ToolParameterValueWrapper ): """ Wraps a SelectTooParameter so that __str__ returns the selected value, but all other @@ -112,7 +118,11 @@ class SelectToolParameterWrapper( ToolParameterValueWrapper ): def __getattr__( self, name ): if name not in self._fields: self._fields[ name ] = self._input.options.get_field_by_name_for_value( name, self._value, None, self._other_values ) - return self._input.separator.join( map( self._path_rewriter, map( str, self._fields[ name ] ) ) ) + values = map( str, self._fields[ name ] ) + if name in PATH_ATTRIBUTES: + # If we infer this is a path, rewrite it if needed. + values = map( self._path_rewriter, values ) + return self._input.separator.join( values ) def __init__( self, input, value, app, other_values={}, path_rewriter=None ): self.input = input @@ -123,7 +133,9 @@ class SelectToolParameterWrapper( ToolParameterValueWrapper ): self.fields = self.SelectToolParameterFieldWrapper( input, value, other_values, self._path_rewriter ) def __str__( self ): - return self.input.to_param_dict_string( self.value, other_values=self._other_values, value_map=self._path_rewriter ) + # Assuming value is never a path - otherwise would need to pass + # along following argument value_map=self._path_rewriter. + return self.input.to_param_dict_string( self.value, other_values=self._other_values ) def __getattr__( self, key ): return getattr( self.input, key )