commit/galaxy-central: greg: Enhancements to tool shed containers to enable features when tool shed repositories are installed in Galaxy.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/c159eafdf9d3/ changeset: c159eafdf9d3 user: greg date: 2012-12-20 23:39:31 summary: Enhancements to tool shed containers to enable features when tool shed repositories are installed in Galaxy. affected #: 5 files diff -r 4971f90034e88ff9397adcc2cf406d20f09c2714 -r c159eafdf9d3e97e12b7c9db53509f13842c5b96 lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -493,20 +493,29 @@ missing_tool_dependencies = {} for td_key, val in all_tool_dependencies.items(): if td_key in [ 'set_environment' ]: - for td_info_dict in val: + for index, td_info_dict in enumerate( val ): name = td_info_dict[ 'name' ] version = None type = td_info_dict[ 'type' ] - tool_dependency = get_tool_dependency_by_name_type_repository( trans, repository, name, type ) + tool_dependency = get_tool_dependency_by_name_type_repository( trans, repository, name, type ) + if tool_dependency: + td_info_dict[ 'status' ] = str( tool_dependency.status ) + val[ index ] = td_info_dict + if tool_dependency.status == trans.model.ToolDependency.installation_status.INSTALLED: + tool_dependencies[ td_key ] = val + else: + missing_tool_dependencies[ td_key ] = val else: name = val[ 'name' ] version = val[ 'version' ] type = val[ 'type' ] tool_dependency = get_tool_dependency_by_name_version_type_repository( trans, repository, name, version, type ) - if tool_dependency and tool_dependency.status == trans.model.ToolDependency.installation_status.INSTALLED: - tool_dependencies[ td_key ] = val - else: - missing_tool_dependencies[ td_key ] = val + val[ 'status' ] = str( tool_dependency.status ) + if tool_dependency: + if tool_dependency.status == trans.model.ToolDependency.installation_status.INSTALLED: + tool_dependencies[ td_key ] = val + else: + missing_tool_dependencies[ td_key ] = val else: tool_dependencies = None missing_tool_dependencies = None diff -r 4971f90034e88ff9397adcc2cf406d20f09c2714 -r c159eafdf9d3e97e12b7c9db53509f13842c5b96 lib/galaxy/util/shed_util_common.py --- a/lib/galaxy/util/shed_util_common.py +++ b/lib/galaxy/util/shed_util_common.py @@ -87,6 +87,12 @@ tool_dependencies=None, valid_tools=None, workflows=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: + repository_id = repository.id + else: + repository_id = None lock = threading.Lock() lock.acquire( True ) if tool_dependencies: @@ -125,12 +131,26 @@ containers_dict[ 'repository_dependencies' ] = repository_dependencies_root_folder # Tool dependencies container. if tool_dependencies: - folder_id, tool_dependencies_root_folder = container_util.build_tool_dependencies_folder( folder_id, tool_dependencies, for_galaxy=True ) + # We only want to display the Status column if the tool_dependency is missing. + description = 'click the name to browse the dependency installation directory' + folder_id, tool_dependencies_root_folder = container_util.build_tool_dependencies_folder( folder_id, + tool_dependencies, + for_galaxy=True, + repository_id=repository_id , + description=description, + display_status=False ) containers_dict[ 'tool_dependencies' ] = tool_dependencies_root_folder # Missing tool dependencies container. if missing_tool_dependencies: - folder_id, missing_tool_dependencies_root_folder = \ - container_util.build_tool_dependencies_folder( folder_id, missing_tool_dependencies, label='Missing tool dependencies', for_galaxy=True ) + description = 'click the name to install the missing dependency' + # We only want to display the Status column if the tool_dependency is missing. + folder_id, missing_tool_dependencies_root_folder = container_util.build_tool_dependencies_folder( folder_id, + missing_tool_dependencies, + label='Missing tool dependencies', + for_galaxy=True, + repository_id=repository_id, + description=description, + display_status=True ) containers_dict[ 'missing_tool_dependencies' ] = missing_tool_dependencies_root_folder # Valid tools container. if valid_tools: @@ -197,7 +217,12 @@ # Tool dependencies container. if metadata and 'tool_dependencies' in metadata: tool_dependencies = metadata[ 'tool_dependencies' ] - folder_id, tool_dependencies_root_folder = container_util.build_tool_dependencies_folder( folder_id, tool_dependencies, for_galaxy=False ) + folder_id, tool_dependencies_root_folder = container_util.build_tool_dependencies_folder( folder_id, + tool_dependencies, + for_galaxy=False, + repository_id=None, + description=None, + display_status=False ) containers_dict[ 'tool_dependencies' ] = tool_dependencies_root_folder # Valid tools container. if metadata and 'tools' in metadata: @@ -2441,26 +2466,28 @@ return file_name def to_safe_string( text, to_html=True ): """Translates the characters in text to an html string""" - translated = [] - for c in text: - if c in VALID_CHARS: - translated.append( c ) - elif c in MAPPED_CHARS: - translated.append( MAPPED_CHARS[ c ] ) - elif c in [ '\n' ]: - if to_html: - translated.append( '<br/>' ) + if text: + translated = [] + for c in text: + if c in VALID_CHARS: + translated.append( c ) + elif c in MAPPED_CHARS: + translated.append( MAPPED_CHARS[ c ] ) + elif c in [ '\n' ]: + if to_html: + translated.append( '<br/>' ) + else: + translated.append( c ) + elif c in [ '\r' ]: + continue + elif c in [ ' ', ' ' ]: + translated.append( c ) else: - translated.append( c ) - elif c in [ '\r' ]: - continue - elif c in [ ' ', ' ' ]: - translated.append( c ) - else: - translated.append( '' ) - if to_html: - str( markupsafe.escape( ''.join( translated ) ) ) - return ''.join( translated ) + translated.append( '' ) + if to_html: + str( markupsafe.escape( ''.join( translated ) ) ) + return ''.join( translated ) + return text def tool_shed_from_repository_clone_url( repository_clone_url ): return clean_repository_clone_url( repository_clone_url ).split( 'repos' )[ 0 ].rstrip( '/' ) def tool_shed_is_this_tool_shed( toolshed_base_url ): diff -r 4971f90034e88ff9397adcc2cf406d20f09c2714 -r c159eafdf9d3e97e12b7c9db53509f13842c5b96 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 @@ -71,12 +71,13 @@ class RepositoryDependency( object ): """Repository dependency object""" - def __init__( self, id=None, toolshed=None, repository_name=None, repository_owner=None, changeset_revision=None ): + def __init__( self, id=None, toolshed=None, repository_name=None, repository_owner=None, changeset_revision=None, installation_status=None ): self.id = id self.toolshed = toolshed self.repository_name = repository_name self.repository_owner = repository_owner self.changeset_revision = changeset_revision + self.installation_status = installation_status @property def listify( self ): return [ self.toolshed, self.repository_name, self.repository_owner, self.changeset_revision ] @@ -97,13 +98,15 @@ class ToolDependency( object ): """Tool dependency object""" - def __init__( self, id=None, name=None, version=None, type=None, install_dir=None, readme=None ): + def __init__( self, id=None, name=None, version=None, type=None, install_dir=None, readme=None, installation_status=None, repository_id=None, ): self.id = id self.name = name self.version = version self.type = type self.install_dir = install_dir self.readme = readme + self.installation_status = installation_status + self.repository_id = repository_id class Workflow( object ): """Workflow object""" @@ -115,7 +118,7 @@ self.format_version = format_version self.annotation = annotation -def build_datatypes_folder( folder_id, datatypes, label='Datatypes' ): +def build_datatypes_folder( folder_id, datatypes, label='Datatypes', description=None ): """Return a folder hierarchy containing datatypes.""" if datatypes: datatype_id = 0 @@ -123,6 +126,8 @@ datatypes_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 folder = Folder( id=folder_id, key='datatypes', label=label, parent=datatypes_root_folder ) + if description: + folder.description = description datatypes_root_folder.folders.append( folder ) # Insert a header row. datatype_id += 1 @@ -143,7 +148,7 @@ else: datatypes_root_folder = None return folder_id, datatypes_root_folder -def build_invalid_tools_folder( folder_id, invalid_tool_configs, changeset_revision, repository=None, label='Invalid tools' ): +def build_invalid_tools_folder( folder_id, invalid_tool_configs, changeset_revision, repository=None, label='Invalid tools', description=None ): """Return a folder hierarchy containing invalid tools.""" # TODO: Should we display invalid tools on the tool panel selection page when installing the repository into Galaxy? if invalid_tool_configs: @@ -152,6 +157,8 @@ invalid_tools_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 folder = Folder( id=folder_id, key='invalid_tools', label=label, parent=invalid_tools_root_folder ) + if description: + folder.description = description invalid_tools_root_folder.folders.append( folder ) for invalid_tool_config in invalid_tool_configs: invalid_tool_id += 1 @@ -167,7 +174,7 @@ else: invalid_tools_root_folder = None return folder_id, invalid_tools_root_folder -def build_readme_files_folder( folder_id, readme_files_dict, label='Readme files' ): +def build_readme_files_folder( folder_id, readme_files_dict, label='Readme files', description=None ): """Return a folder hierarchy containing readme text files.""" if readme_files_dict: multiple_readme_files = len( readme_files_dict ) > 1 @@ -177,6 +184,8 @@ if multiple_readme_files: folder_id += 1 readme_files_folder = Folder( id=folder_id, key='readme_files', label=label, parent=readme_files_root_folder ) + if description: + readme_files_folder.description = description readme_files_root_folder.folders.append( readme_files_folder ) for readme_file_name, readme_file_text in readme_files_dict.items(): readme_id += 1 @@ -195,7 +204,7 @@ readme_files_root_folder = None return folder_id, readme_files_root_folder def build_repository_dependencies_folder( toolshed_base_url, repository_name, repository_owner, changeset_revision, folder_id, repository_dependencies, - label='Repository dependencies' ): + label='Repository dependencies', description=None ): """Return a folder hierarchy containing repository dependencies.""" if repository_dependencies: repository_dependency_id = 0 @@ -206,6 +215,8 @@ # Create the Repository dependencies folder and add it to the root folder. repository_dependencies_folder_key = repository_dependencies[ 'root_key' ] repository_dependencies_folder = Folder( id=folder_id, key=repository_dependencies_folder_key, label=label, parent=repository_dependencies_root_folder ) + if description: + repository_dependencies_folder.description = description del repository_dependencies[ 'root_key' ] # The received repository_dependencies is a dictionary with keys: 'root_key', 'description', and one or more repository_dependency keys. # We want the description value associated with the repository_dependencies_folder. @@ -268,7 +279,8 @@ else: tools_root_folder = None return folder_id, tools_root_folder -def build_tool_dependencies_folder( folder_id, tool_dependencies, label='Tool dependencies', for_galaxy=False ): +def build_tool_dependencies_folder( folder_id, tool_dependencies, label='Installed tool dependencies', for_galaxy=False, repository_id=None, description=None, + display_status=False ): """Return a folder hierarchy containing tool dependencies.""" if tool_dependencies: tool_dependency_id = 0 @@ -276,6 +288,8 @@ tool_dependencies_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 folder = Folder( id=folder_id, key='tool_dependencies', label=label, parent=tool_dependencies_root_folder ) + if description: + folder.description = description tool_dependencies_root_folder.folders.append( folder ) # Insert a header row. tool_dependency_id += 1 @@ -285,12 +299,19 @@ name='Name', version='Version', type='Type', - install_dir='Install directory' ) + repository_id=repository_id ) + if display_status: + tool_dependency.installation_status = 'Status' + else: + tool_dependency.install_dir = 'Install directory' else: tool_dependency = ToolDependency( id=tool_dependency_id, name='Name', version='Version', - type='Type' ) + type='Type', + repository_id=repository_id ) + if display_status: + tool_dependency.installation_status = 'Status' folder.tool_dependencies.append( tool_dependency ) for dependency_key, requirements_dict in tool_dependencies.items(): tool_dependency_id += 1 @@ -298,25 +319,37 @@ for set_environment_dict in requirements_dict: name = set_environment_dict[ 'name' ] type = set_environment_dict[ 'type' ] + if display_status: + installation_status = set_environment_dict[ 'status' ] + else: + installation_status = None tool_dependency = ToolDependency( id=tool_dependency_id, name=name, - type=type ) + type=type, + installation_status=installation_status, + repository_id=repository_id ) folder.tool_dependencies.append( tool_dependency ) else: name = requirements_dict[ 'name' ] version = requirements_dict[ 'version' ] type = requirements_dict[ 'type' ] install_dir = requirements_dict.get( 'install_dir', None ) + if display_status: + installation_status = requirements_dict[ 'status' ] + else: + installation_status = None tool_dependency = ToolDependency( id=tool_dependency_id, name=name, version=version, type=type, - install_dir=install_dir ) + install_dir=install_dir, + installation_status=installation_status, + repository_id=repository_id ) folder.tool_dependencies.append( tool_dependency ) else: tool_dependencies_root_folder = None return folder_id, tool_dependencies_root_folder -def build_workflows_folder( folder_id, workflows, repository_metadata, label='Workflows' ): +def build_workflows_folder( folder_id, workflows, repository_metadata, label='Workflows', description=None ): """Return a folder hierarchy containing invalid tools.""" if workflows: workflow_id = 0 @@ -324,6 +357,8 @@ workflows_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 folder = Folder( id=folder_id, key='workflows', label=label, parent=workflows_root_folder ) + if description: + folder.description = description workflows_root_folder.folders.append( folder ) # Insert a header row. workflow_id += 1 diff -r 4971f90034e88ff9397adcc2cf406d20f09c2714 -r c159eafdf9d3e97e12b7c9db53509f13842c5b96 templates/webapps/community/repository/common.mako --- a/templates/webapps/community/repository/common.mako +++ b/templates/webapps/community/repository/common.mako @@ -203,6 +203,12 @@ folder_label = str( folder.label ) if folder.datatypes: col_span_str = 'colspan="4"' + elif folder.label == 'Missing tool dependencies': + if folder.description: + folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description ) + else: + folder_label = "%s<i> - this repository's tools require handling of these missing dependencies</i>" % folder_label + col_span_str = 'colspan="5"' elif folder.label == 'Repository dependencies': if folder.description: folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description ) @@ -217,8 +223,11 @@ elif folder.invalid_tools: folder_label = "%s<i> - click the tool config file name to see why the tool is invalid</i>" % folder_label elif folder.tool_dependencies: - folder_label = "%s<i> - this repository's tools require handling of these dependencies</i>" % folder_label - col_span_str = 'colspan="3"' + if folder.description: + folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description ) + else: + folder_label = "%s<i> - this repository's tools require handling of these dependencies</i>" % folder_label + col_span_str = 'colspan="4"' elif folder.workflows: col_span_str = 'colspan="4"' %> @@ -418,7 +427,24 @@ parent="${parent}" %endif id="libraryItem-${encoded_id}"> - <${cell_type} style="padding-left: ${pad+20}px;">${tool_dependency.name | h}</${cell_type}> + <${cell_type} style="padding-left: ${pad+20}px;"> + %if row_is_header: + ${tool_dependency.name | h} + %elif tool_dependency.repository_id: + %if not tool_dependency.installation_status: + ## tool_dependency.installation_status will be None if the status value in the database is 'Installed'. + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='browse_tool_dependency', id=trans.security.encode_id( tool_dependency.id ), repository_id=trans.security.encode_id( tool_dependency.repository_id ) )}"> + ${tool_dependency.name | h} + </a> + %else: + <a class="action-button" href="${h.url_for( controller='admin_toolshed', action='manage_tool_dependencies', id=trans.security.encode_id( tool_dependency.id ) )}"> + ${tool_dependency.name} + </a> + %endif + %else: + ${tool_dependency.name | h} + %endif + </${cell_type}><${cell_type}><% if tool_dependency.version: @@ -432,6 +458,9 @@ %if tool_dependency.install_dir: <${cell_type}>${tool_dependency.install_dir | h}</${cell_type}> %endif + %if tool_dependency.installation_status not in [ 'Installed', None ]: + <${cell_type}>${tool_dependency.installation_status | h}</${cell_type}> + %endif </tr><% my_row = row_counter.count diff -r 4971f90034e88ff9397adcc2cf406d20f09c2714 -r c159eafdf9d3e97e12b7c9db53509f13842c5b96 test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py --- a/test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py +++ b/test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py @@ -62,7 +62,9 @@ self.browse_tool_shed( url=self.url, strings_displayed=[ 'Test 0010 Repository With Tool Dependencies' ] ) category = test_db_util.get_category_by_name( 'Test 0010 Repository With Tool Dependencies' ) self.browse_category( category, strings_displayed=[ 'freebayes_0010' ] ) - self.preview_repository_in_tool_shed( 'freebayes_0010', common.test_user_1_name, strings_displayed=[ 'freebayes_0010', 'Valid tools', 'Tool dependencies' ] ) + self.preview_repository_in_tool_shed( 'freebayes_0010', common.test_user_1_name, strings_displayed=[ 'freebayes_0010', + 'Valid tools', + 'Installed tool dependencies' ] ) def test_0015_install_freebayes_repository( self ): '''Install the freebayes repository without installing tool dependencies.''' strings_displayed=[ 'set your tool_dependency_dir', 'can be automatically installed', 'Set the tool_dependency_dir' ] 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