commit/galaxy-central: greg: Add a UtilityContainerManager class and subclasses for displaying Tool Shed utility containers.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/a4fc4ba21a25/ Changeset: a4fc4ba21a25 User: greg Date: 2014-07-31 21:27:21 Summary: Add a UtilityContainerManager class and subclasses for displaying Tool Shed utility containers. Affected #: 8 files diff -r 4aba2116bc2de405166d46f034c81eb522cfe4e7 -r a4fc4ba21a254415c6245a23f1842b997c653e31 lib/galaxy/webapps/tool_shed/controllers/repository.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository.py @@ -20,13 +20,13 @@ from tool_shed.galaxy_install import dependency_display from tool_shed.metadata import repository_metadata_manager +from tool_shed.utility_containers import ToolShedUtilityContainerManager from tool_shed.tools import tool_validator from tool_shed.tools import tool_version_manager from tool_shed.util import basic_util from tool_shed.util import common_util -from tool_shed.util import container_util from tool_shed.util import encoding_util from tool_shed.util import hg_util from tool_shed.util import metadata_util @@ -1273,12 +1273,12 @@ # Only display repository dependencies if they exist. exclude = [ 'datatypes', 'invalid_repository_dependencies', 'invalid_tool_dependencies', 'invalid_tools', 'readme_files', 'tool_dependencies', 'tools', 'tool_test_results', 'workflows', 'data_manager' ] - containers_dict = container_util.build_repository_containers_for_tool_shed( trans.app, - repository, - changeset_revision, - repository_dependencies, - repository_metadata, - exclude=exclude ) + tsucm = ToolShedUtilityContainerManager( trans.app ) + containers_dict = tsucm.build_repository_containers( repository, + changeset_revision, + repository_dependencies, + repository_metadata, + exclude=exclude ) export_repository_dependencies_check_box = CheckboxField( 'export_repository_dependencies', checked=True ) else: containers_dict = None @@ -2458,11 +2458,11 @@ skip_tool_tests_check_box = CheckboxField( 'skip_tool_tests', checked=skip_tool_tests_checked ) categories = suc.get_categories( trans.app ) selected_categories = [ rca.category_id for rca in repository.categories ] - containers_dict = container_util.build_repository_containers_for_tool_shed( trans.app, - repository, - changeset_revision, - repository_dependencies, - repository_metadata ) + tsucm = ToolShedUtilityContainerManager( trans.app ) + containers_dict = tsucm.build_repository_containers( repository, + changeset_revision, + repository_dependencies, + repository_metadata ) heads = hg_util.get_repository_heads( repo ) deprecated_repository_dependency_tups = \ metadata_util.get_repository_dependency_tups_from_repository_metadata( trans.app, @@ -2653,11 +2653,11 @@ selected_value=changeset_revision, add_id_to_name=False, downloadable=False ) - containers_dict = container_util.build_repository_containers_for_tool_shed( trans.app, - repository, - changeset_revision, - repository_dependencies, - repository_metadata ) + tsucm = ToolShedUtilityContainerManager( trans.app ) + containers_dict = tsucm.build_repository_containers( repository, + changeset_revision, + repository_dependencies, + repository_metadata ) return trans.fill_template( '/webapps/tool_shed/repository/preview_tools_in_changeset.mako', repository=repository, containers_dict=containers_dict, @@ -3360,11 +3360,11 @@ else: message += malicious_error status = 'error' - containers_dict = container_util.build_repository_containers_for_tool_shed( trans.app, - repository, - changeset_revision, - repository_dependencies, - repository_metadata ) + tsucm = ToolShedUtilityContainerManager( trans.app ) + containers_dict = tsucm.build_repository_containers( repository, + changeset_revision, + repository_dependencies, + repository_metadata ) repository_type_select_field = rt_util.build_repository_type_select_field( trans, repository=repository ) heads = hg_util.get_repository_heads( repo ) return trans.fill_template( '/webapps/tool_shed/repository/view_repository.mako', diff -r 4aba2116bc2de405166d46f034c81eb522cfe4e7 -r a4fc4ba21a254415c6245a23f1842b997c653e31 lib/galaxy/webapps/tool_shed/controllers/repository_review.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository_review.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository_review.py @@ -1,17 +1,26 @@ -import os, logging -from galaxy import web, util +import logging +import os + +from sqlalchemy.sql.expression import func + +from galaxy import util +from galaxy import web + +from galaxy.model.orm import and_ +from galaxy.util.odict import odict from galaxy.web.base.controller import BaseUIController -from galaxy.web.form_builder import SelectField, CheckboxField -from sqlalchemy.sql.expression import func -from galaxy.model.orm import and_ +from galaxy.web.form_builder import CheckboxField +from galaxy.web.form_builder import SelectField + from galaxy.webapps.tool_shed.util import ratings_util + +import tool_shed.grids.repository_review_grids as repository_review_grids +import tool_shed.grids.util as grids_util + from tool_shed.util.container_util import STRSEP -import tool_shed.util.shed_util_common as suc from tool_shed.util import hg_util from tool_shed.util import review_util -from galaxy.util.odict import odict -import tool_shed.grids.repository_review_grids as repository_review_grids -import tool_shed.grids.util as grids_util +from tool_shed.util import shed_util_common as suc log = logging.getLogger( __name__ ) diff -r 4aba2116bc2de405166d46f034c81eb522cfe4e7 -r a4fc4ba21a254415c6245a23f1842b997c653e31 lib/tool_shed/dependencies/repository/relation_builder.py --- a/lib/tool_shed/dependencies/repository/relation_builder.py +++ b/lib/tool_shed/dependencies/repository/relation_builder.py @@ -3,6 +3,7 @@ from galaxy.util import asbool from galaxy.util import listify + from tool_shed.util import common_util from tool_shed.util import container_util from tool_shed.util import hg_util diff -r 4aba2116bc2de405166d46f034c81eb522cfe4e7 -r a4fc4ba21a254415c6245a23f1842b997c653e31 lib/tool_shed/galaxy_install/dependency_display.py --- a/lib/tool_shed/galaxy_install/dependency_display.py +++ b/lib/tool_shed/galaxy_install/dependency_display.py @@ -5,6 +5,9 @@ from galaxy import util +from tool_shed.galaxy_install.utility_containers import GalaxyUtilityContainerManager +from tool_shed.utility_containers import utility_container_manager + from tool_shed.util import common_util from tool_shed.util import container_util from tool_shed.util import readme_util @@ -276,22 +279,23 @@ old_container_repository_dependencies_root = old_container_dict[ 'repository_dependencies' ] if old_container_repository_dependencies_root: if repository_dependencies_root_folder is None: - repository_dependencies_root_folder = container_util.Folder( id=folder_id, - key='root', - label='root', - parent=None ) + repository_dependencies_root_folder = utility_container_manager.Folder( id=folder_id, + key='root', + label='root', + parent=None ) folder_id += 1 - repository_dependencies_folder = container_util.Folder( id=folder_id, - key='merged', - label='Repository dependencies', - parent=repository_dependencies_root_folder ) + repository_dependencies_folder = utility_container_manager.Folder( id=folder_id, + key='merged', + label='Repository dependencies', + parent=repository_dependencies_root_folder ) folder_id += 1 # The old_container_repository_dependencies_root will be a root folder containing a single sub_folder. old_container_repository_dependencies_folder = old_container_repository_dependencies_root.folders[ 0 ] # Change the folder id so it won't confict with others being merged. old_container_repository_dependencies_folder.id = folder_id folder_id += 1 - repository_components_tuple = container_util.get_components_from_key( old_container_repository_dependencies_folder.key ) + repository_components_tuple = \ + container_util.get_components_from_key( old_container_repository_dependencies_folder.key ) components_list = suc.extract_components_from_tuple( repository_components_tuple ) name = components_list[ 1 ] # Generate the label by retrieving the repository name. @@ -301,15 +305,15 @@ old_container_tool_dependencies_root = old_container_dict[ 'tool_dependencies' ] if old_container_tool_dependencies_root: if tool_dependencies_root_folder is None: - tool_dependencies_root_folder = container_util.Folder( id=folder_id, - key='root', - label='root', - parent=None ) + tool_dependencies_root_folder = utility_container_manager.Folder( id=folder_id, + key='root', + label='root', + parent=None ) folder_id += 1 - tool_dependencies_folder = container_util.Folder( id=folder_id, - key='merged', - label='Tool dependencies', - parent=tool_dependencies_root_folder ) + tool_dependencies_folder = utility_container_manager.Folder( id=folder_id, + key='merged', + label='Tool dependencies', + parent=tool_dependencies_root_folder ) folder_id += 1 else: td_list = [ td.listify for td in tool_dependencies_folder.tool_dependencies ] @@ -410,23 +414,22 @@ repository_missing_tool_dependencies=missing_tool_dependencies, required_repo_info_dicts=None ) # Most of the repository contents are set to None since we don't yet know what they are. - containers_dict = \ - container_util.build_repository_containers_for_galaxy( app=self.app, - repository=None, - datatypes=None, - invalid_tools=None, - missing_repository_dependencies=missing_repository_dependencies, - missing_tool_dependencies=missing_tool_dependencies, - readme_files_dict=readme_files_dict, - repository_dependencies=installed_repository_dependencies, - 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 ) + gucm = GalaxyUtilityContainerManager( self.app ) + containers_dict = gucm.build_repository_containers( repository=None, + datatypes=None, + invalid_tools=None, + missing_repository_dependencies=missing_repository_dependencies, + missing_tool_dependencies=missing_tool_dependencies, + readme_files_dict=readme_files_dict, + repository_dependencies=installed_repository_dependencies, + 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 ) if not updating: # If we installing a new repository and not updaing an installed repository, we can merge # the missing_repository_dependencies container contents to the installed_repository_dependencies @@ -508,23 +511,22 @@ 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 = \ - container_util.build_repository_containers_for_galaxy( app=self.app, - repository=repository, - datatypes=datatypes, - invalid_tools=invalid_tools, - missing_repository_dependencies=missing_repository_dependencies, - missing_tool_dependencies=missing_tool_dependencies, - readme_files_dict=readme_files_dict, - repository_dependencies=installed_repository_dependencies, - 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 ) + gucm = GalaxyUtilityContainerManager( self.app ) + containers_dict = gucm.build_repository_containers( repository=repository, + datatypes=datatypes, + invalid_tools=invalid_tools, + missing_repository_dependencies=missing_repository_dependencies, + missing_tool_dependencies=missing_tool_dependencies, + readme_files_dict=readme_files_dict, + repository_dependencies=installed_repository_dependencies, + 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: containers_dict = dict( datatypes=None, invalid_tools=None, diff -r 4aba2116bc2de405166d46f034c81eb522cfe4e7 -r a4fc4ba21a254415c6245a23f1842b997c653e31 lib/tool_shed/galaxy_install/utility_containers/__init__.py --- /dev/null +++ b/lib/tool_shed/galaxy_install/utility_containers/__init__.py @@ -0,0 +1,145 @@ +import logging +import os +import threading + +from tool_shed.utility_containers import utility_container_manager + +log = logging.getLogger( __name__ ) + + +class GalaxyUtilityContainerManager( utility_container_manager.UtilityContainerManager ): + + def __init__( self, app ): + self.app = app + + def build_repository_containers( self, repository, datatypes, invalid_tools, missing_repository_dependencies, + missing_tool_dependencies, 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, + missing_tool_dependencies=None, + readme_files=None, + repository_dependencies=None, + missing_repository_dependencies=None, + tool_dependencies=None, + valid_tools=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: + repository_id = repository.id + changeset_revision = repository.changeset_revision + else: + repository_id = None + changeset_revision = None + lock = threading.Lock() + lock.acquire( True ) + try: + folder_id = 0 + # Datatypes container. + if datatypes: + folder_id, datatypes_root_folder = self.build_datatypes_folder( folder_id, datatypes ) + containers_dict[ 'datatypes' ] = datatypes_root_folder + # Invalid tools container. + if invalid_tools: + folder_id, invalid_tools_root_folder = \ + self.build_invalid_tools_folder( folder_id, + invalid_tools, + changeset_revision, + repository=repository, + label='Invalid tools' ) + containers_dict[ 'invalid_tools' ] = invalid_tools_root_folder + # Readme files container. + if readme_files_dict: + folder_id, readme_files_root_folder = self.build_readme_files_folder( folder_id, readme_files_dict ) + containers_dict[ 'readme_files' ] = readme_files_root_folder + # Installed repository dependencies container. + if repository_dependencies: + if new_install: + label = 'Repository dependencies' + else: + label = 'Installed repository dependencies' + folder_id, repository_dependencies_root_folder = \ + self.build_repository_dependencies_folder( folder_id=folder_id, + repository_dependencies=repository_dependencies, + label=label, + installed=True ) + containers_dict[ 'repository_dependencies' ] = repository_dependencies_root_folder + # Missing repository dependencies container. + if missing_repository_dependencies: + folder_id, missing_repository_dependencies_root_folder = \ + self.build_repository_dependencies_folder( folder_id=folder_id, + repository_dependencies=missing_repository_dependencies, + label='Missing repository dependencies', + installed=False ) + containers_dict[ 'missing_repository_dependencies' ] = missing_repository_dependencies_root_folder + # Installed tool dependencies container. + if tool_dependencies: + if new_install: + label = 'Tool dependencies' + else: + label = 'Installed tool dependencies' + # We only want to display the Status column if the tool_dependency is missing. + folder_id, tool_dependencies_root_folder = \ + self.build_tool_dependencies_folder( folder_id, + tool_dependencies, + label=label, + missing=False, + new_install=new_install, + reinstalling=reinstalling ) + containers_dict[ 'tool_dependencies' ] = tool_dependencies_root_folder + # Missing tool dependencies container. + if missing_tool_dependencies: + # We only want to display the Status column if the tool_dependency is missing. + folder_id, missing_tool_dependencies_root_folder = \ + self.build_tool_dependencies_folder( folder_id, + missing_tool_dependencies, + label='Missing tool dependencies', + missing=True, + new_install=new_install, + reinstalling=reinstalling ) + containers_dict[ 'missing_tool_dependencies' ] = missing_tool_dependencies_root_folder + # Valid tools container. + if valid_tools: + folder_id, valid_tools_root_folder = self.build_tools_folder( folder_id, + valid_tools, + repository, + changeset_revision, + label='Valid tools' ) + containers_dict[ 'valid_tools' ] = valid_tools_root_folder + # Workflows container. + if workflows: + folder_id, workflows_root_folder = \ + self.build_workflows_folder( folder_id=folder_id, + workflows=workflows, + repository_metadata_id=None, + repository_id=repository_id, + label='Workflows' ) + containers_dict[ 'workflows' ] = workflows_root_folder + if valid_data_managers: + folder_id, valid_data_managers_root_folder = \ + self.build_data_managers_folder( 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 = \ + self.build_invalid_data_managers_folder( 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: %s" % str( e ) ) + finally: + lock.release() + return containers_dict This diff is so big that we needed to truncate the remainder. 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)
-
commits-noreply@bitbucket.org