mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
More typing around tool validator...
This commit is contained in:
@@ -14,11 +14,13 @@ from galaxy.util.tool_shed import xml_util
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
RequiredAppT = Union[BasicSharedApp, InstallationTarget]
|
||||
|
||||
|
||||
class ShedToolDataTableManager:
|
||||
app: Union[BasicSharedApp, InstallationTarget]
|
||||
app: RequiredAppT
|
||||
|
||||
def __init__(self, app: Union[BasicSharedApp, InstallationTarget]):
|
||||
def __init__(self, app: RequiredAppT):
|
||||
self.app = app
|
||||
|
||||
def generate_repository_info_elem(
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import logging
|
||||
|
||||
from galaxy.tool_shed.tools.data_table_manager import ShedToolDataTableManager
|
||||
from galaxy.tool_shed.tools.data_table_manager import (
|
||||
RequiredAppT,
|
||||
ShedToolDataTableManager,
|
||||
)
|
||||
from galaxy.tool_shed.util import (
|
||||
basic_util,
|
||||
hg_util,
|
||||
@@ -17,7 +20,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ToolValidator:
|
||||
def __init__(self, app):
|
||||
def __init__(self, app: RequiredAppT):
|
||||
self.app = app
|
||||
self.stdtm = ShedToolDataTableManager(self.app)
|
||||
|
||||
|
||||
@@ -3,22 +3,34 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from contextlib import contextmanager
|
||||
from typing import Optional
|
||||
|
||||
from galaxy.managers.dbkeys import GenomeBuilds
|
||||
from galaxy.tools.data import ToolDataTableManager
|
||||
from galaxy.util.bunch import Bunch
|
||||
|
||||
|
||||
class ValidationContextConfig:
|
||||
tool_data_path: Optional[str]
|
||||
shed_tool_data_path: Optional[str]
|
||||
tool_data_table_config: str
|
||||
shed_tool_data_table_config: str
|
||||
interactivetools_enable: bool
|
||||
len_file_path: str
|
||||
builds_file_path: Optional[str]
|
||||
|
||||
|
||||
class ValidationContext:
|
||||
"""Minimal App object for tool validation."""
|
||||
|
||||
is_webapp = True
|
||||
config: ValidationContextConfig
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
app_name,
|
||||
security,
|
||||
app_name: str,
|
||||
model,
|
||||
security,
|
||||
tool_data_path,
|
||||
shed_tool_data_path,
|
||||
tool_data_tables=None,
|
||||
@@ -27,9 +39,9 @@ class ValidationContext:
|
||||
biotools_metadata_source=None,
|
||||
):
|
||||
self.name = app_name
|
||||
self.security = security
|
||||
self.model = model
|
||||
self.config = Bunch()
|
||||
self.security = security
|
||||
self.config = ValidationContextConfig()
|
||||
self.config.tool_data_path = tool_data_path
|
||||
self.config.shed_tool_data_path = shed_tool_data_path
|
||||
self.temporary_path = tempfile.mkdtemp(prefix="tool_validation_")
|
||||
@@ -67,11 +79,11 @@ class ValidationContext:
|
||||
with ValidationContext(
|
||||
app_name=app.name,
|
||||
security=app.security,
|
||||
model=app.model,
|
||||
model=getattr(app, "model", None),
|
||||
tool_data_path=work_dir,
|
||||
shed_tool_data_path=work_dir,
|
||||
tool_data_tables=tool_data_tables,
|
||||
registry=app.datatypes_registry,
|
||||
registry=getattr(app, "datatypes_registry", None),
|
||||
hgweb_config_manager=getattr(app, "hgweb_config_manager", None),
|
||||
biotools_metadata_source=getattr(app, "biotools_metadata_source", None),
|
||||
) as app:
|
||||
|
||||
Reference in New Issue
Block a user