Remove workflows from tool shed.

This commit is contained in:
John Chilton
2019-11-12 20:54:46 -05:00
parent f308c05f61
commit b404dc0b63
17 changed files with 4 additions and 1240 deletions
@@ -26,7 +26,6 @@ from tool_shed.util import (
shed_util_common as suc,
tool_dependency_util,
tool_util,
workflow_util
)
from tool_shed.util.web_util import escape
from .admin import AdminGalaxy
@@ -245,12 +244,6 @@ class AdminToolshed(AdminGalaxy):
return open(path_to_file, 'rb')
return None
@web.expose
@web.require_admin
def generate_workflow_image(self, trans, workflow_name, repository_id=None):
"""Return an svg image representation of a workflow dictionary created when the workflow was exported."""
return workflow_util.generate_workflow_image(trans, workflow_name, repository_metadata_id=None, repository_id=repository_id)
@web.expose
@web.require_admin
def view_tool_metadata(self, trans, repository_id, tool_id, **kwd):
@@ -342,36 +335,6 @@ class AdminToolshed(AdminGalaxy):
repo_information_dict = json.loads(raw_text)
return repo_information_dict
@web.expose
@web.require_admin
def import_workflow(self, trans, workflow_name, repository_id, **kwd):
"""Import a workflow contained in an installed tool shed repository into Galaxy."""
message = str(escape(kwd.get('message', '')))
status = kwd.get('status', 'done')
if workflow_name:
workflow_name = encoding_util.tool_shed_decode(workflow_name)
repository = repository_util.get_tool_shed_repository_by_id(trans.app, repository_id)
if repository:
workflow, status, message = workflow_util.import_workflow(trans, repository, workflow_name)
if workflow:
workflow_name = encoding_util.tool_shed_encode(str(workflow.name))
else:
message += 'Unable to locate a workflow named <b>%s</b> within the installed tool shed repository named <b>%s</b>' % \
(escape(str(workflow_name)), escape(str(repository.name)))
status = 'error'
else:
message = 'Invalid repository id <b>%s</b> received.' % str(repository_id)
status = 'error'
else:
message = 'The value of workflow_name is required, but was not received.'
status = 'error'
return trans.response.send_redirect(web.url_for(controller='admin_toolshed',
action='view_workflow',
workflow_name=workflow_name,
repository_id=repository_id,
message=message,
status=status))
@web.expose
@web.require_admin
def initiate_tool_dependency_installation(self, trans, tool_dependencies, **kwd):
@@ -1669,23 +1632,3 @@ class AdminToolshed(AdminGalaxy):
action='repositories',
message=message,
status=status))
@web.expose
@web.require_admin
def view_workflow(self, trans, workflow_name=None, repository_id=None, **kwd):
"""Retrieve necessary information about a workflow from the database so that it can be displayed in an svg image."""
message = escape(kwd.get('message', ''))
status = kwd.get('status', 'done')
if workflow_name:
workflow_name = encoding_util.tool_shed_decode(workflow_name)
repository = repository_util.get_tool_shed_repository_by_id(trans.app, repository_id)
changeset_revision = repository.changeset_revision
metadata = repository.metadata
return trans.fill_template("/admin/tool_shed_repository/view_workflow.mako",
repository=repository,
changeset_revision=changeset_revision,
repository_id=repository_id,
workflow_name=workflow_name,
metadata=metadata,
message=message,
status=status)
-59
View File
@@ -32,7 +32,6 @@ from galaxy.security import idencoding
from galaxy.util import smart_str, unicodify
from galaxy_test.driver.testcase import FunctionalTestCase
from tool_shed.util import hg_util, xml_util
from tool_shed.util.encoding_util import tool_shed_encode
from . import common, test_db_util
# Set a 10 minute timeout for repository installation.
@@ -829,11 +828,6 @@ class ShedTwillTestCase(FunctionalTestCase):
strings_not_displayed = []
self.check_for_strings(strings_displayed, strings_not_displayed)
def display_all_workflows(self, strings_displayed=None, strings_not_displayed=None):
url = '/workflows/list'
self.visit_galaxy_url(url)
self.check_for_strings(strings_displayed, strings_not_displayed)
def display_galaxy_browse_repositories_page(self, strings_displayed=None, strings_not_displayed=None):
url = '/admin_toolshed/browse_repositories'
self.visit_galaxy_url(url)
@@ -869,14 +863,6 @@ class ShedTwillTestCase(FunctionalTestCase):
strings_displayed = [x.replace("'", "&#39;") for x in strings_displayed]
self.check_for_strings(strings_displayed, strings_not_displayed)
def display_installed_workflow_image(self, repository, workflow_name, strings_displayed=None, strings_not_displayed=None):
params = {
'repository_id': self.security.encode_id(repository.id),
'workflow_name': tool_shed_encode(workflow_name)
}
self.visit_galaxy_url('/admin_toolshed/generate_workflow_image', params=params)
self.check_for_strings(strings_displayed, strings_not_displayed)
def display_manage_repository_page(self, repository, changeset_revision=None, strings_displayed=None, strings_not_displayed=None):
params = {
'id': self.security.encode_id(repository.id)
@@ -1343,20 +1329,6 @@ class ShedTwillTestCase(FunctionalTestCase):
self.submit_form('import_capsule', 'import_capsule_button')
self.check_for_strings(strings_displayed_after_submit, strings_not_displayed_after_submit)
def import_workflow(self, repository, workflow_name, strings_displayed=None, strings_not_displayed=None):
if strings_displayed is None:
strings_displayed = []
if strings_not_displayed is None:
strings_not_displayed = []
params = {
'repository_id': self.security.encode_id(repository.id),
'workflow_name': tool_shed_encode(workflow_name)
}
self.visit_galaxy_url('/admin_toolshed/import_workflow', params=params)
if workflow_name not in strings_displayed:
strings_displayed.append(workflow_name)
self.check_for_strings(strings_displayed, strings_not_displayed)
def initiate_installation_process(self,
install_tool_dependencies=False,
install_repository_dependencies=True,
@@ -1541,19 +1513,6 @@ class ShedTwillTestCase(FunctionalTestCase):
self.visit_galaxy_url('/tool_runner', params=params)
self.check_for_strings(strings_displayed, strings_not_displayed)
def load_workflow_image_in_tool_shed(self, repository, workflow_name, changeset_revision=None, strings_displayed=None, strings_not_displayed=None):
if not changeset_revision:
changeset_revision = self.get_repository_tip(repository)
metadata = self.get_repository_metadata_by_changeset_revision(repository, changeset_revision)
if not metadata:
raise AssertionError('Metadata not found for changeset revision %s.' % changeset_revision)
params = {
'repository_metadata_id': self.security.encode_id(metadata.id),
'workflow_name': tool_shed_encode(workflow_name)
}
self.visit_url('/repository/generate_workflow_image', params=params)
self.check_for_strings(strings_displayed, strings_not_displayed)
def manage_review_components(self, strings_displayed=None, strings_not_displayed=None):
url = '/repository_review/manage_components'
self.visit_url(url)
@@ -1570,16 +1529,6 @@ class ShedTwillTestCase(FunctionalTestCase):
self.visit_url('/repository/preview_tools_in_changeset', params=params)
self.check_for_strings(strings_displayed, strings_not_displayed)
def preview_workflow_in_tool_shed(self, repository_name, owner, workflow_name, strings_displayed=None, strings_not_displayed=None):
repository = test_db_util.get_repository_by_name_and_owner(repository_name, owner)
metadata = self.get_repository_metadata(repository)
params = {
'workflow_name': tool_shed_encode(workflow_name),
'repository_metadata_id': self.security.encode_id(metadata[0].id)
}
self.visit_url('/repository/view_workflow', params=params)
self.check_for_strings(strings_displayed, strings_not_displayed)
def reactivate_repository(self, installed_repository):
params = dict(id=self.security.encode_id(installed_repository.id))
url = '/admin_toolshed/restore_repository'
@@ -2017,14 +1966,6 @@ class ShedTwillTestCase(FunctionalTestCase):
# or if the number of keys differs.
assert old_metadata == new_metadata, 'Metadata changed after reset on repository %s.' % repository.name
def view_installed_workflow(self, repository, workflow_name, strings_displayed=None, strings_not_displayed=None):
params = {
'repository_id': self.security.encode_id(repository.id),
'workflow_name': tool_shed_encode(workflow_name)
}
self.visit_galaxy_url('/admin_toolshed/view_workflow', params=params)
self.check_for_strings(strings_displayed, strings_not_displayed)
def visit_galaxy_url(self, url, params=None, doseq=False, allowed_codes=[200]):
url = '%s%s' % (self.galaxy_url, url)
self.visit_url(url, params=params, doseq=doseq, allowed_codes=allowed_codes)
@@ -1,123 +0,0 @@
import os
from ..base.twilltestcase import common, ShedTwillTestCase
repository_name = 'filtering_0060'
repository_description = "Galaxy's filtering tool for test 0060"
repository_long_description = "Long description of Galaxy's filtering tool for test 0060"
workflow_filename = 'Workflow_for_0060_filter_workflow_repository.ga'
workflow_name = 'Workflow for 0060_filter_workflow_repository'
category_name = 'Test 0060 Workflow Features'
category_description = 'Test 0060 for workflow features'
workflow_repository_name = 'filtering_workflow_0060'
workflow_repository_description = "Workflow referencing the filtering tool for test 0060"
workflow_repository_long_description = "Long description of the workflow for test 0060"
class TestToolShedWorkflowFeatures(ShedTwillTestCase):
'''Test valid and invalid workflows.'''
def test_0000_initiate_users(self):
"""Create necessary user accounts and login as an admin user."""
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
test_user_1 = self.test_db_util.get_user(common.test_user_1_email)
assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_1_email
self.test_db_util.get_private_role(test_user_1)
self.login(email=common.admin_email, username=common.admin_username)
admin_user = self.test_db_util.get_user(common.admin_email)
assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email
self.test_db_util.get_private_role(admin_user)
def test_0005_create_categories(self):
"""Create categories for this test suite"""
self.create_category(name='Test 0060 Workflow Features', description='Test 0060 - Workflow Features')
def test_0010_create_repository(self):
"""Create and populate the filtering repository"""
category = self.create_category(name=category_name, description=category_description)
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
self.get_or_create_repository(name=repository_name,
description=repository_description,
long_description=repository_long_description,
owner=common.test_user_1_name,
category_id=self.security.encode_id(category.id),
strings_displayed=[])
def test_0015_upload_workflow(self):
'''Upload a workflow with a missing tool, and verify that the tool specified is marked as missing.'''
repository = self.test_db_util.get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
workflow = open(self.get_filename('filtering_workflow/Workflow_for_0060_filter_workflow_repository.ga'), 'r').read()
workflow = workflow.replace('__TEST_TOOL_SHED_URL__', self.url.replace('http://', ''))
workflow_filepath = self.generate_temp_path('test_0060', additional_paths=['filtering_workflow'])
if not os.path.exists(workflow_filepath):
os.makedirs(workflow_filepath)
open(os.path.join(workflow_filepath, workflow_filename), 'w+').write(workflow)
self.upload_file(repository,
filename=workflow_filename,
filepath=workflow_filepath,
valid_tools_only=True,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded filtering workflow.',
strings_displayed=[],
strings_not_displayed=[])
self.load_workflow_image_in_tool_shed(repository, workflow_name, strings_displayed=['#EBBCB2'])
def test_0020_upload_tool(self):
'''Upload the missing tool for the workflow in the previous step, and verify that the error is no longer present.'''
repository = self.test_db_util.get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
self.upload_file(repository,
filename='filtering/filtering_2.2.0.tar',
filepath=None,
valid_tools_only=True,
uncompress_file=True,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded filtering 2.2.0.',
strings_displayed=[],
strings_not_displayed=[])
self.load_workflow_image_in_tool_shed(repository, workflow_name, strings_not_displayed=['#EBBCB2'])
def test_0025_create_repository_with_only_workflow(self):
"""Create and populate the filtering_workflow_0060 repository"""
category = self.create_category(name=category_name, description=category_description)
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
self.get_or_create_repository(name=workflow_repository_name,
description=workflow_repository_description,
long_description=workflow_repository_long_description,
owner=common.test_user_1_name,
category_id=self.security.encode_id(category.id),
strings_displayed=[])
workflow = open(self.get_filename('filtering_workflow/Workflow_for_0060_filter_workflow_repository.ga'), 'r').read()
workflow = workflow.replace('__TEST_TOOL_SHED_URL__', self.url.replace('http://', ''))
workflow = workflow.replace('Workflow for 0060_filter_workflow_repository',
'New workflow for 0060_filter_workflow_repository')
workflow_filepath = self.generate_temp_path('test_0060', additional_paths=['filtering_workflow_2'])
if not os.path.exists(workflow_filepath):
os.makedirs(workflow_filepath)
open(os.path.join(workflow_filepath, workflow_filename), 'w+').write(workflow)
repository = self.test_db_util.get_repository_by_name_and_owner(workflow_repository_name, common.test_user_1_name)
self.upload_file(repository,
filename=workflow_filename,
filepath=workflow_filepath,
valid_tools_only=True,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded filtering workflow.',
strings_displayed=[],
strings_not_displayed=[])
self.load_workflow_image_in_tool_shed(repository, workflow_name, strings_displayed=['#EBBCB2'])
def test_0030_check_workflow_repository(self):
"""Check for strings on the manage page for the filtering_workflow_0060 repository."""
repository = self.test_db_util.get_repository_by_name_and_owner(workflow_repository_name, common.test_user_1_name)
strings_displayed = ['Workflows', 'New workflow for 0060_filter', '0.1']
strings_not_displayed = ['Valid tools', 'Invalid tools']
self.display_manage_repository_page(repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed)
def test_0035_verify_repository_metadata(self):
'''Verify that resetting the metadata does not change it.'''
repository = self.test_db_util.get_repository_by_name_and_owner(repository_name, common.test_user_1_name)
self.verify_unchanged_repository_metadata(repository)
@@ -1,154 +0,0 @@
import os
from ..base.twilltestcase import common, ShedTwillTestCase
repository_name = 'filtering_0060'
repository_description = "Galaxy's filtering tool for test 0060"
repository_long_description = "Long description of Galaxy's filtering tool for test 0060"
workflow_filename = 'Workflow_for_0060_filter_workflow_repository.ga'
workflow_name = 'Workflow for 0060_filter_workflow_repository'
second_workflow_name = 'New workflow for 0060_filter_workflow_repository'
category_name = 'Test 0060 Workflow Features'
category_description = 'Test 0060 for workflow features'
workflow_repository_name = 'filtering_workflow_0060'
workflow_repository_description = "Workflow referencing the filtering tool for test 0060"
workflow_repository_long_description = "Long description of the workflow for test 0060"
class ToolWithRepositoryDependencies(ShedTwillTestCase):
'''Test installing a repository with repository dependencies.'''
def test_0000_initiate_users(self):
"""Create necessary user accounts."""
self.galaxy_login(email=common.admin_email, username=common.admin_username)
galaxy_admin_user = self.test_db_util.get_galaxy_user(common.admin_email)
assert galaxy_admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email
self.test_db_util.get_galaxy_private_role(galaxy_admin_user)
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
test_user_1 = self.test_db_util.get_user(common.test_user_1_email)
assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_1_email
self.test_db_util.get_private_role(test_user_1)
self.login(email=common.admin_email, username=common.admin_username)
admin_user = self.test_db_util.get_user(common.admin_email)
assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email
self.test_db_util.get_private_role(admin_user)
def test_0005_ensure_category_exists(self):
'''Create the 0060 category.'''
category = self.create_category(name=category_name, description=category_description)
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
repository = self.get_or_create_repository(name=repository_name,
description=repository_description,
long_description=repository_long_description,
owner=common.test_user_1_name,
category_id=self.security.encode_id(category.id),
strings_displayed=[])
if self.repository_is_new(repository):
workflow = open(self.get_filename('filtering_workflow/Workflow_for_0060_filter_workflow_repository.ga'), 'r').read()
workflow = workflow.replace('__TEST_TOOL_SHED_URL__', self.url.replace('http://', ''))
workflow_filepath = self.generate_temp_path('test_1060', additional_paths=['filtering_workflow'])
if not os.path.exists(workflow_filepath):
os.makedirs(workflow_filepath)
open(os.path.join(workflow_filepath, workflow_filename), 'w+').write(workflow)
self.upload_file(repository,
filename=workflow_filename,
filepath=workflow_filepath,
valid_tools_only=True,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded filtering workflow.',
strings_displayed=[],
strings_not_displayed=[])
self.upload_file(repository,
filename='filtering/filtering_2.2.0.tar',
filepath=None,
valid_tools_only=True,
uncompress_file=True,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded filtering 2.2.0.',
strings_displayed=[],
strings_not_displayed=[])
def test_0010_install_repository_with_workflow(self):
"""Browse the available tool sheds in this Galaxy instance and preview the filtering tool."""
self.preview_repository_in_tool_shed(repository_name,
common.test_user_1_name,
strings_displayed=[repository_name, 'Valid tools', 'Workflows'])
self.galaxy_login(email=common.admin_email, username=common.admin_username)
self.install_repository(repository_name,
common.test_user_1_name,
'Test 0060 Workflow Features',
install_tool_dependencies=False,
new_tool_panel_section_label='test_1060')
def test_0015_import_workflow_from_installed_repository(self):
'''Import the workflow from the installed repository and verify that it appears in the list of all workflows.'''
installed_repository = self.test_db_util.get_installed_repository_by_name_owner(repository_name, common.test_user_1_name)
self.display_installed_workflow_image(installed_repository,
workflow_name,
strings_displayed=['#EBD9B2'],
strings_not_displayed=['#EBBCB2'])
self.display_all_workflows(strings_not_displayed=['Workflow for 0060_filter_workflow_repository'])
self.import_workflow(installed_repository, workflow_name)
self.display_all_workflows(strings_displayed=['Workflow for 0060_filter_workflow_repository'])
def test_0020_create_filter_workflow_repository(self):
'''Create, if necessary, a filtering repository with only a workflow.'''
category = self.create_category(name=category_name, description=category_description)
self.login(email=common.test_user_1_email, username=common.test_user_1_name)
repository = self.get_or_create_repository(name=workflow_repository_name,
description=workflow_repository_description,
long_description=workflow_repository_long_description,
owner=common.test_user_1_name,
category_id=self.security.encode_id(category.id),
strings_displayed=[])
if self.repository_is_new(repository):
workflow = open(self.get_filename('filtering_workflow/Workflow_for_0060_filter_workflow_repository.ga'), 'r').read()
workflow = workflow.replace('__TEST_TOOL_SHED_URL__', self.url.replace('http://', ''))
workflow = workflow.replace('Workflow for 0060_filter_workflow_repository',
'New workflow for 0060_filter_workflow_repository')
workflow_filepath = self.generate_temp_path('test_0060', additional_paths=['filtering_workflow_2'])
if not os.path.exists(workflow_filepath):
os.makedirs(workflow_filepath)
open(os.path.join(workflow_filepath, workflow_filename), 'w+').write(workflow)
self.upload_file(repository,
filename=workflow_filename,
filepath=workflow_filepath,
valid_tools_only=True,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded filtering workflow.',
strings_displayed=[],
strings_not_displayed=[])
self.load_workflow_image_in_tool_shed(repository,
'New workflow for 0060_filter_workflow_repository',
strings_displayed=['#EBBCB2'])
def test_0025_install_repository_with_workflow(self):
"""Browse the available tool sheds in this Galaxy instance and preview the filtering workflow repository."""
self.preview_repository_in_tool_shed(workflow_repository_name,
common.test_user_1_name,
strings_displayed=['filtering_workflow_0060', 'Workflows'],
strings_not_displayed=['Valid tools', 'Invalid tools'])
self.galaxy_login(email=common.admin_email, username=common.admin_username)
self.install_repository(workflow_repository_name,
common.test_user_1_name,
'Test 0060 Workflow Features',
install_tool_dependencies=False,
includes_tools_for_display_in_tool_panel=False)
def test_0030_import_workflow_from_installed_repository(self):
'''Import the workflow from the installed repository and verify that it appears in the list of all workflows.'''
installed_repository = self.test_db_util.get_installed_repository_by_name_owner(workflow_repository_name, common.test_user_1_name)
self.display_installed_workflow_image(installed_repository,
'New workflow for 0060_filter_workflow_repository',
strings_displayed=['#EBD9B2'],
strings_not_displayed=['#EBBCB2'])
self.display_all_workflows(strings_not_displayed=['New workflow for 0060_filter_workflow_repository'])
self.import_workflow(installed_repository,
'New workflow for 0060_filter_workflow_repository',
strings_displayed=['New workflow for 0060_filter_workflow_repository'])
self.display_all_workflows(strings_displayed=['New workflow for 0060_filter_workflow_repository'])
-414
View File
@@ -1,414 +0,0 @@
""" Tool shed helper methods for dealing with workflows - only two methods are
utilized outside of this modules - generate_workflow_image and import_workflow.
"""
import json
import logging
import os
import galaxy.tools
import galaxy.tools.parameters
from galaxy.tools.repositories import ValidationContext
from galaxy.util.sanitize_html import sanitize_html
from galaxy.workflow.modules import (
module_types,
ToolModule,
WorkflowModuleFactory
)
from galaxy.workflow.render import WorkflowCanvas
from galaxy.workflow.steps import attach_ordered_steps
from tool_shed.tools import tool_validator
from tool_shed.util import (
encoding_util,
metadata_util,
repository_util
)
log = logging.getLogger(__name__)
class RepoToolModule(ToolModule):
type = "tool"
def __init__(self, trans, repository_id, changeset_revision, tools_metadata, tool_id):
self.trans = trans
self.tools_metadata = tools_metadata
self.tool_id = tool_id
self.tool = None
self.errors = None
self.tool_version = None
if trans.webapp.name == 'tool_shed':
# We're in the tool shed.
with ValidationContext.from_app(trans.app) as validation_context:
tv = tool_validator.ToolValidator(validation_context)
for tool_dict in tools_metadata:
if self.tool_id in [tool_dict['id'], tool_dict['guid']]:
repository, self.tool, valid, message = tv.load_tool_from_changeset_revision(repository_id,
changeset_revision,
tool_dict['tool_config'])
if self.tool is None and message or not valid:
self.errors = 'unavailable'
break
else:
# We're in Galaxy.
self.tool = trans.app.toolbox.get_tool(self.tool_id, tool_version=self.tool_version)
if self.tool is None:
self.errors = 'unavailable'
self.post_job_actions = {}
self.workflow_outputs = []
self.state = None
@classmethod
def from_dict(Class, trans, step_dict, repository_id, changeset_revision, tools_metadata, secure=True):
tool_id = step_dict['tool_id']
module = Class(trans, repository_id, changeset_revision, tools_metadata, tool_id)
module.state = galaxy.tools.DefaultToolState()
if module.tool is not None:
module.state.decode(step_dict["tool_state"], module.tool, module.trans.app)
module.errors = step_dict.get("tool_errors", None)
return module
@classmethod
def from_workflow_step(Class, trans, step, repository_id, changeset_revision, tools_metadata):
module = Class(trans, repository_id, changeset_revision, tools_metadata, step.tool_id)
module.state = galaxy.tools.DefaultToolState()
module.recover_state(step.tool_inputs)
module.errors = module.get_errors()
return module
def get_data_inputs(self):
data_inputs = []
def callback(input, prefixed_name, prefixed_label, **kwargs):
if isinstance(input, galaxy.tools.parameters.basic.DataToolParameter):
data_inputs.append(dict(name=prefixed_name,
label=prefixed_label,
extensions=input.extensions))
if self.tool:
try:
galaxy.tools.parameters.visit_input_values(self.tool.inputs, self.state.inputs, callback)
except Exception:
# TODO have this actually use default parameters? Fix at
# refactor, needs to be discussed wrt: reproducibility though.
log.exception("Tool parse failed for %s -- this indicates incompatibility of local tool version with expected version by the workflow.", self.tool.id)
return data_inputs
def get_data_outputs(self):
data_outputs = []
if self.tool:
data_inputs = None
for name, tool_output in self.tool.outputs.items():
if tool_output.format_source is not None:
# Default to special name "input" which remove restrictions on connections
formats = ['input']
if data_inputs is None:
data_inputs = self.get_data_inputs()
# Find the input parameter referenced by format_source
for di in data_inputs:
# Input names come prefixed with conditional and repeat names separated by '|',
# so remove prefixes when comparing with format_source.
if di['name'] is not None and di['name'].split('|')[-1] == tool_output.format_source:
formats = di['extensions']
else:
formats = [tool_output.format]
for change_elem in tool_output.change_format:
for when_elem in change_elem.findall('when'):
format = when_elem.get('format', None)
if format and format not in formats:
formats.append(format)
data_outputs.append(dict(name=name, extensions=formats))
return data_outputs
class RepoWorkflowModuleFactory(WorkflowModuleFactory):
def __init__(self, module_types):
self.module_types = module_types
def from_dict(self, trans, repository_id, changeset_revision, step_dict, tools_metadata, **kwd):
"""Return module initialized from the data in dictionary `step_dict`."""
type = step_dict['type']
assert type in self.module_types
module_method_kwds = dict(**kwd)
if type == "tool":
module_method_kwds['repository_id'] = repository_id
module_method_kwds['changeset_revision'] = changeset_revision
module_method_kwds['tools_metadata'] = tools_metadata
return self.module_types[type].from_dict(trans, step_dict, **module_method_kwds)
def from_workflow_step(self, trans, repository_id, changeset_revision, tools_metadata, step):
"""Return module initialized from the WorkflowStep object `step`."""
type = step.type
module_method_kwds = dict()
if type == "tool":
module_method_kwds['repository_id'] = repository_id
module_method_kwds['changeset_revision'] = changeset_revision
module_method_kwds['tools_metadata'] = tools_metadata
return self.module_types[type].from_workflow_step(trans, step, **module_method_kwds)
tool_shed_module_types = module_types.copy()
tool_shed_module_types['tool'] = RepoToolModule
module_factory = RepoWorkflowModuleFactory(tool_shed_module_types)
def generate_workflow_image(trans, workflow_name, repository_metadata_id=None, repository_id=None):
"""
Return an svg image representation of a workflow dictionary created when the workflow was exported. This method is called
from both Galaxy and the tool shed. When called from the tool shed, repository_metadata_id will have a value and repository_id
will be None. When called from Galaxy, repository_metadata_id will be None and repository_id will have a value.
"""
workflow_name = encoding_util.tool_shed_decode(workflow_name)
if trans.webapp.name == 'tool_shed':
# We're in the tool shed.
repository_metadata = metadata_util.get_repository_metadata_by_id(trans.app, repository_metadata_id)
repository_id = trans.security.encode_id(repository_metadata.repository_id)
changeset_revision = repository_metadata.changeset_revision
metadata = repository_metadata.metadata
else:
# We're in Galaxy.
repository = repository_util.get_tool_shed_repository_by_id(trans.app, repository_id)
changeset_revision = repository.changeset_revision
metadata = repository.metadata
# metadata[ 'workflows' ] is a list of tuples where each contained tuple is
# [ <relative path to the .ga file in the repository>, <exported workflow dict> ]
for workflow_tup in metadata['workflows']:
workflow_dict = workflow_tup[1]
if workflow_dict['name'] == workflow_name:
break
if 'tools' in metadata:
tools_metadata = metadata['tools']
else:
tools_metadata = []
workflow, missing_tool_tups = get_workflow_from_dict(trans=trans,
workflow_dict=workflow_dict,
tools_metadata=tools_metadata,
repository_id=repository_id,
changeset_revision=changeset_revision)
workflow_canvas = WorkflowCanvas()
canvas = workflow_canvas.canvas
# Store px width for boxes of each step.
for step in workflow.steps:
step.upgrade_messages = {}
module = module_factory.from_workflow_step(trans, repository_id, changeset_revision, tools_metadata, step)
tool_errors = module.type == 'tool' and not module.tool
module_data_inputs = get_workflow_data_inputs(step, module)
module_data_outputs = get_workflow_data_outputs(step, module, workflow.steps)
module_name = get_workflow_module_name(module, missing_tool_tups)
workflow_canvas.populate_data_for_step(
step,
module_name,
module_data_inputs,
module_data_outputs,
tool_errors=tool_errors
)
workflow_canvas.add_steps(highlight_errors=True)
workflow_canvas.finish()
trans.response.set_content_type("image/svg+xml")
return canvas.tostring()
def get_workflow_data_inputs(step, module):
if module.type == 'tool':
if module.tool:
return module.get_data_inputs()
else:
data_inputs = []
for wfsc in step.input_connections:
data_inputs_dict = {}
data_inputs_dict['extensions'] = ['']
data_inputs_dict['name'] = wfsc.input_name
data_inputs_dict['label'] = 'Unknown'
data_inputs.append(data_inputs_dict)
return data_inputs
return module.get_data_inputs()
def get_workflow_data_outputs(step, module, steps):
if module.type == 'tool':
if module.tool:
return module.get_data_outputs()
else:
data_outputs = []
data_outputs_dict = {}
data_outputs_dict['extensions'] = ['input']
found = False
for workflow_step in steps:
for wfsc in workflow_step.input_connections:
if step.label == wfsc.output_step.label:
data_outputs_dict['name'] = wfsc.output_name
found = True
break
if found:
break
if not found:
# We're at the last step of the workflow.
data_outputs_dict['name'] = 'output'
data_outputs.append(data_outputs_dict)
return data_outputs
return module.get_data_outputs()
def get_workflow_from_dict(trans, workflow_dict, tools_metadata, repository_id, changeset_revision):
"""
Return an in-memory Workflow object from the dictionary object created when it was exported. This method is called from
both Galaxy and the tool shed to retrieve a Workflow object that can be displayed as an SVG image. This method is also
called from Galaxy to retrieve a Workflow object that can be used for saving to the Galaxy database.
"""
trans.workflow_building_mode = True
workflow = trans.model.Workflow()
workflow.name = workflow_dict['name']
workflow.has_errors = False
steps = []
# Keep ids for each step that we need to use to make connections.
steps_by_external_id = {}
# Keep track of tools required by the workflow that are not available in
# the tool shed repository. Each tuple in the list of missing_tool_tups
# will be ( tool_id, tool_name, tool_version ).
missing_tool_tups = []
# First pass to build step objects and populate basic values
for step_dict in workflow_dict['steps'].values():
# Create the model class for the step
step = trans.model.WorkflowStep()
step.label = step_dict.get('label', None)
step.position = step_dict['position']
module = module_factory.from_dict(trans, repository_id, changeset_revision, step_dict, tools_metadata=tools_metadata)
if module.type == 'tool' and module.tool is None:
# A required tool is not available in the current repository.
step.tool_errors = 'unavailable'
missing_tool_tup = (step_dict['tool_id'], step_dict['name'], step_dict['tool_version'])
if missing_tool_tup not in missing_tool_tups:
missing_tool_tups.append(missing_tool_tup)
module.save_to_step(step)
if step.tool_errors:
workflow.has_errors = True
# Stick this in the step temporarily.
step.temp_input_connections = step_dict['input_connections']
if trans.webapp.name == 'galaxy':
annotation = step_dict.get('annotation', '')
if annotation:
annotation = sanitize_html(annotation)
new_step_annotation = trans.model.WorkflowStepAnnotationAssociation()
new_step_annotation.annotation = annotation
new_step_annotation.user = trans.user
step.annotations.append(new_step_annotation)
# Unpack and add post-job actions.
post_job_actions = step_dict.get('post_job_actions', {})
for pja_dict in post_job_actions.values():
trans.model.PostJobAction(pja_dict['action_type'],
step,
pja_dict['output_name'],
pja_dict['action_arguments'])
steps.append(step)
steps_by_external_id[step_dict['id']] = step
# Second pass to deal with connections between steps.
for step in steps:
# Input connections.
for input_name, conn_dict in step.temp_input_connections.items():
if conn_dict:
step_input = step.get_or_add_input(input_name)
output_step = steps_by_external_id[conn_dict['id']]
conn = trans.model.WorkflowStepConnection()
conn.input_step_input = step_input
conn.output_step = output_step
conn.output_name = conn_dict['output_name']
del step.temp_input_connections
# Order the steps if possible.
attach_ordered_steps(workflow, steps)
# Return the in-memory Workflow object for display or later persistence to the Galaxy database.
return workflow, missing_tool_tups
def get_workflow_module_name(module, missing_tool_tups):
module_name = module.get_name()
if module.type == 'tool' and module_name == 'unavailable':
for missing_tool_tup in missing_tool_tups:
missing_tool_id, missing_tool_name, missing_tool_version = missing_tool_tup
if missing_tool_id == module.tool_id:
module_name = '%s' % missing_tool_name
break
return module_name
def import_workflow(trans, repository, workflow_name):
"""Import a workflow contained in an installed tool shed repository into Galaxy (this method is called only from Galaxy)."""
status = 'done'
message = ''
changeset_revision = repository.changeset_revision
metadata = repository.metadata
workflows = metadata.get('workflows', [])
tools_metadata = metadata.get('tools', [])
workflow_dict = None
for workflow_data_tuple in workflows:
# The value of workflow_data_tuple is ( relative_path_to_workflow_file, exported_workflow_dict ).
relative_path_to_workflow_file, exported_workflow_dict = workflow_data_tuple
if exported_workflow_dict['name'] == workflow_name:
# If the exported workflow is available on disk, import it.
if os.path.exists(relative_path_to_workflow_file):
workflow_file = open(relative_path_to_workflow_file, 'rb')
workflow_data = workflow_file.read()
workflow_file.close()
workflow_dict = json.loads(workflow_data)
else:
# Use the current exported_workflow_dict.
workflow_dict = exported_workflow_dict
break
if workflow_dict:
# Create workflow if possible.
workflow, missing_tool_tups = get_workflow_from_dict(trans=trans,
workflow_dict=workflow_dict,
tools_metadata=tools_metadata,
repository_id=repository.id,
changeset_revision=changeset_revision)
# Save the workflow in the Galaxy database. Pass workflow_dict along to create annotation at this point.
stored_workflow = save_workflow(trans, workflow, workflow_dict)
# Use the latest version of the saved workflow.
workflow = stored_workflow.latest_workflow
if workflow_name:
workflow.name = workflow_name
# Provide user feedback and show workflow list.
if workflow.has_errors:
message += "Imported, but some steps in this workflow have validation errors. "
status = "error"
if workflow.has_cycles:
message += "Imported, but this workflow contains cycles. "
status = "error"
else:
message += "Workflow <b>%s</b> imported successfully. " % workflow.name
if missing_tool_tups:
name_and_id_str = ''
for missing_tool_tup in missing_tool_tups:
tool_id, tool_name, other = missing_tool_tup
name_and_id_str += 'name: %s, id: %s' % (str(tool_id), str(tool_name))
message += "The following tools required by this workflow are missing from this Galaxy instance: %s. " % name_and_id_str
else:
workflow = None
message += 'The workflow named %s is not included in the metadata for revision %s of repository %s' % \
(str(workflow_name), str(changeset_revision), str(repository.name))
status = 'error'
return workflow, status, message
def save_workflow(trans, workflow, workflow_dict=None):
"""Use the received in-memory Workflow object for saving to the Galaxy database."""
stored = trans.model.StoredWorkflow()
stored.name = workflow.name
workflow.stored_workflow = stored
stored.latest_workflow = workflow
stored.user = trans.user
if workflow_dict and workflow_dict.get('annotation', ''):
annotation = sanitize_html(workflow_dict['annotation'])
new_annotation = trans.model.StoredWorkflowAnnotationAssociation()
new_annotation.annotation = annotation
new_annotation.user = trans.user
stored.annotations.append(new_annotation)
trans.sa_session.add(stored)
trans.sa_session.flush()
# Add a new entry to the Workflows menu.
if trans.user.stored_workflow_menu_entries is None:
trans.user.stored_workflow_menu_entries = []
menuEntry = trans.model.StoredWorkflowMenuEntry()
menuEntry.stored_workflow = stored
trans.user.stored_workflow_menu_entries.append(menuEntry)
trans.sa_session.flush()
return stored
+2 -122
View File
@@ -42,8 +42,7 @@ from tool_shed.util import (
repository_util,
search_util,
shed_util_common as suc,
tool_util,
workflow_util
tool_util
)
from tool_shed.util.web_util import escape
from tool_shed.utility_containers import ToolShedUtilityContainerManager
@@ -1077,9 +1076,7 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
global_actions = [grids.GridAction("Browse valid repositories",
dict(controller='repository', action='browse_valid_categories')),
grids.GridAction("Search for valid tools",
dict(controller='repository', action='find_tools')),
grids.GridAction("Search for workflows",
dict(controller='repository', action='find_workflows'))]
dict(controller='repository', action='find_tools'))]
self.install_matched_repository_grid.global_actions = global_actions
install_url_args = dict(controller='repository', action='find_tools')
operations = [grids.GridOperation("Install", url_args=install_url_args, allow_multiple=True, async_compatible=False)]
@@ -1105,101 +1102,6 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
message=message,
status=status)
@web.expose
def find_workflows(self, trans, **kwd):
message = escape(kwd.get('message', ''))
status = kwd.get('status', 'done')
common_util.handle_galaxy_url(trans, **kwd)
if 'operation' in kwd:
item_id = kwd.get('id', '')
if item_id:
operation = kwd['operation'].lower()
is_admin = trans.user_is_admin
if operation == "view_or_manage_repository":
# The received id is a RepositoryMetadata id, so we have to get the repository id.
repository_metadata = metadata_util.get_repository_metadata_by_id(trans.app, item_id)
repository_id = trans.security.encode_id(repository_metadata.repository.id)
repository = repository_util.get_repository_in_tool_shed(trans.app, repository_id)
kwd['id'] = repository_id
kwd['changeset_revision'] = repository_metadata.changeset_revision
if trans.webapp.name == 'tool_shed' and (is_admin or repository.user == trans.user):
a = 'manage_repository'
else:
a = 'view_repository'
return trans.response.send_redirect(web.url_for(controller='repository',
action=a,
**kwd))
if operation == "install to galaxy":
# We've received a list of RepositoryMetadata ids, so we need to build a list of associated Repository ids.
encoded_repository_ids = []
changeset_revisions = []
for repository_metadata_id in util.listify(item_id):
repository_metadata = metadata_util.get_repository_metadata_by_id(trans.app, item_id)
encoded_repository_ids.append(trans.security.encode_id(repository_metadata.repository.id))
changeset_revisions.append(repository_metadata.changeset_revision)
new_kwd = {}
new_kwd['repository_ids'] = encoded_repository_ids
new_kwd['changeset_revisions'] = changeset_revisions
return trans.response.send_redirect(web.url_for(controller='repository',
action='install_repositories_by_revision',
**new_kwd))
else:
# This can only occur when there is a multi-select grid with check boxes and an operation,
# and the user clicked the operation button without checking any of the check boxes.
return trans.show_error_message("No items were selected.")
if 'find_workflows_button' in kwd:
workflow_names = [item.lower() for item in util.listify(kwd.get('workflow_name', ''))]
exact_matches = kwd.get('exact_matches', '')
exact_matches_checked = CheckboxField.is_checked(exact_matches)
match_tuples = []
ok = True
if workflow_names:
ok, match_tuples = search_util.search_repository_metadata(trans.app,
exact_matches_checked,
workflow_names=workflow_names)
else:
ok, match_tuples = search_util.search_repository_metadata(trans.app,
exact_matches_checked,
workflow_names=[],
all_workflows=True)
if ok:
kwd['match_tuples'] = match_tuples
if trans.webapp.name == 'galaxy':
# Our initial request originated from a Galaxy instance.
global_actions = [grids.GridAction("Browse valid repositories",
dict(controller='repository', action='browse_valid_repositories')),
grids.GridAction("Search for valid tools",
dict(controller='repository', action='find_tools')),
grids.GridAction("Search for workflows",
dict(controller='repository', action='find_workflows'))]
self.install_matched_repository_grid.global_actions = global_actions
install_url_args = dict(controller='repository', action='find_workflows')
operations = [grids.GridOperation("Install", url_args=install_url_args, allow_multiple=True, async_compatible=False)]
self.install_matched_repository_grid.operations = operations
return self.install_matched_repository_grid(trans, **kwd)
else:
kwd['message'] = "workflow name: <b>%s</b><br/>exact matches only: <b>%s</b>" % \
(escape(basic_util.stringify(workflow_names)), str(exact_matches_checked))
self.matched_repository_grid.title = "Repositories with matching workflows"
return self.matched_repository_grid(trans, **kwd)
else:
message = "No search performed - each field must contain the same number of comma-separated items."
status = "error"
else:
exact_matches_checked = False
workflow_names = []
exact_matches_check_box = CheckboxField('exact_matches', value=exact_matches_checked)
return trans.fill_template('/webapps/tool_shed/repository/find_workflows.mako',
workflow_name=basic_util.stringify(workflow_names),
exact_matches_check_box=exact_matches_check_box,
message=message,
status=status)
@web.expose
def generate_workflow_image(self, trans, workflow_name, repository_metadata_id=None):
"""Return an svg image representation of a workflow dictionary created when the workflow was exported."""
return workflow_util.generate_workflow_image(trans, workflow_name, repository_metadata_id=repository_metadata_id, repository_id=None)
@web.expose
def get_changeset_revision_and_ctx_rev(self, trans, **kwd):
"""Handle a request from a local Galaxy instance to retrieve the changeset revision hash to which an installed repository can be updated."""
@@ -2965,28 +2867,6 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
message=message,
status=status)
@web.expose
def view_workflow(self, trans, workflow_name, repository_metadata_id, **kwd):
"""Retrieve necessary information about a workflow from the database so that it can be displayed in an svg image."""
message = escape(kwd.get('message', ''))
status = kwd.get('status', 'done')
render_repository_actions_for = kwd.get('render_repository_actions_for', 'tool_shed')
if workflow_name:
workflow_name = encoding_util.tool_shed_decode(workflow_name)
repository_metadata = metadata_util.get_repository_metadata_by_id(trans.app, repository_metadata_id)
repository = repository_util.get_repository_in_tool_shed(trans.app, trans.security.encode_id(repository_metadata.repository_id))
changeset_revision = repository_metadata.changeset_revision
metadata = repository_metadata.metadata
return trans.fill_template("/webapps/tool_shed/repository/view_workflow.mako",
repository=repository,
render_repository_actions_for=render_repository_actions_for,
changeset_revision=changeset_revision,
repository_metadata_id=repository_metadata_id,
workflow_name=workflow_name,
metadata=metadata,
message=message,
status=status)
def validate_changeset_revision(self, trans, changeset_revision, repository_id):
"""In case changeset revision is invalid send them to the repository page"""
if changeset_revision:
@@ -16,9 +16,6 @@
<ul class="manage-table-actions">
<li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li>
<div popupmenu="repository-${repository.id}-popup">
%if workflow_name:
<li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='admin_toolshed', action='import_workflow', workflow_name=tool_shed_encode( workflow_name ), repository_id=trans.security.encode_id( repository.id ) )}">Import workflow to Galaxy</a></li>
%endif
%if repository.can_reinstall_or_activate:
<a class="action-button" href="${h.url_for( controller='admin_toolshed', action='restore_repository', id=trans.security.encode_id( repository.id ) )}">Activate or reinstall repository</a>
%endif
@@ -1,37 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%namespace file="/admin/tool_shed_repository/repository_actions_menu.mako" import="*" />
<% from tool_shed.util.encoding_util import tool_shed_encode %>
<%!
def inherit(context):
if context.get('use_panels'):
return '/webapps/tool_shed/base_panels.mako'
else:
return '/base.mako'
%>
<%inherit file="${inherit(context)}"/>
<%def name="render_workflow( workflow_name, repository_id )">
<% center_url = h.url_for( controller='admin_toolshed', action='generate_workflow_image', workflow_name=tool_shed_encode( workflow_name ), repository_id=repository_id ) %>
<iframe name="workflow_image" id="workflow_image" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${center_url|h}"> </iframe>
</%def>
${render_galaxy_repository_actions( repository )}
%if message:
${render_msg( message, status )}
%endif
<div class="card-header">${workflow_name | h}</div>
<div class="form-row">
<div class="toolParamHelp" style="clear: both;">
(this page displays SVG graphics)
</div>
</div>
<br clear="left"/>
${render_workflow( workflow_name, repository_id )}
@@ -42,10 +42,6 @@
<td>Invalid versions of tools</td>
<td>${trans.app.shed_counter.invalid_versions_of_tools | h}</td>
</tr>
<tr>
<td>Exported Galaxy workflows</td>
<td>${trans.app.shed_counter.workflows | h}</td>
</tr>
<tr>
<td>Custom datatypes</td>
<td>${trans.app.shed_counter.custom_datatypes | h}</td>
@@ -199,12 +199,10 @@
<div popupmenu="repository-${repository.id}-popup">
<a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='browse_valid_categories' )}">Browse valid repositories</a>
<a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a>
<a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a>
</div>
%else:
<li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='browse_valid_categories' )}">Browse valid repositories</a></li>
<a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a>
<li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a></li>
%endif
</ul>
</%def>
@@ -57,9 +57,6 @@
<div class="toolTitle">
<a target="galaxy_main" href="${h.url_for( controller='repository', action='find_tools' )}">Search for valid tools</a>
</div>
<div class="toolTitle">
<a target="galaxy_main" href="${h.url_for( controller='repository', action='find_workflows' )}">Search for workflows</a>
</div>
</div>
<div class="toolSectionPad"></div>
<div class="toolSectionTitle">
@@ -299,12 +299,6 @@
else:
folder_label = "%s<i> - repository tools require handling of these dependencies</i>" % folder_label
col_span_str = 'colspan="4"'
elif folder.workflows:
if folder.description:
folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description )
else:
folder_label = "%s<i> - click the name to view an SVG image of the workflow</i>" % folder_label
col_span_str = 'colspan="4"'
elif folder.valid_data_managers:
if folder.description:
folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description )
@@ -358,12 +352,6 @@
%for invalid_tool in folder.invalid_tools:
${render_invalid_tool( invalid_tool, pad, my_row, row_counter, render_repository_actions_for=render_repository_actions_for )}
%endfor
%if folder.workflows:
%for index, workflow in enumerate( folder.workflows ):
<% row_is_header = index == 0 %>
${render_workflow( workflow, pad, my_row, row_counter, row_is_header, render_repository_actions_for=render_repository_actions_for )}
%endfor
%endif
%if folder.datatypes:
%for index, datatype in enumerate( folder.datatypes ):
<% row_is_header = index == 0 %>
@@ -990,48 +978,6 @@
%>
</%def>
<%def name="render_workflow( workflow, pad, parent, row_counter, row_is_header=False, render_repository_actions_for='tool_shed' )">
<%
from tool_shed.util.encoding_util import tool_shed_encode
encoded_id = trans.security.encode_id( workflow.id )
encoded_workflow_name = tool_shed_encode( workflow.workflow_name )
if trans.webapp.name == 'tool_shed':
encoded_repository_metadata_id = trans.security.encode_id( workflow.repository_metadata_id )
encoded_repository_id = None
else:
encoded_repository_metadata_id = None
encoded_repository_id = trans.security.encode_id( workflow.repository_id )
if row_is_header:
cell_type = 'th'
else:
cell_type = 'td'
%>
<tr class="datasetRow"
%if parent is not None:
parent="${parent}"
%endif
id="libraryItem-rw-${encoded_id}">
<${cell_type} style="padding-left: ${pad+20}px;">
%if row_is_header:
${workflow.workflow_name | h}
%elif trans.webapp.name == 'tool_shed' and encoded_repository_metadata_id:
<a href="${h.url_for( controller='repository', action='view_workflow', workflow_name=encoded_workflow_name, repository_metadata_id=encoded_repository_metadata_id, render_repository_actions_for=render_repository_actions_for )}">${workflow.workflow_name | h}</a>
%elif trans.webapp.name == 'galaxy' and encoded_repository_id:
<a href="${h.url_for( controller='admin_toolshed', action='view_workflow', workflow_name=encoded_workflow_name, repository_id=encoded_repository_id )}">${workflow.workflow_name | h}</a>
%else:
${workflow.workflow_name | h}
%endif
</${cell_type}>
<${cell_type}>${workflow.steps | h}</${cell_type}>
<${cell_type}>${workflow.format_version | h}</${cell_type}>
<${cell_type}>${workflow.annotation | h}</${cell_type}>
</tr>
<%
my_row = row_counter.count
row_counter.increment()
%>
</%def>
<%def name="render_dependency_status( dependency, prepare_for_install=False)">
<td>${dependency['name'] | h}</td>
<td>${dependency['version'] | h}</td>
@@ -1109,7 +1055,6 @@
has_datatypes = metadata and 'datatypes' in metadata
has_readme_files = metadata and 'readme_files' in metadata
has_workflows = metadata and 'workflows' in metadata
datatypes_root_folder = containers_dict.get( 'datatypes', None )
invalid_data_managers_root_folder = containers_dict.get( 'invalid_data_managers', None )
@@ -1125,9 +1070,8 @@
tool_test_results_root_folder = containers_dict.get( 'tool_test_results', None )
valid_data_managers_root_folder = containers_dict.get( 'valid_data_managers', None )
valid_tools_root_folder = containers_dict.get( 'valid_tools', None )
workflows_root_folder = containers_dict.get( 'workflows', None )
has_contents = datatypes_root_folder or invalid_tools_root_folder or valid_tools_root_folder or workflows_root_folder
has_contents = datatypes_root_folder or invalid_tools_root_folder or valid_tools_root_folder
has_dependencies = \
invalid_repository_dependencies_root_folder or \
invalid_tool_dependencies_root_folder or \
@@ -1240,13 +1184,6 @@
${render_folder( invalid_data_managers_root_folder, 0, parent=None, row_counter=row_counter, is_root_folder=True, render_repository_actions_for=render_repository_actions_for )}
</table>
%endif
%if workflows_root_folder:
<p/>
<% row_counter = RowCounter() %>
<table cellspacing="2" cellpadding="2" border="0" width="100%" class="tables container-table" id="workflows">
${render_folder( workflows_root_folder, 0, parent=None, row_counter=row_counter, is_root_folder=True, render_repository_actions_for=render_repository_actions_for )}
</table>
%endif
%if datatypes_root_folder:
<p/>
<% row_counter = RowCounter() %>
@@ -1,51 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/repository_actions_menu.mako" import="render_galaxy_repository_actions" />
<%!
def inherit(context):
if context.get('use_panels'):
return '/webapps/tool_shed/base_panels.mako'
else:
return '/base.mako'
%>
<%inherit file="${inherit(context)}"/>
%if trans.webapp.name == 'galaxy':
${render_galaxy_repository_actions( repository=None )}
%endif
%if message:
${render_msg( message, status )}
%endif
<div class="toolForm">
<div class="toolFormTitle">Search repositories for workflows</div>
<div class="toolFormBody">
<div class="form-row">
Enter a workflow name to find repositories that contain workflows matching the search criteria, or leave blank to find all repositories that contain a workflow.<br/><br/>
Comma-separated strings may be entered to expand search criteria.
</div>
<div style="clear: both"></div>
<form name="find_workflows" id="find_workflows" action="${h.url_for( controller='repository', action='find_workflows' )}" method="post" >
<div style="clear: both"></div>
<div class="form-row">
<label>Workflow name:</label>
<input name="workflow_name" type="textfield" value="${workflow_name | h}" size="40"/>
</div>
<div style="clear: both"></div>
<div class="form-row">
<label>Exact matches only:</label>
${render_checkbox(exact_matches_check_box)}
<div class="toolParamHelp" style="clear: both;">
Check the box to match text exactly (text case doesn't matter as all strings are forced to lower case).
</div>
</div>
<div style="clear: both"></div>
<div class="form-row">
<input type="submit" name="find_workflows_button" value="Search repositories"/>
</div>
</form>
</div>
</div>
@@ -1,43 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/repository_actions_menu.mako" import="*" />
<%!
def inherit(context):
if context.get('use_panels'):
return '/webapps/tool_shed/base_panels.mako'
else:
return '/base.mako'
%>
<%inherit file="${inherit(context)}"/>
<% from tool_shed.util.encoding_util import tool_shed_encode %>
<%def name="render_workflow( workflow_name, repository_metadata_id )">
<% center_url = h.url_for( controller='repository', action='generate_workflow_image', workflow_name=tool_shed_encode( workflow_name ), repository_metadata_id=repository_metadata_id ) %>
<iframe name="workflow_image" id="workflow_image" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${center_url}"> </iframe>
</%def>
%if render_repository_actions_for == 'tool_shed':
${render_tool_shed_repository_actions( repository=repository )}
%else:
${render_galaxy_repository_actions( repository=repository )}
%endif
%if message:
${render_msg( message, status )}
%endif
<div class="toolFormTitle">${workflow_name | h}</div>
<div class="form-row">
<b>Boxes are red when tools are not available in this repository</b>
<div class="toolParamHelp" style="clear: both;">
(this page displays SVG graphics)
</div>
</div>
<br clear="left"/>
${render_workflow( workflow_name, repository_metadata_id )}
@@ -16,9 +16,6 @@
<ul class="manage-table-actions">
<li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li>
<div popupmenu="repository-${repository.id}-popup">
%if workflow_name:
<li><a class="action-button" target="galaxy_main" href="${h.url_for( controller='admin_toolshed', action='import_workflow', workflow_name=tool_shed_encode( workflow_name ), repository_id=trans.security.encode_id( repository.id ) )}">Import workflow to Galaxy</a></li>
%endif
%if repository.can_reinstall_or_activate:
<a class="action-button" href="${h.url_for( controller='admin_toolshed', action='restore_repository', id=trans.security.encode_id( repository.id ) )}">Activate or reinstall repository</a>
%endif
@@ -1,37 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%namespace file="/admin/tool_shed_repository/repository_actions_menu.mako" import="*" />
<% from tool_shed.util.encoding_util import tool_shed_encode %>
<%!
def inherit(context):
if context.get('use_panels'):
return '/webapps/tool_shed/base_panels.mako'
else:
return '/base.mako'
%>
<%inherit file="${inherit(context)}"/>
<%def name="render_workflow( workflow_name, repository_id )">
<% center_url = h.url_for( controller='admin_toolshed', action='generate_workflow_image', workflow_name=tool_shed_encode( workflow_name ), repository_id=repository_id ) %>
<iframe name="workflow_image" id="workflow_image" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${center_url|h}"> </iframe>
</%def>
${render_galaxy_repository_actions( repository )}
%if message:
${render_msg( message, status )}
%endif
<div class="card-header">${workflow_name | h}</div>
<div class="form-row">
<div class="toolParamHelp" style="clear: both;">
(this page displays SVG graphics)
</div>
</div>
<br clear="left"/>
${render_workflow( workflow_name, repository_id )}
@@ -299,12 +299,6 @@
else:
folder_label = "%s<i> - repository tools require handling of these dependencies</i>" % folder_label
col_span_str = 'colspan="4"'
elif folder.workflows:
if folder.description:
folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description )
else:
folder_label = "%s<i> - click the name to view an SVG image of the workflow</i>" % folder_label
col_span_str = 'colspan="4"'
elif folder.valid_data_managers:
if folder.description:
folder_label = "%s<i> - %s</i>" % ( folder_label, folder.description )
@@ -358,12 +352,6 @@
%for invalid_tool in folder.invalid_tools:
${render_invalid_tool( invalid_tool, pad, my_row, row_counter, render_repository_actions_for=render_repository_actions_for )}
%endfor
%if folder.workflows:
%for index, workflow in enumerate( folder.workflows ):
<% row_is_header = index == 0 %>
${render_workflow( workflow, pad, my_row, row_counter, row_is_header, render_repository_actions_for=render_repository_actions_for )}
%endfor
%endif
%if folder.datatypes:
%for index, datatype in enumerate( folder.datatypes ):
<% row_is_header = index == 0 %>
@@ -990,48 +978,6 @@
%>
</%def>
<%def name="render_workflow( workflow, pad, parent, row_counter, row_is_header=False, render_repository_actions_for='tool_shed' )">
<%
from tool_shed.util.encoding_util import tool_shed_encode
encoded_id = trans.security.encode_id( workflow.id )
encoded_workflow_name = tool_shed_encode( workflow.workflow_name )
if trans.webapp.name == 'tool_shed':
encoded_repository_metadata_id = trans.security.encode_id( workflow.repository_metadata_id )
encoded_repository_id = None
else:
encoded_repository_metadata_id = None
encoded_repository_id = trans.security.encode_id( workflow.repository_id )
if row_is_header:
cell_type = 'th'
else:
cell_type = 'td'
%>
<tr class="datasetRow"
%if parent is not None:
parent="${parent}"
%endif
id="libraryItem-rw-${encoded_id}">
<${cell_type} style="padding-left: ${pad+20}px;">
%if row_is_header:
${workflow.workflow_name | h}
%elif trans.webapp.name == 'tool_shed' and encoded_repository_metadata_id:
<a href="${h.url_for( controller='repository', action='view_workflow', workflow_name=encoded_workflow_name, repository_metadata_id=encoded_repository_metadata_id, render_repository_actions_for=render_repository_actions_for )}">${workflow.workflow_name | h}</a>
%elif trans.webapp.name == 'galaxy' and encoded_repository_id:
<a href="${h.url_for( controller='admin_toolshed', action='view_workflow', workflow_name=encoded_workflow_name, repository_id=encoded_repository_id )}">${workflow.workflow_name | h}</a>
%else:
${workflow.workflow_name | h}
%endif
</${cell_type}>
<${cell_type}>${workflow.steps | h}</${cell_type}>
<${cell_type}>${workflow.format_version | h}</${cell_type}>
<${cell_type}>${workflow.annotation | h}</${cell_type}>
</tr>
<%
my_row = row_counter.count
row_counter.increment()
%>
</%def>
<%def name="render_dependency_status( dependency, prepare_for_install=False)">
<td>${dependency['name'] | h}</td>
<td>${dependency['version'] | h}</td>
@@ -1109,7 +1055,6 @@
has_datatypes = metadata and 'datatypes' in metadata
has_readme_files = metadata and 'readme_files' in metadata
has_workflows = metadata and 'workflows' in metadata
datatypes_root_folder = containers_dict.get( 'datatypes', None )
invalid_data_managers_root_folder = containers_dict.get( 'invalid_data_managers', None )
@@ -1125,9 +1070,8 @@
tool_test_results_root_folder = containers_dict.get( 'tool_test_results', None )
valid_data_managers_root_folder = containers_dict.get( 'valid_data_managers', None )
valid_tools_root_folder = containers_dict.get( 'valid_tools', None )
workflows_root_folder = containers_dict.get( 'workflows', None )
has_contents = datatypes_root_folder or invalid_tools_root_folder or valid_tools_root_folder or workflows_root_folder
has_contents = datatypes_root_folder or invalid_tools_root_folder or valid_tools_root_folder
has_dependencies = \
invalid_repository_dependencies_root_folder or \
invalid_tool_dependencies_root_folder or \
@@ -1240,13 +1184,6 @@
${render_folder( invalid_data_managers_root_folder, 0, parent=None, row_counter=row_counter, is_root_folder=True, render_repository_actions_for=render_repository_actions_for )}
</table>
%endif
%if workflows_root_folder:
<p/>
<% row_counter = RowCounter() %>
<table cellspacing="2" cellpadding="2" border="0" width="100%" class="tables container-table" id="workflows">
${render_folder( workflows_root_folder, 0, parent=None, row_counter=row_counter, is_root_folder=True, render_repository_actions_for=render_repository_actions_for )}
</table>
%endif
%if datatypes_root_folder:
<p/>
<% row_counter = RowCounter() %>