diff --git a/planemo/cwl/toil.py b/planemo/cwl/toil.py index 30d296589..c4ce6dc83 100644 --- a/planemo/cwl/toil.py +++ b/planemo/cwl/toil.py @@ -1,11 +1,6 @@ import json import tempfile -try: - from toil.cwl import cwltoil -except ImportError: - cwltoil = None - from planemo.deps import ensure_dependency_resolvers_conf_configured from planemo.io import ( error, @@ -25,7 +20,7 @@ def run_toil(ctx, runnable: "Runnable", job_path: str, **kwds): """Translate planemo kwds to cwltool kwds and run cwltool main function.""" - _ensure_toil_available() + cwltoil = _ensure_toil_available() args = [] if not ctx.verbose: @@ -75,5 +70,9 @@ def run_toil(ctx, runnable: "Runnable", job_path: str, **kwds): def _ensure_toil_available(): - if cwltoil is None: + try: + from toil.cwl import cwltoil + + return cwltoil + except ImportError: raise Exception(TOIL_REQUIRED_MESSAGE)