From fc440609d7e8b9e06bc137e68b40ea711a9bf508 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 12 Dec 2023 13:11:52 +0100 Subject: [PATCH] Fix TypeOnlyAvailableAsAwaitable exception --- lib/galaxy/app.py | 9 +++------ lib/galaxy/managers/datatypes.py | 8 ++++---- lib/galaxy/tool_util/edam_util.py | 9 ++++++--- lib/galaxy/webapps/galaxy/api/datatypes.py | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index ed427ee1cf49..e630d5faf9aa 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -122,7 +122,7 @@ from galaxy.tool_util.deps.dependencies import AppInfo from galaxy.tool_util.deps.views import DependencyResolversView from galaxy.tool_util.edam_util import ( - EdamDictType, + EdamDict, load_edam_tree, ) from galaxy.tool_util.verify.test_data import TestDataResolver @@ -696,7 +696,7 @@ def __init__(self, **kwargs) -> None: # Load edam data edam_ontology_path = self.config.edam_toolbox_ontology_path self.edam = self._register_singleton( - EdamDictType, + EdamDict, load_edam_tree( None if not edam_ontology_path or not os.path.exists(edam_ontology_path) else edam_ontology_path, "format_", @@ -706,10 +706,7 @@ def __init__(self, **kwargs) -> None: ), ) else: - self.edam = self._register_singleton( - EdamDictType, - {}, - ) + self.edam = self._register_singleton(EdamDict, EdamDict()) self._configure_toolbox() # Load Data Manager self.data_managers = self._register_singleton(DataManagers) # type: ignore[type-abstract] diff --git a/lib/galaxy/managers/datatypes.py b/lib/galaxy/managers/datatypes.py index c1727afc00a6..f7e5c9e11cd1 100644 --- a/lib/galaxy/managers/datatypes.py +++ b/lib/galaxy/managers/datatypes.py @@ -16,7 +16,7 @@ ) from galaxy.datatypes.data import Data from galaxy.datatypes.registry import Registry -from galaxy.tool_util.edam_util import EdamDictType +from galaxy.tool_util.edam_util import EdamDict def view_index( @@ -91,7 +91,7 @@ def view_converters(datatypes_registry: Registry) -> DatatypeConverterList: return parse_obj_as(DatatypeConverterList, converters) -def _get_edam_details(edam: EdamDictType, edam_ids: Dict[str, str]) -> Dict[str, Dict]: +def _get_edam_details(edam: EdamDict, edam_ids: Dict[str, str]) -> Dict[str, Dict]: details_dict = {} for format, edam_iri in edam_ids.items(): edam_details = edam.get(edam_iri, {}) @@ -106,7 +106,7 @@ def _get_edam_details(edam: EdamDictType, edam_ids: Dict[str, str]) -> Dict[str, def view_edam_formats( - edam: EdamDictType, datatypes_registry: Registry, detailed: Optional[bool] = False + edam: EdamDict, datatypes_registry: Registry, detailed: Optional[bool] = False ) -> Union[Dict[str, str], Dict[str, Dict[str, str]]]: if detailed: return _get_edam_details(edam, datatypes_registry.edam_formats) @@ -115,7 +115,7 @@ def view_edam_formats( def view_edam_data( - edam: EdamDictType, datatypes_registry: Registry, detailed: Optional[bool] = False + edam: EdamDict, datatypes_registry: Registry, detailed: Optional[bool] = False ) -> Union[Dict[str, str], Dict[str, Dict[str, str]]]: if detailed: return _get_edam_details(edam, datatypes_registry.edam_data) diff --git a/lib/galaxy/tool_util/edam_util.py b/lib/galaxy/tool_util/edam_util.py index 89279c8b210c..7c18d326b97c 100644 --- a/lib/galaxy/tool_util/edam_util.py +++ b/lib/galaxy/tool_util/edam_util.py @@ -15,10 +15,13 @@ ROOT_OPERATION = "operation_0004" ROOT_TOPIC = "topic_0003" -EdamDictType = Dict[str, Dict[str, str]] +class EdamDict(dict): + # Exists only for lagom + python3.8 + pass -def load_edam_tree(path: Optional[str] = None, *included_terms: str) -> EdamDictType: + +def load_edam_tree(path: Optional[str] = None, *included_terms: str) -> EdamDict: if path is not None: assert os.path.exists(path), f"Failed to load EDAM tabular data at [{path}] path does not exist." handle = open(path) @@ -27,7 +30,7 @@ def load_edam_tree(path: Optional[str] = None, *included_terms: str) -> EdamDict tabular_stream is not None ), "Failed to load optional import from edam-ontology package, install using [pip install edam-ontology]." handle = tabular_stream() - return load_edam_tree_from_tsv_stream(handle, *included_terms) + return EdamDict(**load_edam_tree_from_tsv_stream(handle, *included_terms)) def load_edam_tree_from_tsv_stream(tsv_stream: TextIO, *included_terms: str): diff --git a/lib/galaxy/webapps/galaxy/api/datatypes.py b/lib/galaxy/webapps/galaxy/api/datatypes.py index 43853e149fdd..b10daade645a 100644 --- a/lib/galaxy/webapps/galaxy/api/datatypes.py +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -26,7 +26,7 @@ view_mapping, view_sniffers, ) -from galaxy.tool_util.edam_util import EdamDictType +from galaxy.tool_util.edam_util import EdamDict from . import ( depends, Router, @@ -58,7 +58,7 @@ @router.cbv class FastAPIDatatypes: datatypes_registry: Registry = depends(Registry) - edam: EdamDictType = depends(EdamDictType) + edam: EdamDict = depends(EdamDict) @router.get( "/api/datatypes",