class_docstr: Execute using SLURM
  
  The plugin_args input to run can be used to control the SLURM execution.
  Currently supported options are:
  
  - template : template to use for batch job submission
  
  - sbatch_args: arguments to pass prepend to the sbatch call
docstr: This is more or less the _submit_batchtask from sge.py with flipped
  variable names, different command line switches, and different output
  formatting/processing
docstr_tok: ["This","is","more","or","less","the","_submit_batchtask","from","sge.py","with","flipped","variable","names",",","different","command","line","switches",",","and","different","output","formatting\/processing"]
code: def _submit_batchtask(self, scriptfile, node):
      """
      This is more or less the _submit_batchtask from sge.py with flipped
      variable names, different command line switches, and different output
      formatting/processing
      """
      cmd = CommandLine(
          "sbatch",
          environ=dict(os.environ),
          resource_monitor=False,
          terminal_output="allatonce",
      )
      path = os.path.dirname(scriptfile)
  
      sbatch_args = ""
      if self._sbatch_args:
          sbatch_args = self._sbatch_args
      if "sbatch_args" in node.plugin_args:
          if (
              "overwrite" in node.plugin_args
              and node.plugin_args["overwrite"]
          ):
              sbatch_args = node.plugin_args["sbatch_args"]
          else:
              sbatch_args += " " + node.plugin_args["sbatch_args"]
      if "-o" not in sbatch_args:
          sbatch_args = "{} -o {}".format(
              sbatch_args, os.path.join(path, "slurm-%j.out")
          )
      if "-e" not in sbatch_args:
          sbatch_args = "{} -e {}".format(
              sbatch_args, os.path.join(path, "slurm-%j.out")
          )
      if node._hierarchy:
          jobname = ".".join(
              (dict(os.environ)["LOGNAME"], node._hierarchy, node._id)
          )
      else:
          jobname = ".".join((dict(os.environ)["LOGNAME"], node._id))
      jobnameitems = jobname.split(".")
      jobnameitems.reverse()
      jobname = ".".join(jobnameitems)
      cmd.inputs.args = f"{sbatch_args} -J {jobname} {scriptfile}"
      oldlevel = iflogger.level
      iflogger.setLevel(logging.getLevelName("CRITICAL"))
      tries = 0
      while True:
          try:
              result = cmd.run()
          except Exception as e:
              if tries < self._max_tries:
                  tries += 1
                  # sleep 2 seconds and try again.
                  sleep(self._retry_timeout)
              else:
                  iflogger.setLevel(oldlevel)
                  raise RuntimeError(
                      "\n".join(
                          (
                              "Could not submit sbatch task for node %s"
                              % node._id,
                              str(e),
                          )
                      )
                  )
          else:
              break
      logger.debug(f"Ran command ({cmd.cmdline})")
      iflogger.setLevel(oldlevel)
      # retrieve taskid
      lines = [
          line for line in result.runtime.stdout.split("\n") if line
      ]
      taskid = int(re.match(self._jobid_re, lines[-1]).groups()[0])
      self._pending[taskid] = node.output_dir()
      logger.debug(
          "submitted sbatch task: %d for node %s" % (taskid, node._id)
      )
      return taskid
  
file_path: nipype/nipype/pipeline/plugins/slurm.py
imports: import os
  import re
  from time import sleep
  from ...None import logging
  from ...interfaces.base import CommandLine
  from .base import SGELikeBatchManagerBase, logger
label_desc: Use image node_id 3 for calling the SLURMPlugin obj's underlying member method code with example usage: obj._submit_batchtask(scriptfile, node) and returns: taskid