diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index b5cacb61b3d..efe28b1165f 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -1100,13 +1100,13 @@ class ConfiguresGalaxyMixin(object): self.security = idencoding.IdEncodingHelper(id_secret=self.config.id_secret) def _configure_tool_shed_registry(self): - import tool_shed.tool_shed_registry + import galaxy.tool_shed.tool_shed_registry # Set up the tool sheds registry if os.path.isfile(self.config.tool_sheds_config_file): - self.tool_shed_registry = tool_shed.tool_shed_registry.Registry(self.config.tool_sheds_config_file) + self.tool_shed_registry = galaxy.tool_shed.tool_shed_registry.Registry(self.config.tool_sheds_config_file) else: - self.tool_shed_registry = tool_shed.tool_shed_registry.Registry() + self.tool_shed_registry = galaxy.tool_shed.tool_shed_registry.Registry() def _configure_models(self, check_migrate_databases=False, check_migrate_tools=False, config_file=None): """ diff --git a/lib/galaxy/tool_shed/util/tool_dependency_util.py b/lib/galaxy/tool_shed/util/tool_dependency_util.py index 4f06673d50d..3800d5fcc03 100644 --- a/lib/galaxy/tool_shed/util/tool_dependency_util.py +++ b/lib/galaxy/tool_shed/util/tool_dependency_util.py @@ -5,9 +5,9 @@ import shutil from sqlalchemy import and_ from galaxy import util -from galaxy.web.form_builder import SelectField from galaxy.tool_shed.util.hg_util import get_config_from_disk from galaxy.util.tool_shed.xml_util import parse_xml +from galaxy.web.form_builder import SelectField log = logging.getLogger(__name__) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index bb41de94bfe..8608b0604d4 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -24,8 +24,6 @@ from six import itervalues, string_types from six.moves.urllib.parse import unquote_plus from webob.compat import cgi_FieldStorage -import tool_shed.util.repository_util as repository_util -import tool_shed.util.shed_util_common from galaxy import ( exceptions, model @@ -34,6 +32,8 @@ from galaxy.job_execution import output_collect from galaxy.managers.jobs import JobSearch from galaxy.metadata import get_metadata_compute_strategy from galaxy.model.tags import GalaxyTagHandler +from galaxy.tool_shed.util.repository_util import get_installed_repository +from galaxy.tool_shed.util.shed_util_common import set_image_paths from galaxy.tool_util.deps import ( CachedDependencyManager, ) @@ -102,9 +102,12 @@ from galaxy.util.template import ( fill_template, refactoring_tool, ) +from galaxy.util.tool_shed.common_util import ( + get_tool_shed_repository_url, + get_tool_shed_url_from_tool_shed_registry, +) from galaxy.version import VERSION_MAJOR from galaxy.work.context import WorkRequestContext -from tool_shed.util import common_util from .execute import ( execute as execute_job, MappingParameters, @@ -333,7 +336,7 @@ class ToolBox(BaseGalaxyToolBox): # Abstract toolbox doesn't have a dependency on the database, so # override _get_tool_shed_repository here to provide this information. - return repository_util.get_installed_repository( + return get_installed_repository( self.app, tool_shed=tool_shed, name=name, @@ -521,12 +524,12 @@ class Tool(Dictifiable): def tool_shed_repository(self): # If this tool is included in an installed tool shed repository, return it. if self.tool_shed: - return repository_util.get_installed_repository(self.app, - tool_shed=self.tool_shed, - name=self.repository_name, - owner=self.repository_owner, - installed_changeset_revision=self.installed_changeset_revision, - from_cache=True) + return get_installed_repository(self.app, + tool_shed=self.tool_shed, + name=self.repository_name, + owner=self.repository_owner, + installed_changeset_revision=self.installed_changeset_revision, + from_cache=True) @property def produces_collections_with_unknown_structure(self): @@ -1244,7 +1247,7 @@ class Tool(Dictifiable): self.repository_owner = tool_shed_repository.owner self.changeset_revision = tool_shed_repository.changeset_revision self.installed_changeset_revision = tool_shed_repository.installed_changeset_revision - self.sharable_url = common_util.get_tool_shed_repository_url( + self.sharable_url = get_tool_shed_repository_url( self.app, self.tool_shed, self.repository_owner, self.repository_name ) @@ -1281,7 +1284,7 @@ class Tool(Dictifiable): if help_text is not None: try: if help_text.find('.. image:: ') >= 0 and (self.tool_shed_repository or self.repository_id): - help_text = tool_shed.util.shed_util_common.set_image_paths( + help_text = set_image_paths( self.app, help_text, encoded_repository_id=self.repository_id, tool_shed_repository=self.tool_shed_repository, tool_id=self.old_id, tool_version=self.version ) except Exception: @@ -2174,7 +2177,7 @@ class Tool(Dictifiable): message += 'You can re-run the job with this tool version, which is a different version of the original tool. ' else: new_tool_shed_url = '%s/%s/' % (tool.sharable_url, tool.changeset_revision) - old_tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry(self.app, tool_id.split('/repos/')[0]) + old_tool_shed_url = get_tool_shed_url_from_tool_shed_registry(self.app, tool_id.split('/repos/')[0]) old_tool_shed_url = '%s/view/%s/%s/' % (old_tool_shed_url, tool.repository_owner, tool.repository_name) message = 'This job was run with tool id \"%s\", version "%s", which is not available. ' % (old_tool_shed_url, tool_id, tool_version) if len(tools) > 1: diff --git a/lib/galaxy/util/tool_shed/common_util.py b/lib/galaxy/util/tool_shed/common_util.py index 9d29f83c635..24ff6d361cc 100644 --- a/lib/galaxy/util/tool_shed/common_util.py +++ b/lib/galaxy/util/tool_shed/common_util.py @@ -15,7 +15,7 @@ log = logging.getLogger(__name__) REPOSITORY_OWNER = 'devteam' # not valid for installed Galaxy, fix MIGRATE_DIR = os.path.abspath(os.path.join( - os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 'tool_shed', 'galaxy_install', 'migrate')) + os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 'galaxy', 'tool_shed', 'galaxy_install', 'migrate')) TOOL_MIGRATION_SCRIPTS_DIR = os.path.join(MIGRATE_DIR, 'scripts') TOOL_MIGRATION_VERSIONS_DIR = os.path.join(MIGRATE_DIR, 'versions') diff --git a/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py b/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py index 8fe57f1a3e2..159e77194e2 100644 --- a/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py +++ b/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py @@ -8,7 +8,6 @@ from paste.httpexceptions import ( ) from sqlalchemy import and_ -import tool_shed.util.shed_util_common as suc from galaxy import ( exceptions, util @@ -16,12 +15,17 @@ from galaxy import ( from galaxy.tool_shed.galaxy_install.install_manager import InstallRepositoryManager from galaxy.tool_shed.galaxy_install.installed_repository_manager import InstalledRepositoryManager from galaxy.tool_shed.galaxy_install.metadata.installed_repository_metadata_manager import InstalledRepositoryMetadataManager +from galaxy.tool_shed.util.repository_util import ( + check_for_updates, + get_installed_repository, + get_installed_tool_shed_repository, + get_tool_shed_repository_by_id, +) +from galaxy.tool_shed.util.shed_util_common import have_shed_tool_conf_for_install +from galaxy.tool_shed.util.tool_util import generate_message_for_invalid_tools from galaxy.web import expose_api, require_admin, url_for from galaxy.webapps.base.controller import BaseAPIController -from tool_shed.util import ( - repository_util, - tool_util -) + log = logging.getLogger(__name__) @@ -41,7 +45,7 @@ class ToolShedRepositoriesController(BaseAPIController): def __ensure_can_install_repos(self, trans): # Make sure this Galaxy instance is configured with a shed-related tool panel configuration file. - if not suc.have_shed_tool_conf_for_install(self.app): + if not have_shed_tool_conf_for_install(self.app): message = get_message_for_no_shed_tool_config() log.debug(message) return dict(status='error', error=message) @@ -238,7 +242,7 @@ class ToolShedRepositoriesController(BaseAPIController): """ if id: try: - repository = repository_util.get_tool_shed_repository_by_id(self.app, id) + repository = get_tool_shed_repository_by_id(self.app, id) except ValueError: raise HTTPBadRequest(detail="No repository with id '%s' found" % id) else: @@ -247,11 +251,11 @@ class ToolShedRepositoriesController(BaseAPIController): tsr_arguments = {key: kwd[key] for key in tsr_arguments} except KeyError as e: raise HTTPBadRequest(detail="Missing required parameter '%s'" % e.args[0]) - repository = repository_util.get_installed_repository(app=self.app, - tool_shed=tsr_arguments['tool_shed_url'], - name=tsr_arguments['name'], - owner=tsr_arguments['owner'], - changeset_revision=tsr_arguments['changeset_revision']) + repository = get_installed_repository(app=self.app, + tool_shed=tsr_arguments['tool_shed_url'], + name=tsr_arguments['name'], + owner=tsr_arguments['owner'], + changeset_revision=tsr_arguments['changeset_revision']) if not repository: raise HTTPBadRequest(detail="Repository not found") irm = InstalledRepositoryManager(app=self.app) @@ -292,7 +296,7 @@ class ToolShedRepositoriesController(BaseAPIController): :param id: the encoded repository id ''' repository_id = kwd.get('id', None) - message, status = repository_util.check_for_updates(self.app, trans.install_model, repository_id) + message, status = check_for_updates(self.app, trans.install_model, repository_id) return {'status': status, 'message': message} @expose_api @@ -305,7 +309,7 @@ class ToolShedRepositoriesController(BaseAPIController): successful = [] for repository_id in repository_ids: try: - repository = repository_util.get_installed_tool_shed_repository(self.app, repository_id) + repository = get_installed_tool_shed_repository(self.app, repository_id) irmm.set_repository(repository) irmm.reset_all_metadata_on_installed_repository() if irmm.invalid_file_tups: @@ -350,11 +354,11 @@ class ToolShedRepositoriesController(BaseAPIController): irmm.reset_all_metadata_on_installed_repository() irmm_invalid_file_tups = irmm.get_invalid_file_tups() if irmm_invalid_file_tups: - message = tool_util.generate_message_for_invalid_tools(self.app, - irmm_invalid_file_tups, - repository, - None, - as_html=False) + message = generate_message_for_invalid_tools(self.app, + irmm_invalid_file_tups, + repository, + None, + as_html=False) results['unsuccessful_count'] += 1 else: message = "Successfully reset metadata on repository %s owned by %s" % \ @@ -378,7 +382,7 @@ class ToolShedRepositoriesController(BaseAPIController): :param id: the encoded id of the ToolShedRepository object """ # Example URL: http://localhost:8763/api/tool_shed_repositories/df7a1f0c02a5b08e - tool_shed_repository = repository_util.get_tool_shed_repository_by_id(self.app, id) + tool_shed_repository = get_tool_shed_repository_by_id(self.app, id) if tool_shed_repository is None: log.debug("Unable to locate tool_shed_repository record for id %s." % (str(id))) return {} diff --git a/lib/galaxy/webapps/galaxy/controllers/admin.py b/lib/galaxy/webapps/galaxy/controllers/admin.py index 8dd5ad54242..acf0e86403b 100644 --- a/lib/galaxy/webapps/galaxy/controllers/admin.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin.py @@ -16,21 +16,18 @@ from galaxy import ( from galaxy.actions.admin import AdminActions from galaxy.exceptions import ActionInputError, MessageException from galaxy.model import tool_shed_install as install_model +from galaxy.tool_shed.util.repository_util import get_ids_of_tool_shed_repositories_being_installed from galaxy.util import ( nice_size, sanitize_text, url_get ) +from galaxy.util.tool_shed import common_util, encoding_util from galaxy.web import url_for from galaxy.web.framework.helpers import grids, time_ago from galaxy.web.params import QuotaParamParser from galaxy.webapps.base import controller from galaxy.webapps.base.controller import UsesQuotaMixin -from tool_shed.util import ( - common_util, - encoding_util, - repository_util -) from tool_shed.util.web_util import escape @@ -550,7 +547,7 @@ class AdminGalaxy(controller.JSAppLauncher, AdminActions, UsesQuotaMixin, QuotaP status = kwd.get('status', 'done') settings = { 'is_repo_installed': trans.install_model.context.query(trans.install_model.ToolShedRepository).first() is not None, - 'installing_repository_ids': repository_util.get_ids_of_tool_shed_repositories_being_installed(trans.app, as_string=True), + 'installing_repository_ids': get_ids_of_tool_shed_repositories_being_installed(trans.app, as_string=True), 'is_tool_shed_installed': bool(trans.app.tool_shed_registry and trans.app.tool_shed_registry.tool_sheds) } return self._bootstrapped_client(trans, app_name='admin', settings=settings, message=message, status=status) @@ -886,7 +883,7 @@ class AdminGalaxy(controller.JSAppLauncher, AdminActions, UsesQuotaMixin, QuotaP status = util.restore_text(kwd.get('status', 'done')) migration_stages_dict = OrderedDict() # FIXME: this isn't valid in an installed context - migration_scripts_dir = os.path.abspath(os.path.join(trans.app.config.root, 'lib', 'tool_shed', 'galaxy_install', 'migrate', 'versions')) + migration_scripts_dir = os.path.abspath(os.path.join(trans.app.config.root, 'lib', 'galaxy', 'tool_shed', 'galaxy_install', 'migrate', 'versions')) modules = os.listdir(migration_scripts_dir) modules.sort() modules.reverse() @@ -912,7 +909,7 @@ class AdminGalaxy(controller.JSAppLauncher, AdminActions, UsesQuotaMixin, QuotaP message = escape(kwd.get('message', '')) status = kwd.get('status', 'done') is_repo_installed = trans.install_model.context.query(trans.install_model.ToolShedRepository).first() is not None - installing_repository_ids = repository_util.get_ids_of_tool_shed_repositories_being_installed(trans.app, as_string=True) + installing_repository_ids = get_ids_of_tool_shed_repositories_being_installed(trans.app, as_string=True) return trans.fill_template('/webapps/galaxy/admin/center.mako', is_repo_installed=is_repo_installed, installing_repository_ids=installing_repository_ids, diff --git a/lib/galaxy/workflow/modules.py b/lib/galaxy/workflow/modules.py index e3a9ae48564..fcd5298bafd 100644 --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -53,7 +53,7 @@ from galaxy.util.bunch import Bunch from galaxy.util.json import safe_loads from galaxy.util.rules_dsl import RuleSet from galaxy.util.template import fill_template -from tool_shed.util import common_util +from galaxy.util.tool_shed.common_util import get_tool_shed_url_from_tool_shed_registry log = logging.getLogger(__name__) @@ -848,7 +848,7 @@ class ToolModule(WorkflowModule): if step.tool_id and step.tool_id != module.tool_id: # This means the exact version of the tool is not installed. We inform the user. old_tool_shed = step.tool_id.split("/repos/")[0] if old_tool_shed not in tool_id: # Only display the following warning if the tool comes from a different tool shed - old_tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry(trans.app, old_tool_shed) + old_tool_shed_url = get_tool_shed_url_from_tool_shed_registry(trans.app, old_tool_shed) if not old_tool_shed_url: # a tool from a different tool_shed has been found, but the original tool shed has been deactivated old_tool_shed_url = "http://" + old_tool_shed # let's just assume it's either http, or a http is forwarded to https. old_url = old_tool_shed_url + "/view/%s/%s/" % (module.tool.repository_owner, module.tool.repository_name) diff --git a/test/unit/shed_unit/test_fabric_util.py b/test/unit/shed_unit/test_fabric_util.py index bb18a2b7bf5..2785ca388ad 100644 --- a/test/unit/shed_unit/test_fabric_util.py +++ b/test/unit/shed_unit/test_fabric_util.py @@ -1,6 +1,6 @@ from contextlib import contextmanager -from tool_shed.galaxy_install.tool_dependencies.recipe.env_file_builder import EnvFileBuilder +from galaxy.tool_shed.galaxy_install.tool_dependencies.recipe.env_file_builder import EnvFileBuilder def test_env_file_builder(): diff --git a/test/unit/shed_unit/test_installed_repository_manager.py b/test/unit/shed_unit/test_installed_repository_manager.py index 78c901aa42b..91cfcbec2f5 100644 --- a/test/unit/shed_unit/test_installed_repository_manager.py +++ b/test/unit/shed_unit/test_installed_repository_manager.py @@ -2,14 +2,14 @@ import os from mock import MagicMock -from tool_shed.galaxy_install.install_manager import InstallRepositoryManager -from tool_shed.galaxy_install.installed_repository_manager import InstalledRepositoryManager -from tool_shed.galaxy_install.update_repository_manager import UpdateRepositoryManager -from tool_shed.util import ( - common_util, +from galaxy.tool_shed.galaxy_install.install_manager import InstallRepositoryManager +from galaxy.tool_shed.galaxy_install.installed_repository_manager import InstalledRepositoryManager +from galaxy.tool_shed.galaxy_install.update_repository_manager import UpdateRepositoryManager +from galaxy.tool_shed.util import ( hg_util, repository_util, ) +from galaxy.util.tool_shed import common_util from ..tools.test_toolbox import ( BaseToolBoxTestCase, DEFAULT_TEST_REPO diff --git a/test/unit/shed_unit/test_td_common_util.py b/test/unit/shed_unit/test_td_common_util.py index d9cc771529a..e57c8eb6cd5 100644 --- a/test/unit/shed_unit/test_td_common_util.py +++ b/test/unit/shed_unit/test_td_common_util.py @@ -1,9 +1,9 @@ from contextlib import contextmanager from os.path import join +from galaxy.tool_shed.galaxy_install.tool_dependencies.env_manager import EnvManager +from galaxy.tool_shed.galaxy_install.tool_dependencies.recipe.env_file_builder import EnvFileBuilder from galaxy.util import parse_xml_string -from tool_shed.galaxy_install.tool_dependencies.env_manager import EnvManager -from tool_shed.galaxy_install.tool_dependencies.recipe.env_file_builder import EnvFileBuilder TEST_DEPENDENCIES_DIR = "/opt/galaxy/dependencies" TEST_INSTALL_DIR = "%s/test_install_dir" % TEST_DEPENDENCIES_DIR diff --git a/test/unit/shed_unit/test_tool_panel_manager.py b/test/unit/shed_unit/test_tool_panel_manager.py index e8fd74ecfb5..7c36a26f512 100644 --- a/test/unit/shed_unit/test_tool_panel_manager.py +++ b/test/unit/shed_unit/test_tool_panel_manager.py @@ -1,7 +1,7 @@ import os +from galaxy.tool_shed.galaxy_install.tools import tool_panel_manager from galaxy.util import parse_xml -from tool_shed.galaxy_install.tools import tool_panel_manager from tool_shed.tools import tool_version_manager from ..tools.test_toolbox import ( BaseToolBoxTestCase,