Package Ganga :: Package GPIDev :: Package Lib :: Package Job :: Module Job' :: Class Job
[hide private]
[frames] | no frames]

Class Job

source code

          object --+        
                   |        
   Base.Objects.Node --+    
                       |    
Base.Objects.GangaObject --+
                           |
                          Job
Known Subclasses:

This is a Ganga.GPI.Job implementation class. Refer to Ganga.GPI.Job.__doc__ for documentation.

Nested Classes [hide private]
  State
  Transitions
  _proxyClass
Job is an interface for submision, killing and querying the jobs :-).

Inherited from Base.Objects.GangaObject: __metaclass__

Instance Methods [hide private]
 
__getstate__(self) source code
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_attribute_filter__set__(self, n, v) source code
 
_auto__init__(self, registry=None) source code
 
_checkset_status(self, value) source code
 
_commit(self, objects=None)
Helper method to unconditionally commit to the repository.
source code
 
_init_workspace(self) source code
 
_kill(self, transition_update)
Private helper.
source code
 
_readonly(self) source code
 
_repr(self) source code
 
_resubmit(self, backend=None, auto_resubmit=False)
Internal implementation of resubmit which handles the publically accessible resubmit() method proper as well as the auto_resubmit use case used in the monitoring loop.
source code
 
_subjobs_proxy(self) source code
 
_subjobs_summary_print(self, value, verbosity_level) source code
 
auto_resubmit(self)
Private method used for auto resubmit functionality by the monitoring loop.
source code
 
createInputSandbox(self, files, master=False)
Create an unpacked input sandbox which contains files (a list of File or FileBuffer objects).
source code
 
createPackedInputSandbox(self, files, master=False)
Create a packed input sandbox which contains files (a list of File or FileBuffer objects).
source code
 
fail(self, force=False)
Deprecated.
source code
 
force_status(self, status, force=False)
Force job to enter the "failed" or "completed" state.
source code
 
getDebugWorkspace(self, create=True) source code
 
getFQID(self, sep=None)
Return a fully qualified job id (within registry): a list of ids [masterjob_id,subjob_id,...] If optional sep is specified FQID string is returned, ids are separated by sep.
source code
 
getInputWorkspace(self, create=True) source code
 
getMonitoringService(self) source code
 
getOutputWorkspace(self, create=True) source code
 
getStringFQID(self) source code
 
getStringInputDir(self) source code
 
getStringOutputDir(self) source code
 
getWorkspace(self, what, create=True) source code
 
kill(self)
Kill the job.
source code
 
merge(self, subjobs=None, sum_outputdir=None, **options)
Merge the output of subjobs.
source code
 
monitorFailed_hook(self) source code
 
monitorKilled_hook(self) source code
 
monitorPrepare_hook(self, subjobconfig)
Let monitoring services work with the subjobconfig after it's prepared
source code
 
monitorRollbackToNew_hook(self) source code
 
