code: def _run_toil(args):
      
      main_file, json_file, project_name = _get_main_and_json(args.directory)
      work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "toil_work"))
      tmp_dir = utils.safe_makedir(os.path.join(work_dir, "tmpdir"))
      os.environ["TMPDIR"] = tmp_dir
      log_file = os.path.join(work_dir, "%s-toil.log" % project_name)
      jobstore = os.path.join(work_dir, "cwltoil_jobstore")
      flags = ["--jobStore", jobstore, "--logFile", log_file, "--workDir", tmp_dir, "--linkImports"]
      if os.path.exists(jobstore):
          flags += ["--restart"]
      # caching causes issues for batch systems
      if "--batchSystem" in args.toolargs:
          flags += ["--disableCaching"]
      flags += args.toolargs
      if args.no_container:
          _remove_bcbiovm_path()
          flags += ["--no-container", "--preserve-environment", "PATH", "HOME"]
      cmd = ["cwltoil"] + flags + ["--", main_file, json_file]
      with utils.chdir(work_dir):
          _run_tool(cmd, not args.no_container, work_dir)
          for tmpdir in (glob.glob(os.path.join(work_dir, "out_tmpdir*")) +
                         glob.glob(os.path.join(work_dir, "tmp*"))):
              if os.path.isdir(tmpdir):
                  shutil.rmtree(tmpdir)
docs: Run CWL with Toil.