cwltool.job
===========

.. py:module:: cwltool.job


Attributes
----------

.. autoapisummary::

   cwltool.job.CollectOutputsType
   cwltool.job.needs_shell_quoting_re
   cwltool.job.FORCE_SHELLED_POPEN
   cwltool.job.SHELL_COMMAND_TEMPLATE
   cwltool.job.CONTROL_CODE_RE


Classes
-------

.. autoapisummary::

   cwltool.job.JobBase
   cwltool.job.CommandLineJob
   cwltool.job.ContainerCommandLineJob


Functions
---------

.. autoapisummary::

   cwltool.job.relink_initialworkdir
   cwltool.job.neverquote


Module Contents
---------------

.. py:data:: CollectOutputsType

.. py:data:: needs_shell_quoting_re

.. py:data:: FORCE_SHELLED_POPEN

.. py:data:: SHELL_COMMAND_TEMPLATE
   :value: Multiline-String

   .. raw:: html

      <details><summary>Show Value</summary>

   .. code-block:: python

      """#!/bin/bash
      python3 "run_job.py" "job.json"
      """

   .. raw:: html

      </details>



.. py:function:: relink_initialworkdir(pathmapper, host_outdir, container_outdir, inplace_update = False)

.. py:function:: neverquote(string, pos = 0, endpos = 0)

   No-op.


.. py:class:: JobBase(builder, joborder, make_path_mapper, requirements, hints, name)

   Bases: :py:obj:`cwltool.utils.HasReqsHints`

   .. autoapi-inheritance-diagram:: cwltool.job.JobBase
      :parts: 1


   Base class for get_requirement().


   .. py:attribute:: builder


   .. py:attribute:: joborder


   .. py:attribute:: stdin
      :type:  str | None
      :value: None



   .. py:attribute:: stderr
      :type:  str | None
      :value: None



   .. py:attribute:: stdout
      :type:  str | None
      :value: None



   .. py:attribute:: successCodes
      :type:  collections.abc.Iterable[int]
      :value: []



   .. py:attribute:: temporaryFailCodes
      :type:  collections.abc.Iterable[int]
      :value: []



   .. py:attribute:: permanentFailCodes
      :type:  collections.abc.Iterable[int]
      :value: []



   .. py:attribute:: requirements


   .. py:attribute:: hints


   .. py:attribute:: name


   .. py:attribute:: command_line
      :type:  list[str]
      :value: []



   .. py:attribute:: pathmapper


   .. py:attribute:: make_path_mapper


   .. py:attribute:: generatemapper
      :type:  cwltool.pathmapper.PathMapper | None
      :value: None



   .. py:attribute:: collect_outputs
      :value: None



   .. py:attribute:: output_callback
      :type:  cwltool.utils.OutputCallbackType | None
      :value: None



   .. py:attribute:: outdir
      :value: ''



   .. py:attribute:: tmpdir
      :value: ''



   .. py:attribute:: environment
      :type:  collections.abc.MutableMapping[str, str]


   .. py:attribute:: generatefiles


   .. py:attribute:: stagedir
      :type:  str | None
      :value: None



   .. py:attribute:: inplace_update
      :value: False



   .. py:attribute:: timelimit
      :type:  int | None
      :value: None



   .. py:attribute:: networkaccess
      :type:  bool
      :value: False



   .. py:attribute:: mpi_procs
      :type:  int | None
      :value: None



   .. py:method:: __repr__()

      Represent this Job object.



   .. py:method:: run(runtimeContext, tmpdir_lock = None)
      :abstractmethod:



   .. py:method:: extract_environment(runtimeContext, envVarReq)
      :staticmethod:


      Extract environment variables that should be preserved.



   .. py:method:: prepare_environment(runtimeContext, envVarReq)

      Set up environment variables.

      Here we prepare the environment for the job, based on any
      preserved variables and `EnvVarRequirement`. Later, changes due
      to `MPIRequirement`, `Secrets`, or `SoftwareRequirement` are
      applied (in that order).



   .. py:method:: process_monitor(sproc)

      Watch a process, logging its max memory usage.



.. py:class:: CommandLineJob(builder, joborder, make_path_mapper, requirements, hints, name)

   Bases: :py:obj:`JobBase`

   .. autoapi-inheritance-diagram:: cwltool.job.CommandLineJob
      :parts: 1


   Base class for get_requirement().


   .. py:method:: run(runtimeContext, tmpdir_lock = None)


.. py:data:: CONTROL_CODE_RE
   :value: '\\x1b\\[[0-9;]*[a-zA-Z]'


.. py:class:: ContainerCommandLineJob(builder, joborder, make_path_mapper, requirements, hints, name)

   Bases: :py:obj:`JobBase`

   .. autoapi-inheritance-diagram:: cwltool.job.ContainerCommandLineJob
      :parts: 1


   Commandline job using containers.


   .. py:attribute:: CONTAINER_TMPDIR
      :type:  str
      :value: '/tmp'



   .. py:method:: get_from_requirements(r, pull_image, force_pull, tmp_outdir_prefix, image_base_path = None)
      :abstractmethod:



   .. py:method:: create_runtime(env, runtime_context)
      :abstractmethod:


      Return the list of commands to run the selected container engine.



   .. py:method:: append_volume(runtime, source, target, writable = False)
      :staticmethod:

      :abstractmethod:


      Add binding arguments to the runtime list.



   .. py:method:: add_file_or_directory_volume(runtime, volume, host_outdir_tgt)
      :abstractmethod:


      Append volume a file/dir mapping to the runtime option list.



   .. py:method:: add_writable_file_volume(runtime, volume, host_outdir_tgt, tmpdir_prefix)
      :abstractmethod:


      Append a writable file mapping to the runtime option list.



   .. py:method:: add_writable_directory_volume(runtime, volume, host_outdir_tgt, tmpdir_prefix)
      :abstractmethod:


      Append a writable directory mapping to the runtime option list.



   .. py:method:: create_file_and_add_volume(runtime, volume, host_outdir_tgt, secret_store, tmpdir_prefix)

      Create the file and add a mapping.



   .. py:method:: add_volumes(pathmapper, runtime, tmpdir_prefix, secret_store = None, any_path_okay = False)

      Append volume mappings to the runtime option list.



   .. py:method:: run(runtimeContext, tmpdir_lock = None)


   .. py:method:: docker_monitor(cidfile, tmpdir_prefix, cleanup_cidfile, docker_exe, process)

      Record memory usage of the running Docker container.



