mypy typing for galaxy-web-stack.

This commit is contained in:
John Chilton
2020-12-28 23:41:44 -05:00
parent be3f17a3ac
commit d3b2f71bbd
5 changed files with 19 additions and 16 deletions
+5 -4
View File
@@ -5,6 +5,7 @@ import inspect
import json
import logging
import os
from typing import Callable, Dict, FrozenSet, List, Optional, Tuple, Type
from urllib.request import install_opener
# The uwsgi module is automatically injected by the parent uwsgi process and only exists that way. If anything works,
@@ -43,10 +44,10 @@ class UWSGILogFilter(logging.Filter):
class ApplicationStack:
name = None
prohibited_middleware = frozenset()
name: Optional[str] = None
prohibited_middleware: FrozenSet[str] = frozenset()
transport_class = ApplicationStackTransport
log_filter_class = ApplicationStackLogFilter
log_filter_class: Type[logging.Filter] = ApplicationStackLogFilter
log_format = '%(name)s %(levelname)s %(asctime)s %(message)s'
# TODO: this belongs in the pool configuration
server_name_template = '{server_name}'
@@ -235,7 +236,7 @@ class UWSGIApplicationStack(MessageApplicationStack):
log_format = '%(name)s %(levelname)s %(asctime)s [p:%(process)s,w:%(worker_id)s,m:%(mule_id)s] [%(threadName)s] %(message)s'
server_name_template = '{server_name}.{pool_name}.{instance_id}'
postfork_functions = []
postfork_functions: List[Tuple[Callable, List, Dict]] = []
localhost_addrs = ('127.0.0.1', '[::1]')
bind_all_addrs = ('', '0.0.0.0', '[::]')
+10 -9
View File
@@ -4,6 +4,7 @@
import json
import logging
import types
from typing import Optional, Tuple
log = logging.getLogger(__name__)
@@ -46,7 +47,7 @@ class ApplicationStackMessageDispatcher:
class ApplicationStackMessage(dict):
target = None
_target: Optional[str] = None
default_handler = None
_validate_kwargs = ('target',)
@@ -96,17 +97,17 @@ class ApplicationStackMessage(dict):
@property
def target(self):
return self['target']
return self['_target']
@target.setter
def set_target(self, target):
self['target'] = target
def target(self, target):
self['_target'] = target
class ParamMessage(ApplicationStackMessage):
_validate_kwargs = ('params',)
_validate_params = ()
_exclude_params = ()
_validate_params: Tuple[str, ...] = ()
_exclude_params: Tuple[str, ...] = ()
def __init__(self, target=None, params=None, **kwargs):
super().__init__(target=target)
@@ -126,7 +127,7 @@ class ParamMessage(ApplicationStackMessage):
return d
@params.setter
def set_params(self, params):
def params(self, params):
self['params'] = params
@@ -151,12 +152,12 @@ class TaskMessage(ParamMessage):
class JobHandlerMessage(TaskMessage):
target = 'job_handler'
_target = 'job_handler'
_validate_params = ('job_id',)
class WorkflowSchedulingMessage(TaskMessage):
target = 'workflow_scheduling'
_target = 'workflow_scheduling'
_validate_params = ('workflow_invocation_id',)
+2 -1
View File
@@ -3,6 +3,7 @@
import logging
import threading
from typing import List
from galaxy.util import unicodify
@@ -70,7 +71,7 @@ class UWSGIFarmMessageTransport(ApplicationStackTransport):
""" Communication via uWSGI Mule Farm messages. Communication is unidirectional (workers -> mules).
"""
# Define any static lock names here, additional locks will be appended for each configured farm's message handler
_locks = []
_locks: List[str] = []
def init_late_prefork(self):
num = int(uwsgi.opt.get('locks', 0)) + 1
+1 -1
View File
@@ -34,7 +34,7 @@ PACKAGE_DIRS=(
# tool_util not yet working 100%,
# data has many problems quota, tool shed install database, etc..
RUN_TESTS=(1 1 1 1 1 1 1 1 1 1 0 0)
RUN_MYPY=(1 1 1 1 1 1 1 1 0 0 0 0)
RUN_MYPY=(1 1 1 1 1 1 1 1 1 0 0 0)
for ((i=0; i<${#PACKAGE_DIRS[@]}; i++)); do
package_dir=${PACKAGE_DIRS[$i]}
run_tests=${RUN_TESTS[$i]}
+1 -1
View File
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore