From dc5ef792329868d2acc4acddb188a77df856dcbb Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Wed, 5 Oct 2022 14:21:54 +0100 Subject: [PATCH] Fix type annotation of ``type_to_object_store_class`` function --- lib/galaxy/app.py | 1 + lib/galaxy/objectstore/__init__.py | 5 +++-- lib/galaxy/structured_app.py | 7 +++++-- test/unit/app/jobs/test_job_wrapper.py | 4 ++-- test/unit/app/tools/test_actions.py | 4 ++-- test/unit/app/tools/test_collect_primary_datasets.py | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index a3363a66304..da829e80739 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -216,6 +216,7 @@ class MinimalGalaxyApplication(BasicSharedApp, HaltableContainer, SentryClientMi toolbox_search: ToolBoxSearch container_finder: containers.ContainerFinder install_model: ModelMapping + object_store: BaseObjectStore def __init__(self, fsmon=False, **kwargs) -> None: super().__init__() diff --git a/lib/galaxy/objectstore/__init__.py b/lib/galaxy/objectstore/__init__.py index f85576af050..224b2d6cec7 100644 --- a/lib/galaxy/objectstore/__init__.py +++ b/lib/galaxy/objectstore/__init__.py @@ -16,6 +16,7 @@ from typing import ( Any, Dict, List, + Tuple, Type, ) @@ -1089,8 +1090,8 @@ class HierarchicalObjectStore(NestedObjectStore): self.backends[0].create(obj, **kwargs) -def type_to_object_store_class(store, fsmon=False): - objectstore_class: Type[ObjectStore] +def type_to_object_store_class(store: str, fsmon: bool = False) -> Tuple[Type[BaseObjectStore], Dict[str, Any]]: + objectstore_class: Type[BaseObjectStore] objectstore_constructor_kwds = {} if store == "disk": objectstore_class = DiskObjectStore diff --git a/lib/galaxy/structured_app.py b/lib/galaxy/structured_app.py index db3644f62cf..d14f3db63a2 100644 --- a/lib/galaxy/structured_app.py +++ b/lib/galaxy/structured_app.py @@ -23,7 +23,10 @@ from galaxy.model.security import ( HostAgent, ) from galaxy.model.tags import GalaxyTagHandler -from galaxy.objectstore import ObjectStore +from galaxy.objectstore import ( + BaseObjectStore, + ObjectStore, +) from galaxy.quota import QuotaAgent from galaxy.security.idencoding import IdEncodingHelper from galaxy.security.vault import Vault @@ -85,7 +88,6 @@ class MinimalApp(BasicSharedApp): install_model: ModelMapping security_agent: GalaxyRBACAgent host_security_agent: HostAgent - object_store: ObjectStore class MinimalManagerApp(MinimalApp): @@ -108,6 +110,7 @@ class MinimalManagerApp(MinimalApp): dynamic_tool_manager: Any # 'galaxy.managers.tools.DynamicToolManager' genomes: "Genomes" error_reports: "ErrorReports" + object_store: BaseObjectStore @property def is_job_handler(self) -> bool: diff --git a/test/unit/app/jobs/test_job_wrapper.py b/test/unit/app/jobs/test_job_wrapper.py index 249b0402e01..fff6f51d68c 100644 --- a/test/unit/app/jobs/test_job_wrapper.py +++ b/test/unit/app/jobs/test_job_wrapper.py @@ -18,7 +18,7 @@ from galaxy.model import ( Task, User, ) -from galaxy.objectstore import ObjectStore +from galaxy.objectstore import BaseObjectStore from galaxy.tools import ToolBox from galaxy.util.bunch import Bunch from galaxy.util.unittest import TestCase @@ -52,7 +52,7 @@ class AbstractTestCases: self.app.toolbox = cast(ToolBox, MockToolbox(MockTool(self))) self.working_directory = os.path.join(self.test_directory, "working") - self.app.object_store = cast(ObjectStore, MockObjectStore(self.working_directory)) + self.app.object_store = cast(BaseObjectStore, MockObjectStore(self.working_directory)) self.queue = MockJobQueue(self.app) self.job = job diff --git a/test/unit/app/tools/test_actions.py b/test/unit/app/tools/test_actions.py index 9b3643c0325..8b4b8898eeb 100644 --- a/test/unit/app/tools/test_actions.py +++ b/test/unit/app/tools/test_actions.py @@ -4,7 +4,7 @@ from typing import cast from galaxy import model from galaxy.app_unittest_utils import tools_support from galaxy.exceptions import UserActivationRequiredException -from galaxy.objectstore import ObjectStore +from galaxy.objectstore import BaseObjectStore from galaxy.tool_util.parser.output_objects import ToolOutput from galaxy.tools.actions import ( DefaultToolAction, @@ -68,7 +68,7 @@ class TestDefaultToolAction(TestCase, tools_support.UsesTools): self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" - self.app.object_store = cast(ObjectStore, MockObjectStore()) + self.app.object_store = cast(BaseObjectStore, MockObjectStore()) def test_output_created(self): _, output = self._simple_execute() diff --git a/test/unit/app/tools/test_collect_primary_datasets.py b/test/unit/app/tools/test_collect_primary_datasets.py index 4470ec83a9a..45ce359a461 100644 --- a/test/unit/app/tools/test_collect_primary_datasets.py +++ b/test/unit/app/tools/test_collect_primary_datasets.py @@ -7,7 +7,7 @@ from galaxy import ( util, ) from galaxy.app_unittest_utils import tools_support -from galaxy.objectstore import ObjectStore +from galaxy.objectstore import BaseObjectStore from galaxy.tool_util.parser import output_collection_def from galaxy.tool_util.provided_metadata import ( BaseToolProvidedMetadata, @@ -23,7 +23,7 @@ DEFAULT_EXTRA_NAME = "test1" class TestCollectPrimaryDatasets(TestCase, tools_support.UsesTools): def setUp(self): self.setup_app() - object_store = cast(ObjectStore, MockObjectStore()) + object_store = cast(BaseObjectStore, MockObjectStore()) self.app.object_store = object_store self._init_tool(tools_support.SIMPLE_TOOL_CONTENTS) self._setup_test_output()