From 0f4c3d3b8e95abac132173198f7ec686cc9aa89f Mon Sep 17 00:00:00 2001 From: Mike Lin Date: Thu, 14 Mar 2024 21:06:23 -1000 Subject: [PATCH] wip --- WDL/CLI.py | 8 +++++--- WDL/runtime/__init__.py | 2 +- WDL/runtime/backend/cli_subprocess.py | 4 ++-- WDL/runtime/workflow.py | 8 ++++---- stubs/logging/__init__.py | 6 ++++++ 5 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 stubs/logging/__init__.py diff --git a/WDL/CLI.py b/WDL/CLI.py index 7233ae85..5da8d864 100644 --- a/WDL/CLI.py +++ b/WDL/CLI.py @@ -145,7 +145,7 @@ def __call__(self, parser, namespace, values, option_string=None): # importlib_metadata doesn't seem to provide EntryPoint.dist to get from an entry point to # the metadata of the package providing it; continuing to use pkg_resources for this. Risk # that they give inconsistent results? - import pkg_resources + import pkg_resources # type: ignore for group in runtime.config.default_plugins().keys(): group = f"miniwdl.plugin.{group}" @@ -1116,7 +1116,8 @@ def runner_input_json_file(available_inputs, namespace, input_file, downloadable if input_file: input_file = input_file.strip() if input_file: - import yaml # delayed heavy import + # delayed heavy import: + import yaml # type: ignore input_json = None if input_file[0] == "{": @@ -1745,7 +1746,7 @@ def configure(cfg=None, show=False, force=False, **kwargs): die("`miniwdl configure` is for interactive use") from datetime import datetime - import bullet + import bullet # type: ignore from xdg import XDG_CONFIG_HOME miniwdl_version = pkg_version() @@ -2148,6 +2149,7 @@ def _type_to_input_template(ty: Type.Base): """ if isinstance(ty, Type.StructInstance): ans = {} + assert ty.members for member_name, member_type in ty.members.items(): if not member_type.optional: # TODO: opt in to these ans[member_name] = _type_to_input_template(member_type) diff --git a/WDL/runtime/__init__.py b/WDL/runtime/__init__.py index 120b8cd7..b31c9044 100644 --- a/WDL/runtime/__init__.py +++ b/WDL/runtime/__init__.py @@ -61,4 +61,4 @@ def run( if "max_tasks" in run_kwargs and isinstance(exe, Tree.Task): del run_kwargs["max_tasks"] # N/A to run_local_task entrypoint = run_local_task if isinstance(exe, Tree.Task) else run_local_workflow - return entrypoint(cfg, exe, inputs, **run_kwargs) # pyre-ignore + return entrypoint(cfg, exe, inputs, **run_kwargs) # type: ignore diff --git a/WDL/runtime/backend/cli_subprocess.py b/WDL/runtime/backend/cli_subprocess.py index 1f1cf46b..5452b164 100644 --- a/WDL/runtime/backend/cli_subprocess.py +++ b/WDL/runtime/backend/cli_subprocess.py @@ -118,8 +118,8 @@ def _run(self, logger: logging.Logger, terminating: Callable[[], bool], command: poll_cli_log() if terminating(): raise Terminated() - assert isinstance(exit_code, int) - return exit_code + assert isinstance(exit_code, int) + return exit_code @abstractproperty def cli_name(self) -> str: diff --git a/WDL/runtime/workflow.py b/WDL/runtime/workflow.py index e57894ce..4f8a6063 100644 --- a/WDL/runtime/workflow.py +++ b/WDL/runtime/workflow.py @@ -1142,15 +1142,15 @@ def scan_uri(v: Union[Value.File, Value.Directory]) -> str: Value.rewrite_env_paths(inputs, scan_uri) if not uris: return - logger.notice(_("downloading input URIs", count=len(uris))) # pyre-fixme + logger.notice(_("downloading input URIs", count=len(uris))) # download them on the thread pool (but possibly further limiting concurrency) download_concurrency = cfg.get_int("scheduler", "download_concurrency") if download_concurrency <= 0: download_concurrency = 999999 - ops = {} + ops: Dict[futures.Future[Tuple[bool, str]], str] = {} incomplete = len(uris) - outstanding = set() + outstanding: Set[futures.Future[Tuple[bool, str]]] = set() downloaded_bytes = 0 cached_hits = 0 exn = None @@ -1208,7 +1208,7 @@ def scan_uri(v: Union[Value.File, Value.Directory]) -> str: if exn: raise exn - logger.notice( # pyre-fixme + logger.notice( _( "processed input URIs", cached=cached_hits, diff --git a/stubs/logging/__init__.py b/stubs/logging/__init__.py new file mode 100644 index 00000000..5481ac5e --- /dev/null +++ b/stubs/logging/__init__.py @@ -0,0 +1,6 @@ +from logging import Logger as OriginalLogger +from logging import DEBUG, INFO, WARNING, ERROR, CRITICAL + +class Logger(OriginalLogger): + def notice(self, *args, **kwargs) -> None: ... + def verbose(self, *args, **kwargs) -> None: ...