Skip to content

Commit

Permalink
Strip leading whitespace from WDL commands (#4720)
Browse files Browse the repository at this point in the history
* Strip leading whitespace from WDL commands

* Work around MiniWDL's wrong type
  • Loading branch information
adamnovak authored Dec 14, 2023
1 parent 9aa2da9 commit 2bf0aa3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/toil/wdl/wdltoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import WDL.Error
import WDL.runtime.config
from configargparse import ArgParser, SUPPRESS
from WDL._util import byte_size_units
from WDL._util import byte_size_units, strip_leading_whitespace
from WDL.CLI import print_error
from WDL.runtime.backend.docker_swarm import SwarmContainer
from WDL.runtime.backend.singularity import SingularityContainer
Expand Down Expand Up @@ -1638,9 +1638,12 @@ def patched_run_invocation(*args: Any, **kwargs: Any) -> List[str]:

# Make a new standard library for evaluating the command specifically, which only deals with in-container paths and out-of-container paths.
command_library = ToilWDLStdLibTaskCommand(file_store, task_container)

# Work around wrong types from MiniWDL. See <https://github.com/chanzuckerberg/miniwdl/issues/665>
dedent = cast(Callable[[str], Tuple[int, str]], strip_leading_whitespace)

# Work out the command string, and unwrap it
command_string: str = evaluate_named_expression(self._task, "command", WDL.Type.String(), self._task.command, contained_bindings, command_library).coerce(WDL.Type.String()).value
command_string: str = dedent(evaluate_named_expression(self._task, "command", WDL.Type.String(), self._task.command, contained_bindings, command_library).coerce(WDL.Type.String()).value)[1]

# Grab the standard out and error paths. MyPy complains if we call
# them because in the current MiniWDL version they are untyped.
Expand Down

0 comments on commit 2bf0aa3

Please sign in to comment.