def _get_new_toolbox(app):
    """
    Generate a new toolbox, by constructing a toolbox from the config files,
    and then adding pre-existing data managers from the old toolbox to the new toolbox.
    """
    from galaxy import tools
    from galaxy.tools.special_tools import load_lib_tools
    from galaxy.tools.toolbox.lineages.tool_shed import ToolVersionCache
    if hasattr(app, 'tool_shed_repository_cache'):
        app.tool_shed_repository_cache.rebuild()
    app.tool_version_cache = ToolVersionCache(
        app)  # Load new tools into version cache
    tool_configs = app.config.tool_configs
    if app.config.migrated_tools_config not in tool_configs:
        tool_configs.append(app.config.migrated_tools_config)

    new_toolbox = tools.ToolBox(tool_configs, app.config.tool_path, app)
    new_toolbox.data_manager_tools = app.toolbox.data_manager_tools
    app.datatypes_registry.load_datatype_converters(new_toolbox,
                                                    use_cached=True)
    app.datatypes_registry.load_external_metadata_tool(new_toolbox)
    load_lib_tools(new_toolbox)
    [
        new_toolbox.register_tool(tool)
        for tool in new_toolbox.data_manager_tools.values()
    ]
    app.toolbox = new_toolbox
Beispiel #2
0
def _get_new_toolbox(app):
    """
    Generate a new toolbox, by constructing a toolbox from the config files,
    and then adding pre-existing data managers from the old toolbox to the new toolbox.
    """
    from galaxy import tools
    from galaxy.tools.special_tools import load_lib_tools
    from galaxy.tools.toolbox.lineages.tool_shed import ToolVersionCache
    app.tool_version_cache = ToolVersionCache(
        app)  # Load new tools into version cache
    tool_configs = app.config.tool_configs
    if app.config.migrated_tools_config not in tool_configs:
        tool_configs.append(app.config.migrated_tools_config)
    start = time.time()
    new_toolbox = tools.ToolBox(tool_configs, app.config.tool_path, app,
                                app.toolbox._tool_conf_watcher)
    new_toolbox.data_manager_tools = app.toolbox.data_manager_tools
    load_lib_tools(new_toolbox)
    new_toolbox.load_hidden_lib_tool("galaxy/datatypes/set_metadata_tool.xml")
    [
        new_toolbox.register_tool(tool)
        for tool in new_toolbox.data_manager_tools.values()
    ]
    end = time.time() - start
    log.debug("Toolbox reload took %d seconds", end)
    app.reindex_tool_search(new_toolbox)
    return new_toolbox
Beispiel #3
0
def reload_data_managers(app, **kwargs):
    from galaxy.tools.data_manager.manager import DataManagers
    from galaxy.tools.toolbox.lineages.tool_shed import ToolVersionCache
    log.debug("Executing data managers reload on '%s'", app.config.server_name)
    app._configure_tool_data_tables(from_shed_config=False)
    reload_tool_data_tables(app)
    reload_count = app.data_managers._reload_count
    app.data_managers = DataManagers(app, conf_watchers=app.data_managers.conf_watchers)
    app.data_managers._reload_count = reload_count + 1
    app.tool_version_cache = ToolVersionCache(app)
Beispiel #4
0
 def _repo_install( self, changeset ):
     repository = tool_shed_install.ToolShedRepository()
     repository.tool_shed = "github.com"
     repository.owner = "galaxyproject"
     repository.name = "example"
     repository.changeset_revision = changeset
     repository.installed_changeset_revision = changeset
     repository.deleted = False
     repository.uninstalled = False
     self.app.install_model.context.add( repository )
     self.app.install_model.context.flush( )
     self.app.tool_version_cache = ToolVersionCache(self.app)
     return repository
def reload_data_managers(app, **kwargs):
    reload_timer = util.ExecutionTimer()
    from galaxy.tools.data_manager.manager import DataManagers
    from galaxy.tools.toolbox.lineages.tool_shed import ToolVersionCache
    log.debug("Executing data managers reload on '%s'", app.config.server_name)
    if hasattr(app, 'tool_shed_repository_cache'):
        app.tool_shed_repository_cache.rebuild()
    app._configure_tool_data_tables(from_shed_config=False)
    reload_tool_data_tables(app)
    reload_count = app.data_managers._reload_count
    app.data_managers = DataManagers(app)
    app.data_managers._reload_count = reload_count + 1
    app.tool_version_cache = ToolVersionCache(app)
    if hasattr(app, 'tool_cache'):
        app.tool_cache.reset_status()
    log.debug("Data managers reloaded %s", reload_timer)
