code: def cwl(
      path,
      basedir,
      input,
      output,
      params,
      wildcards,
      threads,
      resources,
      log,
      config,
      rulename,
      use_singularity,
      bench_record,
      jobid,
      sourcecache_path,
      runtime_sourcecache_path,
  ):
      """
      Load cwl from the given basedir + path and execute it.
      """
      if shutil.which("cwltool") is None:
          raise WorkflowError(
              "'cwltool' must be in PATH in order to execute cwl directive."
          )
  
      if not path.startswith("http"):
          if path.startswith("file://"):
              path = path[7:]
          elif path.startswith("file:"):
              path = path[5:]
          if not os.path.isabs(path):
              path = os.path.abspath(os.path.join(basedir, path))
          path = "file://" + path
      path = format(path, wildcards=wildcards)
      if path.startswith("file://"):
          sourceurl = "file:" + pathname2url(path[7:])
      else:
          sourceurl = path
  
      def file_spec(f):
          if isinstance(f, str):
              return {"path": os.path.abspath(f), "class": "File"}
          return [file_spec(f_) for f_ in f]
  
      inputs = dict()
      inputs.update({name: file_spec(f) for name, f in input.items()})
      inputs.update({name: p for name, p in params.items()})
      inputs.update({name: f for name, f in output.items()})
      inputs.update({name: f for name, f in log.items()})
  
      args = "--singularity" if use_singularity else ""
  
      with tempfile.NamedTemporaryFile(mode="w") as input_file:
          json.dump(inputs, input_file)
          input_file.flush()
          cmd = f"cwltool {args} {sourceurl} {input_file.name}"
          shell(cmd, bench_record=bench_record)
  
file_path: snakemake/snakemake/cwl.py
imports: from urllib.request import pathname2url
  import os
  import tempfile
  import json
  import shutil
  from itertools import chain
  from snakemake.utils import format
  from snakemake.exceptions import WorkflowError
  from snakemake.shell import shell
  from snakemake.common import get_container_image
  from snakemake_interface_executor_plugins.settings import ExecMode
label_desc: Use image node_id 1 for calling a global function with example usage: cwl(path, basedir, input, output, params, wildcards, threads, resources, log, config, rulename, use_singularity, bench_record, jobid, sourcecache_path, runtime_sourcecache_path) and returns: unknown, dict