Skip to content

Commit

Permalink
Fix TypeOnlyAvailableAsAwaitable exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Dec 12, 2023
1 parent 4a7b187 commit fc44060
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
9 changes: 3 additions & 6 deletions lib/galaxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_",
Expand All @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions lib/galaxy/managers/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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, {})
Expand All @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions lib/galaxy/tool_util/edam_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/api/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit fc44060

Please sign in to comment.