monitorSubmitted_hook(self)
Send monitoring information (e.g.
source code
 
monitorSubmitting_hook(self)
Let monitoring services perform actions at job submission
source code
 
peek(self, filename='', command='')
Allow viewing of job output (and input) files
source code
 
postprocess_hook(self) source code
 
postprocess_hook_failed(self) source code
 
remove(self, force=False)
Remove the job.
source code
 
resubmit(self, backend=None)
Resubmit a failed or completed job.
source code
 
rollbackToNewState(self)
Rollback the job to the "new" state if submitting of job failed:
source code
 
submit(self, keep_going=None, keep_on_fail=None)
Submits a job.
source code
 
transition_update(self, new_status)
Propagate status transitions
source code
 
updateMasterJobStatus(self)
Update master job status based on the status of subjobs.
source code
 
updateStatus(self, newstatus, transition_update=True)
Move job to the new status.
source code
 
viewFile(self, path='', command='')
Allow file viewing
source code

Inherited from Base.Objects.GangaObject: __construct__, __deepcopy__, __setstate__, accept, getJobObject

Inherited from Base.Objects.Node: __copy__, __eq__, __ne__, clone, copyFrom, printSummaryTree, printTree

Inherited from Base.Objects.Node (private): _getParent, _getRoot, _setParent

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from Base.Objects.GangaObject (private): _declared_property

Class Variables [hide private]
  _GUIPrefs = [{'attribute': 'id'}, {'attribute': 'status'}, {'a...
  _category = 'jobs'
  _exportmethods = ['submit', 'remove', 'kill', 'resubmit', 'pee...
  _name = 'Job'
  _schema = <Ganga.GPIDev.Schema.Schema.Schema instance at 0x18a...
  allowed_force_states = {'completed': ['completing', 'failed'],...
  application = <Ganga.GPIDev.Base.Objects.Descriptor object at ...
  backend = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18...
  default_registry = 'jobs'
  do_auto_resubmit = <Ganga.GPIDev.Base.Objects.Descriptor objec...
  fqid = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9350>
  id = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9750>
  info = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x189de90>
  initial_states = ['new', 'incomplete', 'template']
  inputdata = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x...
  inputdir = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x1...
  inputsandbox = <Ganga.GPIDev.Base.Objects.Descriptor object at...
  master = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a...
  merger = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a...
  name = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9050>
  outputdata = <Ganga.GPIDev.Base.Objects.Descriptor object at 0...
  outputdir = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x...
  outputsandbox = <Ganga.GPIDev.Base.Objects.Descriptor object a...
  splitter = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x1...
  status = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x189...
  status_graph = {'completed': {'failed': <Ganga.GPIDev.Lib.Job....
  subjobs = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18...
  time = <Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9550>
  transient_states = ['incomplete', 'removed', 'unknown']

Inherited from Base.Objects.GangaObject (private): _hidden, _registry

Inherited from Base.Objects.Node (private): _index_cache, _parent

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__getstate__(self)

source code 
Overrides: Base.Objects.Node.__getstate__

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

_attribute_filter__set__(self, n, v)

source code 
Overrides: Base.Objects.GangaObject._attribute_filter__set__

_auto__init__(self, registry=None)

source code 
Overrides: Base.Objects.GangaObject._auto__init__

_commit(self, objects=None)

source code 

Helper method to unconditionally commit to the repository. The 'objects' list specifies objects to be commited (for example the subjobs). If objects are not specified then just the self is commited

_kill(self, transition_update)

source code 

Private helper. Kill the job. Raise JobError exception on error.

_readonly(self)

source code 
Overrides: Base.Objects.GangaObject._readonly

createInputSandbox(self, files, master=False)

source code 

Create an unpacked input sandbox which contains files (a list of File or FileBuffer objects). 'master' flag is not used in this case, and it provided only for uniformity with createPackedInputSandbox() method

createPackedInputSandbox(self, files, master=False)

source code 

Create a packed input sandbox which contains files (a list of File or FileBuffer objects). 'master' flag is used to make a difference between the master and shared input sandbox which is important if the job is not split (subjob and masterjob are the same object)

fail(self, force=False)

source code 

Deprecated. Use force_status('failed') instead.

force_status(self, status, force=False)

source code 

Force job to enter the "failed" or "completed" state. This may be used for marking jobs "bad" jobs or jobs which are stuck in one of the internal ganga states (e.g. completing).

To see the list of allowed states do: job.force_status(None)

getFQID(self, sep=None)

source code 

Return a fully qualified job id (within registry): a list of ids [masterjob_id,subjob_id,...] If optional sep is specified FQID string is returned, ids are separated by sep. For example: getFQID('.') will return 'masterjob_id.subjob_id....'

kill(self)

source code 

Kill the job. Raise JobError exception on error.

merge(self, subjobs=None, sum_outputdir=None, **options)

source code 

Merge the output of subjobs.

By default merge all subjobs into the master outputdir. The output location and the list of subjobs may be overriden. The options (keyword arguments) are passed onto the specific merger implementation. Refer to the specific merger documentation for more information about available options.

monitorSubmitted_hook(self)

source code 

Send monitoring information (e.g. Dashboard) at the time of job submission

peek(self, filename='', command='')

source code 

Allow viewing of job output (and input) files

Arguments other than self:
filename : name of file to be viewed
           => For backends where this is enabled, the filename
              for a job in the "running" state is relative to
              the job's work directory unless the filename begins
              with "../".  In all other cases, the filename is
              relative to the job's output directory
command  : command to be used for viewing the file
           => If no command is given, then the command defined in
              the [File_Associations] section of the Ganga
              configuration file(s) is used

Example usage:

   # examine contents of output/work directory
   peek()

   # examine contents of output directory,
   # even in case of job in "running" state
   peek( "../output" )

   # examine contents of input directory
   peek( "../input" )

   # View ROOT histograms, running root.exe in a new terminal window
   peek( "histograms.root", "root.exe &&" )

   # View contents of file in output/work directory, using
   # command defined in configuration file
   peek( "output.txt" )

   # View ROOT histograms in ouput/work directory,
   # running root.exe in a new terminal window
   peek( "histograms.root", "root.exe &&" )
              
Return value: None

remove(self, force=False)

source code 

Remove the job.

If job has been submitted try to kill it first. Then remove the file workspace associated with the job.

If force=True then remove job without killing it.

resubmit(self, backend=None)

source code 
Resubmit a failed or completed job.  A backend object may
be specified to change some submission parameters (which
parameters may be effectively changed depends on a
particular backend implementation).

Example:
 b = j.backend.copy()
 b.CE = 'some CE'
 j.resubmit(backend=b)

Note: it is not possible to change the type of the backend in this way.

rollbackToNewState(self)

source code 

Rollback the job to the "new" state if submitting of job failed:

  • cleanup the input and output workspace preserving the top dir(bug ##19434)
  • do not remove debug directory
  • cleanup subjobs

This method is used as a hook for submitting->new transition @see updateJobStatus()

submit(self, keep_going=None, keep_on_fail=None)

source code 

Submits a job. Return true on success.

First the application is configured which may generate additional input files, preprocess executable scripts etc. Then backend handler is used to submit the configured job. The job is automatically checkpointed to persistent storage.

The default values of keep_going and keep_on_fail are controlled by [GPI_Semantics] configuration options.

When the submission fails the job status is automatically reverted to new and all files in the input directory are deleted (keep_on_fail=False is the default behaviour unless modified in configuration). If keep_on_fail=True then the job status is moved to the failed status and input directory is left intact. This is helpful for debugging anf implements the request #43143.

For split jobs: consult https://twiki.cern.ch/twiki/bin/view/ArdaGrid/GangaSplitters#Subjob_submission

updateMasterJobStatus(self)

source code 

Update master job status based on the status of subjobs. This is an auxiliary method for implementing bulk subjob monitoring.

updateStatus(self, newstatus, transition_update=True)

source code 

Move job to the new status. according to the state transition graph (Job.status_graph). If transition is allowed:

  • call the specific transition hook (if exists)
  • call the general transition update hook (triggers the auto merger and application hooks)
  • commit the job

If job cannot be commited, then revert to old status and raise JobStatusError. If transition is not allowed then raise JobStatusError.

Transitions from to the current state are allowed by default (so you can updateStatus('running') if job is 'running'). Such default transitions do not have hooks.

viewFile(self, path='', command='')

source code 

Allow file viewing

Arguments other than self:
path    : path to file to be viewed
command  : command to be used for viewing the file
           => If no command is given, then the command defined in
              the [File_Associations] section of the Ganga
              configuration file(s) is used

This is intended as a helper function for the peek() method.

Return value: None


Class Variable Details [hide private]

_GUIPrefs

Value:
[{'attribute': 'id'},
 {'attribute': 'status'},
 {'attribute': 'inputsandbox', 'displayLevel': 1},
 {'attribute': 'inputdata'},
 {'attribute': 'outputsandbox'}]

_exportmethods

Value:
['submit',
 'remove',
 'kill',
 'resubmit',
 'peek',
 'fail',
 'force_status',
 'merge']

_schema

Value:
<Ganga.GPIDev.Schema.Schema.Schema instance at 0x18a0e18>

allowed_force_states

Value:
{'completed': ['completing', 'failed'],
 'failed': ['submitting',
            'completing',
            'completed',
            'submitted',
            'running',
            'killed']}

application

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a93d0>

backend

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a97d0>

do_auto_resubmit

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a91d0>

inputdata

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x189df90>

inputdir

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a90d0>

inputsandbox

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9250>

master

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9450>

merger

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9150>

outputdata

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a94d0>

outputdir

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a92d0>

outputsandbox

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a9650>

splitter

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a95d0>

status

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x189df10>

status_graph

Value:
{'completed': {'failed': <Ganga.GPIDev.Lib.Job.Job.State instance at 0\
x18a6a28>, 'removed': <Ganga.GPIDev.Lib.Job.Job.State instance at 0x18\
a69e0>, 'submitted': <Ganga.GPIDev.Lib.Job.Job.State instance at 0x18a\
6ab8>, 'submitting': <Ganga.GPIDev.Lib.Job.Job.State instance at 0x18a\
6a70>},
 'completing': {'failed': <Ganga.GPIDev.Lib.Job.Job.State instance at \
0x18a66c8>, 'completed': <Ganga.GPIDev.Lib.Job.Job.State instance at 0\
x18a6680>, 'submitted': <Ganga.GPIDev.Lib.Job.Job.State instance at 0x\
...

subjobs

Value:
<Ganga.GPIDev.Base.Objects.Descriptor object at 0x18a96d0>