Remove reselect_tool_panel mako and controller endpoint.

This commit is contained in:
John Chilton
2022-10-17 14:48:15 -04:00
parent 8262c7d75a
commit 533e3f9be0
3 changed files with 0 additions and 459 deletions
@@ -12,7 +12,6 @@ from galaxy.exceptions import ConfigDoesNotAllowException
from galaxy.tool_shed.galaxy_install import install_manager
from galaxy.tool_shed.galaxy_install.repository_dependencies import repository_dependency_manager
from galaxy.tool_shed.galaxy_install.tools import tool_panel_manager
from galaxy.tool_shed.util import tool_util
from galaxy.tool_shed.util.repository_util import (
create_or_update_tool_shed_repository,
get_absolute_path_to_file_in_repository,
@@ -368,172 +367,3 @@ class AdminToolshed(AdminGalaxy):
except Exception:
log.exception("Problem you know in here somewhere...")
raise
@web.expose
@web.require_admin
@legacy_tool_shed_endpoint
def reselect_tool_panel_section(self, trans, **kwd):
"""
Select or change the tool panel section to contain the tools included in the tool shed repository
being reinstalled. If there are updates available for the repository in the tool shed, the
tool_dependencies and repository_dependencies associated with the updated changeset revision will
have been retrieved from the tool shed and passed in the received kwd. In this case, the stored
tool shed repository metadata from the Galaxy database will not be used since it is outdated.
"""
message = ""
status = "done"
repository_id = kwd.get("id", None)
latest_changeset_revision = kwd.get("latest_changeset_revision", None)
latest_ctx_rev = kwd.get("latest_ctx_rev", None)
tool_shed_repository = get_installed_tool_shed_repository(trans.app, repository_id)
repository_clone_url = common_util.generate_clone_url_for_installed_repository(trans.app, tool_shed_repository)
metadata = tool_shed_repository.metadata_
tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry(
trans.app, str(tool_shed_repository.tool_shed)
)
tool_path = tool_shed_repository.get_tool_relative_path(trans.app)[0]
if latest_changeset_revision and latest_ctx_rev:
# There are updates available in the tool shed for the repository, so use the received
# dependency information which was retrieved from the tool shed.
encoded_updated_repo_info_dict = kwd.get("updated_repo_info_dict", None)
updated_repo_info_dict = encoding_util.tool_shed_decode(encoded_updated_repo_info_dict)
readme_files_dict = updated_repo_info_dict.get("readme_files_dict", None)
includes_data_managers = updated_repo_info_dict.get("includes_data_managers", False)
includes_tool_dependencies = updated_repo_info_dict.get("includes_tool_dependencies", False)
repo_info_dict = updated_repo_info_dict["repo_info_dict"]
else:
# There are no updates available from the tool shed for the repository, so use its locally stored metadata.
includes_data_managers = False
includes_tool_dependencies = False
readme_files_dict = None
tool_dependencies = None
if metadata:
if "data_manager" in metadata:
includes_data_managers = True
if "tool_dependencies" in metadata:
includes_tool_dependencies = True
# Since we're reinstalling, we need to send a request to the tool shed to get the README files.
params = dict(
name=tool_shed_repository.name,
owner=tool_shed_repository.owner,
changeset_revision=tool_shed_repository.installed_changeset_revision,
)
pathspec = ["repository", "get_readme_files"]
raw_text = util.url_get(
tool_shed_url,
auth=self.app.tool_shed_registry.url_auth(tool_shed_url),
pathspec=pathspec,
params=params,
)
readme_files_dict = json.loads(raw_text)
tool_dependencies = metadata.get("tool_dependencies", None)
rdim = repository_dependency_manager.RepositoryDependencyInstallManager(trans.app)
repository_dependencies = rdim.get_repository_dependencies_for_installed_tool_shed_repository(
trans.app, tool_shed_repository
)
repo_info_dict = create_repo_info_dict(
trans.app,
repository_clone_url=repository_clone_url,
changeset_revision=tool_shed_repository.installed_changeset_revision,
ctx_rev=tool_shed_repository.ctx_rev,
repository_owner=tool_shed_repository.owner,
repository_name=tool_shed_repository.name,
tool_dependencies=tool_dependencies,
repository_dependencies=repository_dependencies,
)
irm = trans.app.installed_repository_manager
dependencies_for_repository_dict = irm.get_dependencies_for_repository(
tool_shed_url, repo_info_dict, includes_tool_dependencies, updating=True
)
includes_tool_dependencies = dependencies_for_repository_dict.get("includes_tool_dependencies", False)
includes_tools = dependencies_for_repository_dict.get("includes_tools", False)
includes_tools_for_display_in_tool_panel = dependencies_for_repository_dict.get(
"includes_tools_for_display_in_tool_panel", False
)
installed_repository_dependencies = dependencies_for_repository_dict.get(
"installed_repository_dependencies", None
)
installed_tool_dependencies = dependencies_for_repository_dict.get("installed_tool_dependencies", None)
missing_repository_dependencies = dependencies_for_repository_dict.get("missing_repository_dependencies", None)
missing_tool_dependencies = dependencies_for_repository_dict.get("missing_tool_dependencies", None)
if installed_repository_dependencies or missing_repository_dependencies:
has_repository_dependencies = True
else:
has_repository_dependencies = False
if includes_tools_for_display_in_tool_panel:
# Get the location in the tool panel in which the tools were originally loaded.
if "tool_panel_section" in metadata:
tool_panel_dict = metadata["tool_panel_section"]
if tool_panel_dict:
if tool_util.panel_entry_per_tool(tool_panel_dict):
# The following forces everything to be loaded into 1 section (or no section) in the tool panel.
tool_section_dicts = tool_panel_dict[next(iter(tool_panel_dict.keys()))]
tool_section_dict = tool_section_dicts[0]
original_section_name = tool_section_dict["name"]
else:
original_section_name = tool_panel_dict["name"]
else:
original_section_name = ""
else:
original_section_name = ""
tool_panel_section_select_field = tool_util.build_tool_panel_section_select_field(trans.app)
no_changes_check_box = CheckboxField("no_changes", value=True)
if original_section_name:
message += (
"The tools contained in your <b>%s</b> repository were last loaded into the tool panel section <b>%s</b>. "
% (escape(tool_shed_repository.name), original_section_name)
)
message += "Uncheck the <b>No changes</b> check box and select a different tool panel section to load the tools in a "
message += "different section in the tool panel. "
status = "warning"
else:
message += f"The tools contained in your <b>{escape(tool_shed_repository.name)}</b> repository were last loaded into the tool panel outside of any sections. "
message += "Uncheck the <b>No changes</b> check box and select a tool panel section to load the tools into that section. "
status = "warning"
else:
no_changes_check_box = None
original_section_name = ""
tool_panel_section_select_field = None
shed_tool_conf_select_field = tool_util.build_shed_tool_conf_select_field(trans.app)
dd = dependency_display.DependencyDisplayer(trans.app)
containers_dict = dd.populate_containers_dict_for_new_install(
tool_shed_url=tool_shed_url,
tool_path=tool_path,
readme_files_dict=readme_files_dict,
installed_repository_dependencies=installed_repository_dependencies,
missing_repository_dependencies=missing_repository_dependencies,
installed_tool_dependencies=installed_tool_dependencies,
missing_tool_dependencies=missing_tool_dependencies,
updating=False,
)
# Since we're reinstalling we'll merge the list of missing repository dependencies into the list of
# installed repository dependencies since each displayed repository dependency will display a status,
# whether installed or missing.
containers_dict = dd.merge_missing_repository_dependencies_to_installed_container(containers_dict)
# Handle repository dependencies check box.
install_repository_dependencies_check_box = CheckboxField("install_repository_dependencies", value=True)
view = views.DependencyResolversView(self.app)
if view.installable_resolvers:
install_resolver_dependencies_check_box = CheckboxField("install_resolver_dependencies", value=True)
else:
install_resolver_dependencies_check_box = None
return trans.fill_template(
"/admin/tool_shed_repository/reselect_tool_panel_section.mako",
repository=tool_shed_repository,
no_changes_check_box=no_changes_check_box,
original_section_name=original_section_name,
includes_data_managers=includes_data_managers,
includes_tools=includes_tools,
includes_tools_for_display_in_tool_panel=includes_tools_for_display_in_tool_panel,
includes_tool_dependencies=includes_tool_dependencies,
has_repository_dependencies=has_repository_dependencies,
install_repository_dependencies_check_box=install_repository_dependencies_check_box,
install_resolver_dependencies_check_box=install_resolver_dependencies_check_box,
containers_dict=containers_dict,
tool_panel_section_select_field=tool_panel_section_select_field,
shed_tool_conf_select_field=shed_tool_conf_select_field,
encoded_repo_info_dict=encoding_util.tool_shed_encode(repo_info_dict),
repo_info_dict=repo_info_dict,
message=message,
status=status,
)
@@ -1,101 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_dependencies_section" />
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_readme_section" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="stylesheets()">
${parent.stylesheets()}
${h.css( "library" )}
</%def>
<%def name="javascripts()">
${parent.javascripts()}
${container_javascripts()}
</%def>
%if message:
${render_msg( message, status )}
%endif
<div class="card">
<div class="card-body">
<form name="reselect_tool_panel_section" id="reselect_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='reinstall_repository', id=trans.security.encode_id( repository.id ) )}" method="post" >
<div class="form-row">
<input type="hidden" name="repo_info_dict" value="${encoded_repo_info_dict}" />
</div>
<div style="clear: both"></div>
<% readme_files_dict = containers_dict.get( 'readme_files', None ) %>
%if readme_files_dict:
<div class="form-row">
<table class="colored" width="100%">
<th bgcolor="#EBD9B2">Repository README files - may contain important installation or license information</th>
</table>
</div>
${render_readme_section( containers_dict )}
<div style="clear: both"></div>
%endif
%if has_repository_dependencies or includes_tool_dependencies:
<div class="form-row">
<table class="colored" width="100%">
<th bgcolor="#EBD9B2">Confirm dependency installation</th>
</table>
</div>
${render_dependencies_section( install_resolver_dependencies_check_box, install_repository_dependencies_check_box, containers_dict, revision_label=None, export=False )}
%endif
%if shed_tool_conf_select_field:
<div class="form-row">
<table class="colored" width="100%">
<th bgcolor="#EBD9B2">Choose the configuration file whose tool_path setting will be used for installing repositories</th>
</table>
</div>
<%
if len( shed_tool_conf_select_field.options ) == 1:
select_help = "Your Galaxy instance is configured with 1 shed-related tool configuration file, so repositories will be "
select_help += "installed using its <b>tool_path</b> setting."
else:
select_help = "Your Galaxy instance is configured with %d shed-related tool configuration files, " % len( shed_tool_conf_select_field.options )
select_help += "so select the file whose <b>tool_path</b> setting you want used for installing repositories."
%>
<div class="form-row">
<label>Shed tool configuration file:</label>
${render_select(shed_tool_conf_select_field)}
<div class="toolParamHelp" style="clear: both;">
${select_help|h}
</div>
</div>
<div style="clear: both"></div>
%else:
<input type="hidden" name="shed_tool_conf" value="${shed_tool_conf|h}"/>
%endif
%if includes_tools_for_display_in_tool_panel:
<div style="clear: both"></div>
<div class="form-row">
${render_checkbox(no_changes_check_box)}
<label style="display: inline;">No changes</label>
<div class="toolParamHelp" style="clear: both;">
Uncheck and select a different tool panel section to load the tools into a different section in the tool panel.
</div>
</div>
<div class="form-row">
<label>Add new tool panel section:</label>
<input name="new_tool_panel_section_label" type="textfield" value="" size="40"/>
<div class="toolParamHelp" style="clear: both;">
Add a new tool panel section to contain the installed tools (optional).
</div>
</div>
<div class="form-row">
<label>Select existing tool panel section:</label>
${render_select(tool_panel_section_select_field)}
<div class="toolParamHelp" style="clear: both;">
Choose an existing section in your tool panel to contain the installed tools (optional).
</div>
</div>
%endif
<div class="form-row">
<input type="submit" name="select_tool_panel_section_button" value="Install"/>
</div>
</form>
</div>
</div>
@@ -1,188 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_dependencies_section" />
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_readme_section" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="stylesheets()">
${parent.stylesheets()}
${h.css( "library" )}
</%def>
<%def name="javascripts()">
${parent.javascripts()}
${container_javascripts()}
</%def>
<%
# Handle the case where an uninstalled repository encountered errors during the process of being reinstalled. In
# this case, the repository metadata is an empty dictionary, but one or both of has_repository_dependencies
# and includes_tool_dependencies may be True. If either of these are True but we have no metadata, we cannot install
# repository dependencies on this pass.
if has_repository_dependencies:
repository_dependencies = containers_dict[ 'repository_dependencies' ]
missing_repository_dependencies = containers_dict[ 'missing_repository_dependencies' ]
if repository_dependencies or missing_repository_dependencies:
can_display_repository_dependencies = True
else:
can_display_repository_dependencies = False
else:
can_display_repository_dependencies = False
if includes_tool_dependencies:
tool_dependencies = containers_dict[ 'tool_dependencies' ]
missing_tool_dependencies = containers_dict[ 'missing_tool_dependencies' ]
if tool_dependencies or missing_tool_dependencies:
can_display_tool_dependencies = True
else:
can_display_tool_dependencies = False
else:
can_display_tool_dependencies = False
can_display_resolver_installation = install_resolver_dependencies_check_box is not None
%>
%if message:
${render_msg( message, status )}
%endif
<div class="warningmessage">
<p>
The Galaxy development team does not maintain the contents of many Galaxy Tool Shed repositories. Some
repository tools may include code that produces malicious behavior, so be aware of what you are installing.
</p>
<p>
If you discover a repository that causes problems after installation, contact <a href="https://galaxyproject.org/support" target="_blank">Galaxy support</a>,
sending all necessary information, and appropriate action will be taken.
</p>
<p>
<a href="https://galaxyproject.org/toolshed/repository-features/#contact-repository-owner" target="_blank">Contact the repository owner</a> for
general questions or concerns.
</p>
</div>
<div class="card">
<div class="card-body">
<form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='prepare_for_install' )}" method="post" >
<div class="form-row">
<input type="hidden" name="includes_tools" value="${includes_tools}" />
<input type="hidden" name="includes_tool_dependencies" value="${includes_tool_dependencies}" />
<input type="hidden" name="requirements_status" value="${requirements_status}" />
<input type="hidden" name="includes_tools_for_display_in_tool_panel" value="${includes_tools_for_display_in_tool_panel}" />
<input type="hidden" name="tool_shed_url" value="${tool_shed_url}" />
<input type="hidden" name="encoded_repo_info_dicts" value="${encoded_repo_info_dicts}" />
<input type="hidden" name="updating" value="${updating}" />
<input type="hidden" name="updating_repository_id" value="${updating_repository_id}" />
<input type="hidden" name="updating_to_ctx_rev" value="${updating_to_ctx_rev}" />
<input type="hidden" name="updating_to_changeset_revision" value="${updating_to_changeset_revision}" />
<input type="hidden" name="encoded_updated_metadata" value="${encoded_updated_metadata}" />
</div>
<div style="clear: both"></div>
<% readme_files_dict = containers_dict.get( 'readme_files', None ) %>
%if readme_files_dict:
<div class="form-row">
<table class="colored" width="100%">
<th bgcolor="#EBD9B2">Repository README file - may contain important installation or license information</th>
</table>
</div>
${render_readme_section( containers_dict )}
<div style="clear: both"></div>
%endif
<%
if requirements_status and install_resolver_dependencies_check_box or includes_tool_dependencies:
display_dependency_confirmation = True
else:
display_dependency_confirmation = False
%>
%if requirements_status:
%if not install_resolver_dependencies_check_box and not includes_tool_dependencies:
<div class="form-row">
<table class="colored" width="100%">
<head>
<th>
<img src="${h.url_for('/static')}/images/icon_error_sml.gif" title='Cannot install dependencies'/>
This repository requires dependencies that cannot be installed through the Tool Shed
</th>
</head>
</table>
</div>
<div class="form-row">
<p>This repository defines tool requirements that cannot be installed through the Tool Shed.</p>
<p>Please activate Conda dependency resolution, activate Docker dependency resolution, setup Environment Modules
or manually satisfy the dependencies listed below.</p>
<p>For details see <a target="_blank" href="https://docs.galaxyproject.org/en/master/admin/dependency_resolvers.html">the dependency resolver documentation.</a></p>
</div>
%endif
<div class="form-row">
<table class="colored" width="100%">
<th bgcolor="#EBD9B2">The following tool dependencies are required by the current repository</th>
</table>
</div>
<div class="form-row">
${render_tool_dependency_resolver( requirements_status, prepare_for_install=True )}
</div>
<div style="clear: both"></div>
%endif
%if can_display_repository_dependencies or display_dependency_confirmation:
<div class="form-row">
<table class="colored" width="100%">
<th bgcolor="#EBD9B2">Confirm dependency installation</th>
</table>
</div>
${render_dependencies_section( install_resolver_dependencies_check_box, install_repository_dependencies_check_box, containers_dict, revision_label=None, export=False, requirements_status=requirements_status )}
<div style="clear: both"></div>
%endif
%if shed_tool_conf_select_field:
%if includes_tools_for_display_in_tool_panel:
<div class="form-row">
<table class="colored" width="100%">
<th bgcolor="#EBD9B2">Choose the tool panel section to contain the installed tools (optional)</th>
</table>
</div>
<div class="detail-section">
%endif
<%
if len( shed_tool_conf_select_field.options ) == 1:
select_help = "Your Galaxy instance is configured with 1 shed-related tool configuration file, so repositories will be "
select_help += "installed using its <b>tool_path</b> setting."
else:
select_help = "Your Galaxy instance is configured with %d shed-related tool configuration files, " % len( shed_tool_conf_select_field.options )
select_help += "so select the file whose <b>tool_path</b> setting you want used for installing repositories."
%>
<div class="form-row">
<label>Shed tool configuration file:</label>
${render_select(shed_tool_conf_select_field)}
<div class="toolParamHelp" style="clear: both;">
${select_help|h}
</div>
</div>
<div style="clear: both"></div>
</div>
%else:
<input type="hidden" name="shed_tool_conf" value="${shed_tool_conf|h}"/>
%endif
%if includes_tools_for_display_in_tool_panel:
<div class="form-row">
<label>Add new tool panel section:</label>
<input name="new_tool_panel_section_label" type="textfield" value="${new_tool_panel_section_label|h}" size="40"/>
<div class="toolParamHelp" style="clear: both;">
Add a new tool panel section to contain the installed tools (optional).
</div>
</div>
<div class="form-row">
<label>Select existing tool panel section:</label>
${render_select(tool_panel_section_select_field)}
<div class="toolParamHelp" style="clear: both;">
Choose an existing section in your tool panel to contain the installed tools (optional).
</div>
</div>
%endif
<div class="form-row">
<input type="submit" name="select_tool_panel_section_button" value="Install"/>
<div class="toolParamHelp" style="clear: both;">
%if includes_tools_for_display_in_tool_panel:
Clicking <b>Install</b> without selecting a tool panel section will load the installed tools into the tool panel outside of any sections.
%endif
</div>
</div>
</form>
</div>
</div>