commit/galaxy-central: dan: Display Data Managers on repository info pagses in Tool Shed and Galaxy.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7d0a0ca401f7/ changeset: 7d0a0ca401f7 user: dan date: 2013-02-18 19:46:08 summary: Display Data Managers on repository info pagses in Tool Shed and Galaxy. affected #: 4 files diff -r 852b9d795423015cba17d6c0d5b402f1055404dd -r 7d0a0ca401f7cee8b2862c4191f4c1c073cc538d lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -1415,6 +1415,14 @@ valid_tools = metadata.get( 'tools', None ) # Handle workflows. workflows = metadata.get( 'workflows', None ) + # Handle Data Managers + valid_data_managers = None + invalid_data_managers = None + data_manager_errors = None + if 'data_manager' in metadata: + valid_data_managers = metadata['data_manager'].get( 'data_managers', None ) + invalid_data_managers = metadata['data_manager'].get( 'invalid_data_managers', None ) + data_managers_errors = metadata['data_manager'].get( 'messages', None ) containers_dict = suc.build_repository_containers_for_galaxy( trans=trans, repository=repository, datatypes=datatypes, @@ -1426,6 +1434,9 @@ tool_dependencies=installed_tool_dependencies, valid_tools=valid_tools, workflows=workflows, + valid_data_managers=valid_data_managers, + invalid_data_managers=invalid_data_managers, + data_managers_errors=data_managers_errors, new_install=False, reinstalling=reinstalling ) else: @@ -1458,6 +1469,9 @@ tool_dependencies=installed_tool_dependencies, valid_tools=None, workflows=None, + valid_data_managers=None, + invalid_data_managers=None, + data_managers_errors=None, new_install=True, reinstalling=False ) # Merge the missing_repository_dependencies container contents to the installed_repository_dependencies container. diff -r 852b9d795423015cba17d6c0d5b402f1055404dd -r 7d0a0ca401f7cee8b2862c4191f4c1c073cc538d lib/galaxy/util/shed_util_common.py --- a/lib/galaxy/util/shed_util_common.py +++ b/lib/galaxy/util/shed_util_common.py @@ -188,8 +188,8 @@ log.debug( "Error reading README file '%s' defined in metadata: %s" % ( str( relative_path_to_readme_file ), str( e ) ) ) return readme_files_dict def build_repository_containers_for_galaxy( trans, repository, datatypes, invalid_tools, missing_repository_dependencies, missing_tool_dependencies, - readme_files_dict, repository_dependencies, tool_dependencies, valid_tools, workflows, new_install=False, - reinstalling=False ): + readme_files_dict, repository_dependencies, tool_dependencies, valid_tools, workflows, valid_data_managers, + invalid_data_managers, data_managers_errors, new_install=False, reinstalling=False ): """Return a dictionary of containers for the received repository's dependencies and readme files for display during installation to Galaxy.""" containers_dict = dict( datatypes=None, invalid_tools=None, @@ -199,7 +199,9 @@ missing_repository_dependencies=None, tool_dependencies=None, valid_tools=None, - workflows=None ) + workflows=None, + valid_data_managers=None, + invalid_data_managers=None ) # Some of the tool dependency folders will include links to display tool dependency information, and some of these links require the repository # id. However we need to be careful because sometimes the repository object is None. if repository: @@ -294,6 +296,19 @@ repository_id=repository_id, label='Workflows' ) containers_dict[ 'workflows' ] = workflows_root_folder + if valid_data_managers: + folder_id, valid_data_managers_root_folder = container_util.build_data_managers_folder( trans=trans, + folder_id=folder_id, + data_managers=valid_data_managers, + label='Valid Data Managers' ) + containers_dict[ 'valid_data_managers' ] = valid_data_managers_root_folder + if invalid_data_managers or data_managers_errors: + folder_id, invalid_data_managers_root_folder = container_util.build_invalid_data_managers_folder( trans=trans, + folder_id=folder_id, + data_managers=invalid_data_managers, + error_messages=data_managers_errors, + label='Invalid Data Managers' ) + containers_dict[ 'invalid_data_managers' ] = invalid_data_managers_root_folder except Exception, e: log.debug( "Exception in build_repository_containers_for_galaxy: %s" % str( e ) ) finally: @@ -307,7 +322,9 @@ repository_dependencies=None, tool_dependencies=None, valid_tools=None, - workflows=None ) + workflows=None, + valid_data_managers=None + ) if repository_metadata: metadata = repository_metadata.metadata lock = threading.Lock() @@ -399,6 +416,17 @@ repository_id=None, label='Workflows' ) containers_dict[ 'workflows' ] = workflows_root_folder + # Valid Data Managers container + if metadata: + if 'data_manager' in metadata: + data_managers = metadata['data_manager'].get( 'data_managers', None ) + folder_id, data_managers_root_folder = container_util.build_data_managers_folder( trans, folder_id, data_managers, label="Data Managers" ) + containers_dict[ 'valid_data_managers' ] = data_managers_root_folder + error_messages = metadata['data_manager'].get( 'error_messages', None ) + data_managers = metadata['data_manager'].get( 'invalid_data_managers', None ) + folder_id, data_managers_root_folder = container_util.build_invalid_data_managers_folder( trans, folder_id, data_managers, error_messages, label="Invalid Data Managers" ) + containers_dict[ 'invalid_data_managers' ] = data_managers_root_folder + except Exception, e: log.debug( "Exception in build_repository_containers_for_tool_shed: %s" % str( e ) ) finally: @@ -1044,20 +1072,6 @@ """Update the received metadata_dict with information from the parsed data_manager_config_filename.""" if data_manager_config_filename is None: return metadata_dict - try: - tree = util.parse_xml( data_manager_config_filename ) - except Exception, e: - log.error( 'There was an error parsing your Data Manager config file "%s": %s' % ( data_manager_config_filename, e ) ) - return metadata_dict #we are not able to load any data managers - tool_path = None - if shed_config_dict: - tool_path = shed_config_dict.get( 'tool_path', None ) - tools = {} - for tool in metadata_dict.get( 'tools', [] ): - tool_conf_name = tool['tool_config'] - if tool_path: - tool_conf_name = os.path.join( tool_path, tool_conf_name ) - tools[tool_conf_name] = tool repo_path = repository.repo_path( app ) try: #Galaxy Side @@ -1071,37 +1085,65 @@ relative_data_manager_dir = util.relpath( os.path.split( data_manager_config_filename )[0], repo_dir ) rel_data_manager_config_filename = os.path.join( relative_data_manager_dir, os.path.split( data_manager_config_filename )[1] ) data_managers = {} - data_manager_metadata = { 'config_filename': rel_data_manager_config_filename, 'data_managers': data_managers }#'tool_config_files': tool_files } + invalid_data_managers = [] + data_manager_metadata = { 'config_filename': rel_data_manager_config_filename, 'data_managers': data_managers, 'invalid_data_managers': invalid_data_managers, 'error_messages': [] }#'tool_config_files': tool_files } metadata_dict[ 'data_manager' ] = data_manager_metadata + try: + tree = util.parse_xml( data_manager_config_filename ) + except Exception, e: + error_message = 'There was an error parsing your Data Manager config file "%s": %s' % ( data_manager_config_filename, e ) + log.error( error_message ) + data_manager_metadata['error_messages'].append( error_message ) + return metadata_dict #we are not able to load any data managers + tool_path = None + if shed_config_dict: + tool_path = shed_config_dict.get( 'tool_path', None ) + tools = {} + for tool in metadata_dict.get( 'tools', [] ): + tool_conf_name = tool['tool_config'] + if tool_path: + tool_conf_name = os.path.join( tool_path, tool_conf_name ) + tools[tool_conf_name] = tool root = tree.getroot() data_manager_tool_path = root.get( 'tool_path', None ) if data_manager_tool_path: relative_data_manager_dir = os.path.join( relative_data_manager_dir, data_manager_tool_path ) - for data_manager_elem in root.findall( 'data_manager' ): + for i, data_manager_elem in enumerate( root.findall( 'data_manager' ) ): tool_file = data_manager_elem.get( 'tool_file', None ) data_manager_id = data_manager_elem.get( 'id', None ) if data_manager_id is None: log.error( 'Data Manager entry is missing id attribute in "%s".' % ( data_manager_config_filename ) ) + invalid_data_managers.append( { 'index': i, 'error_message': 'Data Manager entry is missing id attribute' } ) continue + data_manager_name = data_manager_elem.get( 'name', data_manager_id ) #fix me, default behavior is to fall back to tool.name version = data_manager_elem.get( 'version', DataManager.DEFAULT_VERSION ) guid = generate_guid_for_object( repository_clone_url, DataManager.GUID_TYPE, data_manager_id, version ) data_tables = [] if tool_file is None: log.error( 'Data Manager entry is missing tool_file attribute in "%s".' % ( data_manager_config_filename ) ) + invalid_data_managers.append( { 'index': i, 'error_message': 'Data Manager entry is missing tool_file attribute' } ) + continue else: + bad_data_table = False for data_table_elem in data_manager_elem.findall( 'data_table' ): data_table_name = data_table_elem.get( 'name', None ) if data_table_name is None: - log.error( 'Data Manager data_table entry is name attribute in "%s".' % ( data_manager_config_filename ) ) + log.error( 'Data Manager data_table entry is missing name attribute in "%s".' % ( data_manager_config_filename ) ) + invalid_data_managers.append( { 'index': i, 'error_message': 'Data Manager entry is missing name attribute' } ) + bad_data_table = True + break else: data_tables.append( data_table_name ) + if bad_data_table: + continue data_manager_metadata_tool_file = os.path.join( relative_data_manager_dir, tool_file ) tool_metadata_tool_file = os.path.join( repo_files_directory, data_manager_metadata_tool_file ) tool = tools.get( tool_metadata_tool_file, None ) if tool is None: log.error( "Unable to determine tools metadata for '%s'." % ( data_manager_metadata_tool_file ) ) + invalid_data_managers.append( { 'index': i, 'error_message': 'Unable to determine tools metadata' } ) continue - data_managers[ data_manager_id ] = { 'guid': guid, 'version': version, 'tool_config_file': data_manager_metadata_tool_file, 'data_tables': data_tables, 'tool_guid': tool['guid'] } + data_managers[ data_manager_id ] = { 'id': data_manager_id, 'name': data_manager_name, 'guid': guid, 'version': version, 'tool_config_file': data_manager_metadata_tool_file, 'data_tables': data_tables, 'tool_guid': tool['guid'] } log.debug( 'Loaded Data Manager tool_files: %s' % ( tool_file ) ) return metadata_dict def generate_datatypes_metadata( datatypes_config, metadata_dict ): diff -r 852b9d795423015cba17d6c0d5b402f1055404dd -r 7d0a0ca401f7cee8b2862c4191f4c1c073cc538d lib/galaxy/webapps/community/util/container_util.py --- a/lib/galaxy/webapps/community/util/container_util.py +++ b/lib/galaxy/webapps/community/util/container_util.py @@ -19,6 +19,8 @@ self.invalid_tool_dependencies = [] self.invalid_tools = [] self.valid_tools = [] + self.valid_data_managers = [] + self.invalid_data_managers = [] self.tool_dependencies = [] self.repository_dependencies = [] self.readme_files = [] @@ -47,6 +49,14 @@ repository_owner=owner, changeset_revision=changeset_revision ) +class DataManager( object ): + """Data Manager object""" + def __init__( self, id=None, name=None, version=None, data_tables=None ): + self.id = id + self.name = name + self.version = version + self.data_tables = data_tables + class Datatype( object ): """Datatype object""" def __init__( self, id=None, extension=None, type=None, mimetype=None, subclass=None ): @@ -56,6 +66,13 @@ self.mimetype = mimetype self.subclass = subclass +class InvalidDataManager( object ): + """Data Manager object""" + def __init__( self, id=None, index=None, error=None ): + self.id = id + self.index = index + self.error = error + class InvalidRepositoryDependency( object ): """Invalid repository dependency definition object""" def __init__( self, id=None, toolshed=None, repository_name=None, repository_owner=None, changeset_revision=None, error=None ): @@ -151,6 +168,35 @@ self.repository_metadata_id = repository_metadata_id self.repository_id = repository_id +def build_data_managers_folder( trans, folder_id, data_managers, label=None ): + """Return a folder hierarchy containing Data Managers.""" + if data_managers: + if label is None: + label = "Data Managers" + data_manager_id = 0 + folder_id += 1 + data_managers_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) + folder_id += 1 + key = "valid_data_managers" + folder = Folder( id=folder_id, key=key, label=label, parent=data_managers_root_folder ) + data_managers_root_folder.folders.append( folder ) + # Insert a header row. + data_manager_id += 1 + data_manager = DataManager( id=data_manager_id, + name='Name', + version='Version', + data_tables='Data Tables' ) + folder.valid_data_managers.append( data_manager ) + for data_manager_dict in data_managers.itervalues(): + data_manager_id += 1 + data_manager = DataManager( id=data_manager_id, + name=data_manager_dict.get( 'name', '' ), + version=data_manager_dict.get( 'version', '' ), + data_tables=", ".join( data_manager_dict.get( 'data_tables', '' ) ) ) + folder.valid_data_managers.append( data_manager ) + else: + data_managers_root_folder = None + return folder_id, data_managers_root_folder def build_datatypes_folder( trans, folder_id, datatypes, label='Datatypes' ): """Return a folder hierarchy containing datatypes.""" if datatypes: @@ -179,6 +225,42 @@ else: datatypes_root_folder = None return folder_id, datatypes_root_folder +def build_invalid_data_managers_folder( trans, folder_id, data_managers, error_messages=None, label=None ): + """Return a folder hierarchy containing invalid Data Managers.""" + if data_managers or error_messages: + if label is None: + label = "Invalid Data Managers" + data_manager_id = 0 + folder_id += 1 + data_managers_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) + folder_id += 1 + key = "invalid_data_managers" + folder = Folder( id=folder_id, key=key, label=label, parent=data_managers_root_folder ) + data_managers_root_folder.folders.append( folder ) + # Insert a header row. + data_manager_id += 1 + data_manager = InvalidDataManager( id=data_manager_id, + index='Element Index', + error='Error' ) + folder.invalid_data_managers.append( data_manager ) + if error_messages: + for error_message in error_messages: + data_manager_id += 1 + data_manager = InvalidDataManager( id=data_manager_id, + index=0, + error=error_message ) + folder.invalid_data_managers.append( data_manager ) + has_errors = True + for data_manager_dict in data_managers: + data_manager_id += 1 + data_manager = InvalidDataManager( id=data_manager_id, + index=data_manager_dict.get( 'index', 0 ) + 1, + error=data_manager_dict.get( 'error_message', '' ) ) + folder.invalid_data_managers.append( data_manager ) + has_errors = True + else: + data_managers_root_folder = None + return folder_id, data_managers_root_folder def build_invalid_repository_dependencies_root_folder( trans, folder_id, invalid_repository_dependencies_dict ): """Return a folder hierarchy containing invalid repository dependencies.""" label = 'Invalid repository dependencies' diff -r 852b9d795423015cba17d6c0d5b402f1055404dd -r 7d0a0ca401f7cee8b2862c4191f4c1c073cc538d templates/webapps/community/repository/common.mako --- a/templates/webapps/community/repository/common.mako +++ b/templates/webapps/community/repository/common.mako @@ -248,6 +248,14 @@ else: folder_label = "%s<i> - click the name to view an SVG image of the workflow</i>" % folder_label col_span_str = 'colspan="4"' + elif folder.valid_data_managers: + if folder.description: + folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description ) + col_span_str = 'colspan="3"' + elif folder.invalid_data_managers: + if folder.description: + folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description ) + col_span_str = 'colspan="2"' %><td ${col_span_str} style="padding-left: ${folder_pad}px;"><span class="expandLink folder-${encoded_id}-click"> @@ -305,6 +313,18 @@ ${render_datatype( datatype, pad, my_row, row_counter, row_is_header )} %endfor %endif + %if folder.valid_data_managers: + %for index, data_manager in enumerate( folder.valid_data_managers ): + <% row_is_header = index == 0 %> + ${render_valid_data_manager( data_manager, pad, my_row, row_counter, row_is_header )} + %endfor + %endif + %if folder.invalid_data_managers: + %for index, data_manager in enumerate( folder.invalid_data_managers ): + <% row_is_header = index == 0 %> + ${render_invalid_data_manager( data_manager, pad, my_row, row_counter, row_is_header )} + %endfor + %endif </%def><%def name="render_datatype( datatype, pad, parent, row_counter, row_is_header=False )"> @@ -331,6 +351,51 @@ %></%def> +<%def name="render_valid_data_manager( data_manager, pad, parent, row_counter, row_is_header=False )"> + <% + encoded_id = trans.security.encode_id( data_manager.id ) + if row_is_header: + cell_type = 'th' + else: + cell_type = 'td' + %> + <tr class="datasetRow" + %if parent is not None: + parent="${parent}" + %endif + id="libraryItem-${encoded_id}"> + <${cell_type} style="padding-left: ${pad+20}px;">${data_manager.name | h}</${cell_type}> + <${cell_type}>${data_manager.version | h}</${cell_type}> + <${cell_type}>${data_manager.data_tables | h}</${cell_type}> + </tr> + <% + my_row = row_counter.count + row_counter.increment() + %> +</%def> + +<%def name="render_invalid_data_manager( data_manager, pad, parent, row_counter, row_is_header=False )"> + <% + encoded_id = trans.security.encode_id( data_manager.id ) + if row_is_header: + cell_type = 'th' + else: + cell_type = 'td' + %> + <tr class="datasetRow" + %if parent is not None: + parent="${parent}" + %endif + id="libraryItem-${encoded_id}"> + <${cell_type} style="padding-left: ${pad+20}px;">${data_manager.index | h}</${cell_type}> + <${cell_type}>${data_manager.error | h}</${cell_type}> + </tr> + <% + my_row = row_counter.count + row_counter.increment() + %> +</%def> + <%def name="render_invalid_repository_dependency( invalid_repository_dependency, pad, parent, row_counter )"><% encoded_id = trans.security.encode_id( invalid_repository_dependency.id ) @@ -638,6 +703,8 @@ missing_tool_dependencies_root_folder = containers_dict.get( 'missing_tool_dependencies', None ) valid_tools_root_folder = containers_dict.get( 'valid_tools', None ) workflows_root_folder = containers_dict.get( 'workflows', None ) + valid_data_managers_root_folder = containers_dict.get( 'valid_data_managers', None ) + invalid_data_managers_root_folder = containers_dict.get( 'invalid_data_managers', None ) has_contents = datatypes_root_folder or invalid_tools_root_folder or valid_tools_root_folder or workflows_root_folder has_dependencies = \ @@ -736,6 +803,20 @@ ${render_folder( invalid_tools_root_folder, 0, parent=None, row_counter=row_counter, is_root_folder=True )} </table> %endif + %if valid_data_managers_root_folder: + <p/> + <% row_counter = RowCounter() %> + <table cellspacing="2" cellpadding="2" border="0" width="100%" class="tables container-table" id="valid_tools"> + ${render_folder( valid_data_managers_root_folder, 0, parent=None, row_counter=row_counter, is_root_folder=True )} + </table> + %endif + %if invalid_data_managers_root_folder: + <p/> + <% row_counter = RowCounter() %> + <table cellspacing="2" cellpadding="2" border="0" width="100%" class="tables container-table" id="invalid_tools"> + ${render_folder( invalid_data_managers_root_folder, 0, parent=None, row_counter=row_counter, is_root_folder=True )} + </table> + %endif %if workflows_root_folder: <p/><% row_counter = RowCounter() %> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket