mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-01 15:37:32 +08:00
Decompose tool shed + schema package.
This commit creates two new packages - below a description of these packages and why they are being created. galaxy-schema: This package contains the pydantic models that power the API. The purpose of packaging them is to ensure they can be reused by clients with minimal external dependencies. Reusing the schema in client code would very quickly provide rapid documentation and validation and static checking for Python clients using the Galaxy API. galaxy-tool-shed: This package contains the tool shed server code. This has been a long term project to allow the tool shed to be spun out but maintain real galaxy dependencies and maintain testing. More discussions around this project can be found as part of https://github.com/galaxyproject/galaxy/pull/8830.
This commit is contained in:
@@ -3,7 +3,11 @@ import re
|
||||
from pydantic import Field
|
||||
from typing_extensions import get_args
|
||||
|
||||
from galaxy.security.idencoding import IdEncodingHelper
|
||||
try:
|
||||
from galaxy.security.idencoding import IdEncodingHelper
|
||||
except ImportError:
|
||||
IdEncodingHelper = object # type: ignore[assignment,misc]
|
||||
|
||||
|
||||
ENCODED_DATABASE_ID_PATTERN = re.compile("f?[0-9a-f]+")
|
||||
ENCODED_ID_LENGTH_MULTIPLE = 16
|
||||
|
||||
@@ -21,10 +21,7 @@ from sqlalchemy import (
|
||||
)
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from galaxy import (
|
||||
util,
|
||||
web,
|
||||
)
|
||||
from galaxy import util
|
||||
from galaxy.model.base import transaction
|
||||
from galaxy.model.scoped_session import install_model_scoped_session
|
||||
from galaxy.model.tool_shed_install import ToolShedRepository
|
||||
@@ -726,7 +723,6 @@ def repository_was_previously_installed(app, tool_shed_url, repository_name, rep
|
||||
# Get all previous changeset revisions from the tool shed for the repository back to, but excluding,
|
||||
# the previous valid changeset revision to see if it was previously installed using one of them.
|
||||
params = dict(
|
||||
galaxy_url=web.url_for("/", qualified=True),
|
||||
name=repository_name,
|
||||
owner=repository_owner,
|
||||
changeset_revision=changeset_revision,
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../lib/galaxy/schema
|
||||
@@ -36,6 +36,7 @@ install_requires =
|
||||
galaxy-objectstore
|
||||
galaxy-util[template]
|
||||
alembic
|
||||
alembic-utils
|
||||
bdbag
|
||||
bx-python
|
||||
dnspython
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
util
|
||||
schema
|
||||
config
|
||||
files
|
||||
job_metrics
|
||||
@@ -17,3 +18,4 @@ web_apps
|
||||
test_base
|
||||
test_driver
|
||||
test_api
|
||||
tool_shed
|
||||
@@ -0,0 +1,10 @@
|
||||
History
|
||||
-------
|
||||
|
||||
.. to_doc
|
||||
|
||||
---------------------
|
||||
21.1.0.dev0
|
||||
---------------------
|
||||
|
||||
* First release.
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../LICENSE.txt
|
||||
@@ -0,0 +1 @@
|
||||
include *.rst *.txt LICENSE */py.typed
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../package.Makefile
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
.. image:: https://badge.fury.io/py/galaxy-schema.svg
|
||||
:target: https://pypi.org/project/galaxy-schema/
|
||||
|
||||
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
The Galaxy_ API schema objects.
|
||||
|
||||
* Code: https://github.com/galaxyproject/galaxy
|
||||
|
||||
.. _Galaxy: http://galaxyproject.org/
|
||||
+1
@@ -0,0 +1 @@
|
||||
../package-dev-requirements.txt
|
||||
@@ -0,0 +1 @@
|
||||
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../lib/galaxy/schema/
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../mypy.ini
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../package-pyproject.toml
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../build_scripts
|
||||
@@ -0,0 +1,41 @@
|
||||
[metadata]
|
||||
author = Galaxy Project and Community
|
||||
author_email = galaxy-committers@lists.galaxyproject.org
|
||||
classifiers =
|
||||
Development Status :: 5 - Production/Stable
|
||||
Environment :: Console
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: Academic Free License (AFL)
|
||||
Natural Language :: English
|
||||
Operating System :: POSIX
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Programming Language :: Python :: 3.10
|
||||
Topic :: Software Development
|
||||
Topic :: Software Development :: Code Generators
|
||||
Topic :: Software Development :: Testing
|
||||
description = Galaxy auth framework and implementations
|
||||
keywords =
|
||||
Galaxy
|
||||
license = AFL
|
||||
license_files =
|
||||
LICENSE
|
||||
long_description = file: README.rst, HISTORY.rst
|
||||
long_description_content_type = text/x-rst
|
||||
name = galaxy-schema
|
||||
url = https://github.com/galaxyproject/galaxy
|
||||
version = 23.1.0.dev0
|
||||
|
||||
[options]
|
||||
include_package_data = True
|
||||
install_requires =
|
||||
galaxy-util
|
||||
pydantic[email]
|
||||
packages = find:
|
||||
python_requires = >=3.7
|
||||
|
||||
[options.packages.find]
|
||||
exclude =
|
||||
tests*
|
||||
@@ -0,0 +1 @@
|
||||
pytest
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../test/unit/schema/
|
||||
@@ -0,0 +1,10 @@
|
||||
History
|
||||
-------
|
||||
|
||||
.. to_doc
|
||||
|
||||
---------------------
|
||||
23.1.0.dev0
|
||||
---------------------
|
||||
|
||||
* First release.
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../LICENSE.txt
|
||||
@@ -0,0 +1 @@
|
||||
include *.rst *.txt LICENSE */py.typed
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../package.Makefile
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
.. image:: https://badge.fury.io/py/galaxy-tool-shed.svg
|
||||
:target: https://pypi.org/project/galaxy-tool-shed/
|
||||
|
||||
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
The Galaxy_ tool shed server.
|
||||
|
||||
* Code: https://github.com/galaxyproject/galaxy
|
||||
|
||||
.. _Galaxy: http://galaxyproject.org/
|
||||
+1
@@ -0,0 +1 @@
|
||||
../package-dev-requirements.txt
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../mypy.ini
|
||||
+1
@@ -0,0 +1 @@
|
||||
../package-pyproject.toml
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../build_scripts
|
||||
@@ -0,0 +1,40 @@
|
||||
[metadata]
|
||||
author = Galaxy Project and Community
|
||||
author_email = galaxy-committers@lists.galaxyproject.org
|
||||
classifiers =
|
||||
Development Status :: 5 - Production/Stable
|
||||
Environment :: Console
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: Academic Free License (AFL)
|
||||
Natural Language :: English
|
||||
Operating System :: POSIX
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Programming Language :: Python :: 3.10
|
||||
Topic :: Software Development
|
||||
Topic :: Software Development :: Code Generators
|
||||
Topic :: Software Development :: Testing
|
||||
description = Galaxy auth framework and implementations
|
||||
keywords =
|
||||
Galaxy
|
||||
license = AFL
|
||||
license_files =
|
||||
LICENSE
|
||||
long_description = file: README.rst, HISTORY.rst
|
||||
long_description_content_type = text/x-rst
|
||||
name = galaxy-tool-shed
|
||||
url = https://github.com/galaxyproject/galaxy
|
||||
version = 23.1.0.dev0
|
||||
|
||||
[options]
|
||||
include_package_data = True
|
||||
install_requires =
|
||||
galaxy-webapps
|
||||
packages = find:
|
||||
python_requires = >=3.7
|
||||
|
||||
[options.packages.find]
|
||||
exclude =
|
||||
tests*
|
||||
@@ -0,0 +1 @@
|
||||
pytest
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../test/unit/tool_shed
|
||||
@@ -1,141 +0,0 @@
|
||||
import os
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
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 ..app.tools.test_toolbox import (
|
||||
BaseToolBoxTestCase,
|
||||
DEFAULT_TEST_REPO,
|
||||
)
|
||||
|
||||
|
||||
class ToolShedRepoBaseTestCase(BaseToolBoxTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self._init_dynamic_tool_conf()
|
||||
self.app.config.tool_configs = self.config_files
|
||||
self.app.config.manage_dependency_relationships = False
|
||||
self.app._toolbox = self.toolbox
|
||||
|
||||
def _setup_repository(self):
|
||||
return self._repo_install(changeset="1", config_filename=self.config_files[0])
|
||||
|
||||
|
||||
class TestInstallRepositoryManager(ToolShedRepoBaseTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.irm = InstallRepositoryManager(self.app)
|
||||
self.app.config.enable_tool_shed_check = False
|
||||
self.app.update_repository_manager = UpdateRepositoryManager(self.app)
|
||||
|
||||
def test_tool_shed_repository_install(self):
|
||||
hg_util.clone_repository = MagicMock(return_value=(True, None))
|
||||
repository_util.get_tool_shed_status_for = MagicMock(return_value={"revision_update": "true"})
|
||||
self._install_tool_shed_repository(start_status="New", end_status="Installed", changeset_revision="1")
|
||||
hg_util.clone_repository.assert_called_with(
|
||||
"github.com/repos/galaxyproject/example",
|
||||
os.path.abspath(os.path.join("../shed_tools", "github.com/repos/galaxyproject/example/1/example")),
|
||||
"1",
|
||||
)
|
||||
|
||||
def test_tool_shed_repository_update(self):
|
||||
common_util.get_tool_shed_url_from_tool_shed_registry = MagicMock(return_value="https://github.com")
|
||||
repository_util.get_tool_shed_status_for = MagicMock(return_value={"revision_update": "false"})
|
||||
hg_util.pull_repository = MagicMock()
|
||||
hg_util.update_repository = MagicMock(return_value=(True, None))
|
||||
self._install_tool_shed_repository(start_status="Installed", end_status="Installed", changeset_revision="2")
|
||||
assert hg_util.pull_repository.call_args[0][0].endswith("github.com/repos/galaxyproject/example/1/example")
|
||||
assert hg_util.pull_repository.call_args[0][1] == "https://github.com/repos/galaxyproject/example"
|
||||
assert hg_util.pull_repository.call_args[0][2] == "2"
|
||||
assert hg_util.update_repository.call_args[0][0].endswith("github.com/repos/galaxyproject/example/1/example")
|
||||
assert hg_util.update_repository.call_args[0][1] == "2"
|
||||
|
||||
def _install_tool_shed_repository(self, start_status, end_status, changeset_revision):
|
||||
repository = self._setup_repository()
|
||||
repository.status = start_status
|
||||
repo_info_dict: Dict[str, Any] = {
|
||||
"example": (
|
||||
"description",
|
||||
"github.com/repos/galaxyproject/example",
|
||||
changeset_revision,
|
||||
changeset_revision,
|
||||
"galaxyproject",
|
||||
[],
|
||||
[],
|
||||
)
|
||||
}
|
||||
self.irm.install_tool_shed_repository(
|
||||
repository,
|
||||
repo_info_dict,
|
||||
"section_key",
|
||||
self.app.config.tool_configs[0],
|
||||
"../shed_tools",
|
||||
False,
|
||||
False,
|
||||
reinstalling=False,
|
||||
)
|
||||
assert repository.status == end_status
|
||||
assert repository.changeset_revision == changeset_revision
|
||||
|
||||
|
||||
class TestInstalledRepositoryManager(ToolShedRepoBaseTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.irm = InstalledRepositoryManager(self.app)
|
||||
|
||||
def test_uninstall_repository(self):
|
||||
repository = self._setup_repository()
|
||||
assert repository.uninstalled is False
|
||||
self.irm.uninstall_repository(repository=repository, remove_from_disk=True)
|
||||
assert repository.uninstalled is True
|
||||
|
||||
def test_deactivate_repository(self):
|
||||
self._deactivate_repository()
|
||||
|
||||
def test_activate_repository(self):
|
||||
repository = self._deactivate_repository()
|
||||
self.irm.activate_repository(repository)
|
||||
assert repository.status == self.app.install_model.ToolShedRepository.installation_status.INSTALLED
|
||||
|
||||
def test_create_or_update_tool_shed_repository_update(self):
|
||||
repository = self._setup_repository()
|
||||
self._create_or_update_tool_shed_repository(repository=repository, changeset_revision="2")
|
||||
|
||||
def test_create_or_update_tool_shed_repository_create(self):
|
||||
self._create_or_update_tool_shed_repository(repository=None, changeset_revision="2")
|
||||
|
||||
def _create_or_update_tool_shed_repository(self, repository=None, changeset_revision="2"):
|
||||
if repository is None:
|
||||
repository = DEFAULT_TEST_REPO
|
||||
new_repository = repository_util.create_or_update_tool_shed_repository(
|
||||
app=self.app,
|
||||
name=repository.name,
|
||||
description=repository.description,
|
||||
installed_changeset_revision=repository.installed_changeset_revision,
|
||||
ctx_rev=repository.changeset_revision,
|
||||
repository_clone_url=f"https://github.com/galaxyproject/example/test_tool/0.{repository.installed_changeset_revision}", # not needed if owner is given
|
||||
status=repository.status,
|
||||
metadata_dict=None,
|
||||
current_changeset_revision=str(int(repository.changeset_revision) + 1),
|
||||
owner=repository.owner,
|
||||
dist_to_shed=False,
|
||||
)
|
||||
assert new_repository.changeset_revision == changeset_revision
|
||||
|
||||
def _deactivate_repository(self):
|
||||
repository = self._setup_repository()
|
||||
assert repository.uninstalled is False
|
||||
self.irm.uninstall_repository(repository=repository, remove_from_disk=False)
|
||||
assert repository.uninstalled is False
|
||||
assert repository.status == self.app.install_model.ToolShedRepository.installation_status.DEACTIVATED
|
||||
return repository
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
import os
|
||||
|
||||
from galaxy.tool_shed.galaxy_install.tools import tool_panel_manager
|
||||
from galaxy.util import parse_xml
|
||||
from tool_shed.tools import tool_version_manager
|
||||
from ..app.tools.test_toolbox import (
|
||||
from galaxy.app_unittest_utils.toolbox_support import (
|
||||
BaseToolBoxTestCase,
|
||||
SimplifiedToolBox,
|
||||
)
|
||||
from galaxy.tool_shed.galaxy_install.tools import tool_panel_manager
|
||||
from galaxy.util import parse_xml
|
||||
from tool_shed.tools import tool_version_manager
|
||||
|
||||
DEFAULT_GUID = "123456"
|
||||
|
||||
Reference in New Issue
Block a user