Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused galaxy-side set_tool_version code #4986

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 0 additions & 40 deletions lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py
Expand Up @@ -22,7 +22,6 @@
data_manager,
tool_panel_manager
)
from tool_shed.tools import tool_version_manager
from tool_shed.util import (
common_util,
encoding_util,
Expand Down Expand Up @@ -1538,45 +1537,6 @@ def reset_to_install(self, trans, **kwd):
action='manage_repository',
id=repository_id))

@web.expose
@web.require_admin
def set_tool_versions(self, trans, **kwd):
"""
Get the tool_versions from the tool shed for each tool in the installed revision of a selected tool shed
repository and update the metadata for the repository's revision in the Galaxy database.
"""
repository = repository_util.get_installed_tool_shed_repository(trans.app, kwd['id'])
tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry(trans.app, str(repository.tool_shed))
params = dict(name=repository.name, owner=repository.owner, changeset_revision=repository.changeset_revision)
pathspec = ['repository', 'get_tool_versions']
text = util.url_get(tool_shed_url, password_mgr=self.app.tool_shed_registry.url_auth(tool_shed_url), pathspec=pathspec, params=params)
if text:
tool_version_dicts = json.loads(text)
tvm = tool_version_manager.ToolVersionManager(trans.app)
tvm.handle_tool_versions(tool_version_dicts, repository)
message = "Tool versions have been set for all included tools."
status = 'done'
else:
message = ("Version information for the tools included in the <b>%s</b> repository is missing. "
"Reset all of this reppository's metadata in the tool shed, then set the installed tool versions "
"from the installed repository's <b>Repository Actions</b> menu. " % escape(repository.name))
status = 'error'
shed_tool_conf, tool_path, relative_install_dir = suc.get_tool_panel_config_tool_path_install_dir(trans.app, repository)
repo_files_dir = os.path.abspath(os.path.join(relative_install_dir, repository.name))
dd = dependency_display.DependencyDisplayer(trans.app)
containers_dict = dd.populate_containers_dict_from_repository_metadata(tool_shed_url=tool_shed_url,
tool_path=tool_path,
repository=repository,
reinstalling=False,
required_repo_info_dicts=None)
return trans.fill_template('/admin/tool_shed_repository/manage_repository.mako',
repository=repository,
description=repository.description,
repo_files_dir=repo_files_dir,
containers_dict=containers_dict,
message=message,
status=status)

@web.json
def tool_dependency_status_updates(self, trans, ids=None, status_list=None):
# Avoid caching
Expand Down
31 changes: 2 additions & 29 deletions lib/tool_shed/galaxy_install/install_manager.py
Expand Up @@ -19,8 +19,8 @@
from tool_shed.galaxy_install.tool_dependencies.recipe.recipe_manager import StepManager
from tool_shed.galaxy_install.tool_dependencies.recipe.recipe_manager import TagManager
from tool_shed.galaxy_install.tools import data_manager, tool_panel_manager
from tool_shed.tools import data_table_manager, tool_version_manager
from tool_shed.util import basic_util, common_util, encoding_util, hg_util, repository_util
from tool_shed.tools import data_table_manager
from tool_shed.util import basic_util, encoding_util, hg_util, repository_util
from tool_shed.util import shed_util_common as suc, tool_dependency_util
from tool_shed.util import tool_util, xml_util

