Skip to content

Commit

Permalink
satisfy mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
stxue1 committed Oct 24, 2024
1 parent 642efd0 commit e712d88
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
12 changes: 7 additions & 5 deletions src/toil/cwl/cwltoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
TypeVar,
Union,
cast,
Sequence,
Sequence, Literal,
)
from urllib.error import HTTPError
from urllib.parse import quote, unquote, urlparse, urlsplit
Expand Down Expand Up @@ -1857,7 +1857,7 @@ def extract_files(

if location in fileindex:
file_metadata["location"] = fileindex[location]
return
return None
if not location and file_metadata["path"]:
file_metadata["location"] = location = schema_salad.ref_resolver.file_uri(
cast(str, file_metadata["path"])
Expand Down Expand Up @@ -1944,7 +1944,7 @@ def visit_files(
:param log_level: Log imported files at the given level.
"""
func_return = list()
func_return: List[Any] = list()
tool_id = cwl_object.get("id", str(cwl_object)) if cwl_object else ""

logger.debug("Importing files for %s", tool_id)
Expand Down Expand Up @@ -3653,7 +3653,7 @@ class CWLStartJob(CWLNamedJob):

def __init__(
self,
inputs: Promised[Tuple[CWLObjectType, CWLObjectType]],
inputs: Promised[Tuple[CWLObjectType, Process]],
runtime_context: cwltool.context.RuntimeContext,
**kwargs: Any,
) -> None:
Expand Down Expand Up @@ -3765,7 +3765,7 @@ def import_workflow_inputs(
# always get a FileID out.
def file_import_function(url: str) -> FileID:
logger.log(log_level, "Loading %s...", url)
return cast(FileID, jobstore.import_file(url, symlink=True))
return jobstore.import_file(url, symlink=True)

# Import all the input files, some of which may be missing optional
# files.
Expand Down Expand Up @@ -3835,6 +3835,8 @@ def visitSteps(
f"Unsupported type encountered in workflow "
f"traversal: {type(cmdline_tool)}"
)
# Satisfy mypy, but this branch should never be reached in practice
return []


def rm_unprocessed_secondary_files(job_params: Any) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/toil/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -3874,8 +3874,8 @@ class ImportsJob(Job):
def __init__(
self,
file_to_data: Dict[str, FileMetadata],
import_workers_threshold,
**kwargs: Any,
import_workers_threshold: ParseableIndivisibleResource,
**kwargs: Any
):
"""
Job to take the inputs from the WDL workflow and import them on a worker instead of a leader. Assumes all local and cloud files are accessible.
Expand Down
14 changes: 7 additions & 7 deletions src/toil/wdl/wdltoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ def convert_file_to_uri(file: WDL.Value.File) -> WDL.Value.File:
Calls import_filename to detect if a potential URI exists and imports it. Will modify the File object value to the new URI and tack on the virtualized file.
"""
candidate_uri = file_to_data[file.value][0]
file_id = file_to_id.get(candidate_uri)
file_id = file_to_id[candidate_uri]

# Work out what the basename for the file was
file_basename = os.path.basename(urlsplit(candidate_uri).path)
Expand Down Expand Up @@ -4877,7 +4877,7 @@ def __init__(
self,
task_path: str,
inputs: WDLBindings,
import_data: Promised[Tuple[Dict[str, FileID]], Dict[str, FileMetadata]],
import_data: Promised[Tuple[Dict[str, FileID], Dict[str, FileMetadata]]],
**kwargs: Any,
) -> None:
"""
Expand Down Expand Up @@ -4915,9 +4915,9 @@ def __init__(
target: Union[WDL.Tree.Workflow, WDL.Tree.Task],
inputs: WDLBindings,
wdl_options: WDLContext,
inputs_search_path,
import_remote_files,
import_workers_threshold,
inputs_search_path: List[str],
import_remote_files: bool,
import_workers_threshold: ParseableIndivisibleResource,
**kwargs: Any,
):
"""
Expand Down Expand Up @@ -4960,13 +4960,13 @@ def run(self, file_store: AbstractFileStore) -> Promised[WDLBindings]:
def make_root_job(
target: WDL.Tree.Workflow | WDL.Tree.Task,
inputs: WDLBindings,
inputs_search_path: list[str],
inputs_search_path: List[str],
toil: Toil,
wdl_options: WDLContext,
options: Namespace,
) -> WDLSectionJob:
if options.run_imports_on_workers:
root_job = WDLImportWrapper(
root_job: WDLSectionJob = WDLImportWrapper(
target,
inputs,
wdl_options=wdl_options,
Expand Down

0 comments on commit e712d88

Please sign in to comment.