Beispiel #6
0
 def handle_tool_versions( self, tool_version_dicts, tool_shed_repository ):
     """
     Using the list of tool_version_dicts retrieved from the Tool Shed (one per changeset
     revision up to the currently installed changeset revision), create the parent / child
     pairs of tool versions.  Each dictionary contains { tool id : parent tool id } pairs.
     This function is called only from Galaxy.
     """
     context = self.app.install_model.context
     for tool_version_dict in tool_version_dicts:
         for tool_guid, parent_id in tool_version_dict.items():
             tool_version_using_tool_guid = self.get_tool_version( tool_guid )
             tool_version_using_parent_id = self.get_tool_version( parent_id )
             if not tool_version_using_tool_guid:
                 tool_version_using_tool_guid = \
                     self.app.install_model.ToolVersion( tool_id=tool_guid,
                                                         tool_shed_repository=tool_shed_repository )
                 context.add( tool_version_using_tool_guid )
                 context.flush()
             if not tool_version_using_parent_id:
                 tool_version_using_parent_id = \
                     self.app.install_model.ToolVersion( tool_id=parent_id,
                                                         tool_shed_repository=tool_shed_repository )
                 context.add( tool_version_using_parent_id )
                 context.flush()
             # Remove existing wrong tool version associations having
             # tool_version_using_parent_id as parent or
             # tool_version_using_tool_guid as child.
             context.query( self.app.install_model.ToolVersionAssociation ) \
                    .filter( or_( and_( self.app.install_model.ToolVersionAssociation.table.c.parent_id == tool_version_using_parent_id.id,
                                        self.app.install_model.ToolVersionAssociation.table.c.tool_id != tool_version_using_tool_guid.id ),
                                  and_( self.app.install_model.ToolVersionAssociation.table.c.parent_id != tool_version_using_parent_id.id,
                                        self.app.install_model.ToolVersionAssociation.table.c.tool_id == tool_version_using_tool_guid.id ) ) ) \
                    .delete()
             context.flush()
             tool_version_association = \
                 self.get_tool_version_association( tool_version_using_parent_id,
                                                    tool_version_using_tool_guid )
             if not tool_version_association:
                 # Associate the two versions as parent / child.
                 tool_version_association = \
                     self.app.install_model.ToolVersionAssociation( tool_id=tool_version_using_tool_guid.id,
                                                                    parent_id=tool_version_using_parent_id.id )
                 context.add( tool_version_association )
                 context.flush()
     self.app.tool_version_cache = ToolVersionCache(self.app)
Beispiel #7
0
    def _setup_two_versions( self ):
        repository1 = self._repo_install( changeset="1" )
        version1 = tool_shed_install.ToolVersion()
        version1.tool_id = "github.com/galaxyproject/example/test_tool/0.1"
        version1.repository = repository1
        self.app.install_model.context.add( version1 )
        self.app.install_model.context.flush( )

        repository2 = self._repo_install( changeset="2" )
        version2 = tool_shed_install.ToolVersion()
        version2.tool_id = "github.com/galaxyproject/example/test_tool/0.2"
        version2.repository = repository2

        self.app.install_model.context.add( version2 )
        self.app.install_model.context.flush( )

        version_association = tool_shed_install.ToolVersionAssociation()
        version_association.parent_id = version1.id
        version_association.tool_id = version2.id

        self.app.install_model.context.add( version_association )
        self.app.install_model.context.flush( )
        self.app.tool_version_cache = ToolVersionCache(self.app)
Beispiel #8
0
    def get_versions(self, app):
        tool_versions = []

        # Prepend ancestors.
        def __ancestors(app, tool_version):
            # Should we handle multiple parents at each level?
            previous_version = tool_version.get_previous_version(app)
            if previous_version:
                if previous_version not in tool_versions:
                    tool_versions.insert(0, previous_version)
                    __ancestors(app, previous_version)

        # Append descendants.
        def __descendants(app, tool_version):
            # Should we handle multiple child siblings at each level?
            next_version = tool_version.get_next_version(app)
            if next_version:
                if next_version not in tool_versions:
                    tool_versions.append(next_version)
                    __descendants(app, next_version)

        try:
            __ancestors(app, self)
            if self not in tool_versions:
                tool_versions.append(self)
            __descendants(app, self)
        except DetachedInstanceError:
            # This can happen when loading a tool while referencing
            # and outdated tool version cache, so we build a new cache
            tool_versions = []
            from galaxy.tools.toolbox.lineages.tool_shed import ToolVersionCache
            app.tool_version_cache = ToolVersionCache(app)
            __ancestors(app, self)
            if self not in tool_versions:
                tool_versions.append(self)
            __descendants(app, self)
        return tool_versions