Expand Down Expand Up @@ -536,12 +536,6 @@ def __handle_repository_contents(self, tool_shed_repository, tool_path, reposito
self.app.config.shed_tool_data_table_config,
persist=True)
if 'tools' in irmm_metadata_dict:
# Get the tool_versions from the Tool Shed for each tool in the installed change set.
self.update_tool_shed_repository_status(tool_shed_repository,
self.install_model.ToolShedRepository.installation_status.SETTING_TOOL_VERSIONS)
tool_version_dicts = fetch_tool_versions(self.app, tool_shed_repository)
tvm = tool_version_manager.ToolVersionManager(self.app)
tvm.handle_tool_versions(tool_version_dicts, tool_shed_repository)
tool_panel_dict = self.tpm.generate_tool_panel_dict_for_new_install(irmm_metadata_dict['tools'], tool_section)
sample_files = irmm_metadata_dict.get('sample_files', [])
tool_index_sample_files = tdtm.get_tool_index_sample_files(sample_files)
Expand Down Expand Up @@ -1012,24 +1006,3 @@ class RepositoriesInstalledException(exceptions.RequestParameterInvalidException

def __init__(self):
super(RepositoriesInstalledException, self).__init__('All repositories that you are attempting to install have been previously installed.')


def fetch_tool_versions(app, tool_shed_repository):
""" Fetch a data structure describing tool shed versions from the tool shed
corresponding to a tool_shed_repository object.
"""
try:
tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry(app, str(tool_shed_repository.tool_shed))
params = dict(name=str(tool_shed_repository.name),
owner=str(tool_shed_repository.owner),
changeset_revision=str(tool_shed_repository.changeset_revision))
pathspec = ['repository', 'get_tool_versions']
url = util.build_url(tool_shed_url, pathspec=pathspec, params=params)
text = util.url_get(tool_shed_url, password_mgr=app.tool_shed_registry.url_auth(tool_shed_url), pathspec=pathspec, params=params)
if text:
return json.loads(text)
else:
raise Exception("No content returned from Tool Shed repository version request to %s" % url)
except Exception:
log.exception("Failed to fetch tool version information for Tool Shed repository.")
raise
46 changes: 0 additions & 46 deletions lib/tool_shed/galaxy_install/tool_migration_manager.py
Expand Up @@ -2,7 +2,6 @@
Manage automatic installation of tools configured in the xxx.xml files in ~/scripts/migrate_tools (e.g., 0002_tools.xml).
All of the tools were at some point included in the Galaxy distribution, but are now hosted in the main Galaxy tool shed.
"""
import json
import logging
import os
import shutil
Expand All @@ -20,7 +19,6 @@
from tool_shed.galaxy_install.tools import tool_panel_manager

from tool_shed.tools import data_table_manager
from tool_shed.tools import tool_version_manager

from tool_shed.util import basic_util
from tool_shed.util import common_util
Expand Down Expand Up @@ -571,50 +569,6 @@ def install_repository(self, repository_elem, tool_shed_repository, install_depe
install_dependencies=install_dependencies,
is_repository_dependency=is_repository_dependency)
self.app.install_model.context.refresh(tool_shed_repository)
metadata_dict = tool_shed_repository.metadata
if 'tools' in metadata_dict:
# Initialize the ToolVersionManager.
tvm = tool_version_manager.ToolVersionManager(self.app)
irm.update_tool_shed_repository_status(tool_shed_repository,
self.app.install_model.ToolShedRepository.installation_status.SETTING_TOOL_VERSIONS)
# Get the tool_versions from the tool shed for each tool in the installed change set.
params = dict(name=tool_shed_repository.name,
owner=self.repository_owner,
changeset_revision=tool_shed_repository.installed_changeset_revision)
pathspec = ['repository', 'get_tool_versions']
text = util.url_get(self.tool_shed_url, password_mgr=self.app.tool_shed_registry.url_auth(self.tool_shed_url), pathspec=pathspec, params=params)
if text:
tool_version_dicts = json.loads(text)
tvm.handle_tool_versions(tool_version_dicts, tool_shed_repository)
else:
# Set the tool versions since they seem to be missing
# for this repository in the tool shed. CRITICAL NOTE:
# These default settings may not properly handle all
# parent/child associations.
for tool_dict in metadata_dict['tools']:
tool_id = tool_dict['guid']
old_tool_id = tool_dict['id']
tool_version_using_old_id = tvm.get_tool_version(old_tool_id)
tool_version_using_guid = tvm.get_tool_version(tool_id)
if not tool_version_using_old_id:
tool_version_using_old_id = self.app.install_model.ToolVersion(tool_id=old_tool_id,
tool_shed_repository=tool_shed_repository)
self.app.install_model.context.add(tool_version_using_old_id)
self.app.install_model.context.flush()
if not tool_version_using_guid:
tool_version_using_guid = self.app.install_model.ToolVersion(tool_id=tool_id,
tool_shed_repository=tool_shed_repository)
self.app.install_model.context.add(tool_version_using_guid)
self.app.install_model.context.flush()
# Associate the two versions as parent / child.
tool_version_association = tvm.get_tool_version_association(tool_version_using_old_id,
tool_version_using_guid)
if not tool_version_association:
tool_version_association = \
self.app.install_model.ToolVersionAssociation(tool_id=tool_version_using_guid.id,
parent_id=tool_version_using_old_id.id)
self.app.install_model.context.add(tool_version_association)
self.app.install_model.context.flush()
irm.update_tool_shed_repository_status(tool_shed_repository,
self.app.install_model.ToolShedRepository.installation_status.INSTALLED)
else:
Expand Down
47 changes: 1 addition & 46 deletions lib/tool_shed/tools/tool_version_manager.py
@@ -1,6 +1,6 @@
import logging

from sqlalchemy import and_, or_
from sqlalchemy import and_

from tool_shed.util import hg_util
from tool_shed.util import metadata_util
Expand Down Expand Up @@ -66,48 +66,3 @@ def get_version_lineage_for_tool(self, repository_id, repository_metadata, guid)
current_parent_guid = child_guid
break
return version_lineage

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()
Expand Up @@ -33,9 +33,6 @@
%if repository.can_reset_metadata:
<a class="action-button" target="galaxy_main" href="${h.url_for( controller='admin_toolshed', action='reset_repository_metadata', id=trans.security.encode_id( repository.id ) )}">Reset repository metadata</a>
%endif
%if repository.includes_tools:
<a class="action-button" target="galaxy_main" href="${h.url_for( controller='admin_toolshed', action='set_tool_versions', id=trans.security.encode_id( repository.id ) )}">Set tool versions</a>
%endif
%if tool_dependency_ids:
<a class="action-button" target="galaxy_main" href="${h.url_for( controller='admin_toolshed', action='manage_repository_tool_dependencies', tool_dependency_ids=tool_dependency_ids, repository_id=trans.security.encode_id( repository.id ) )}">Manage tool dependencies</a>
%endif
Expand Down
2 changes: 0 additions & 2 deletions templates/admin/tool_shed_repository/view_tool_metadata.mako
Expand Up @@ -78,8 +78,6 @@ ${render_galaxy_repository_actions( repository )}
</tr>
%endfor
</table>
%else:
No tool versions are defined for this tool so it is critical that you <b>Set tool versions</b> from the <b>Manage repository</b> page.
%endif
</div>
<div class="form-row">
Expand Down
6 changes: 1 addition & 5 deletions test/unit/shed_unit/test_tool_panel_manager.py
Expand Up @@ -74,7 +74,6 @@ def test_add_tool_to_panel(self):

def test_add_twice(self):
self._init_dynamic_tool_conf()
tool_versions = {}
previous_guid = None
for v in "1", "2", "3":
self.__toolbox = self.get_new_toolbox()
Expand All @@ -83,7 +82,7 @@ def test_add_twice(self):
tool = self._init_ts_tool(guid=guid, filename="tool_v%s.xml" % v, version=v)
tool_path = self._tool_path(name="tool_v%s.xml" % v)
new_tools = [{"guid": guid, "tool_config": tool_path}]
tool_shed_repository = self._repo_install(changeset)
self._repo_install(changeset)
repository_tools_tups = [
(
tool_path,
Expand All @@ -97,9 +96,6 @@ def test_add_twice(self):
tool_dicts=new_tools,
tool_section=section,
)
if previous_guid:
tool_versions[guid] = previous_guid
self.tvm.handle_tool_versions([tool_versions], tool_shed_repository)
tpm.add_to_tool_panel(
repository_name="example",
repository_clone_url="github.com",
Expand Down