gstlal 1.13.0
Loading...
Searching...
No Matches
python.dagfile.DAG Class Reference
Inheritance diagram for python.dagfile.DAG:
Collaboration diagram for python.dagfile.DAG:

Public Member Functions

 __init__ (self, nodes={}, maxjobs={}, config=None, dot=None, dotupdate=False, dotoverwrite=True, dotinclude=None, node_status_file=None, node_status_file_updatetime=None, jobstate_log=None)
 reindex (self)
 parse (cls, f, progress=None)
 select_nodes_by_name (cls, dag, nodenames)
 get_all_parent_names (self, names)
 get_all_child_names (self, names)
 check_edges (self)
 load_rescue (self, f, progress=None)
 write (self, f, progress=None, rescue=None)
 dot_source (self, title="DAG", rename=False, colour="black", bgcolour="#a3a3a3", statecolours={ 'wait':'yellow', 'idle':'yellow', 'run':'lightblue', 'abort':'red', 'stop':'red', 'success':'green', 'fail':'red'})

Public Attributes

 nodes = nodes
 maxjobs = maxjobs
 config = config
 dot = dot
bool dotupdate = dotupdate
bool dotoverwrite = dotoverwrite
 dotinclude = dotinclude
 node_status_file = node_status_file
 node_status_file_updatetime = node_status_file_updatetime
 jobstate_log = jobstate_log

Static Public Attributes

 dotpat = re.compile(r'^DOT\s+(?P<filename>\S+)(\s+(?P<options>.+))?', re.IGNORECASE)
 jobpat = re.compile(r'^JOB\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?(\s+(?P<noop>NOOP))?(\s+(?P<done>DONE))?', re.IGNORECASE)
 datapat = re.compile(r'^DATA\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?(\s+(?P<noop>NOOP))?(\s+(?P<done>DONE))?', re.IGNORECASE)
 subdagpat = re.compile(r'^SUBDAG\s+EXTERNAL\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?(\s+(?P<noop>NOOP))?(\s+(?P<done>DONE))?', re.IGNORECASE)
 splicepat = re.compile(r'^SPLICE\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?', re.IGNORECASE)
 prioritypat = re.compile(r'^PRIORITY\s+(?P<name>\S+)\s+(?P<value>\S+)', re.IGNORECASE)
 categorypat = re.compile(r'^CATEGORY\s+(?P<name>\S+)\s+(?P<category>\S+)', re.IGNORECASE)
 retrypat = re.compile(r'^RETRY\s+(?P<name>\S+)\s+(?P<retries>\S+)(\s+UNLESS-EXIT\s+(?P<retry_unless_exit_value>\S+))?', re.IGNORECASE)
 varspat = re.compile(r'^VARS\s+(?P<name>\S+)\s+(?P<vars>.+)', re.IGNORECASE)
 varsvaluepat = re.compile(r'(?P<name>\S+)\s*=\s*"(?P<value>.*?)(?<!\\‍)"', re.IGNORECASE)
 scriptpat = re.compile(r'^SCRIPT\s+(?P<type>(PRE)|(POST))\s(?P<name>\S+)\s+(?P<executable>\S+)(\s+(?P<arguments>.+))?', re.IGNORECASE)
 abortdagonpat = re.compile(r'^ABORT-DAG-ON\s+(?P<name>\S+)\s+(?P<exitvalue>\S+)(\s+RETURN\s+(?P<returnvalue>\S+))?', re.IGNORECASE)
 arcpat = re.compile(r'^PARENT\s+(?P<parents>.+?)\s+CHILD\s+(?P<children>.+)', re.IGNORECASE)
 maxjobspat = re.compile(r'^MAXJOBS\s+(?P<category>\S+)\s+(?P<value>\S+)', re.IGNORECASE)
 configpat = re.compile(r'^CONFIG\s+(?P<filename>\S+)', re.IGNORECASE)
 nodestatuspat = re.compile(r'^NODE_STATUS_FILE\s+(?P<filename>\S+)(\s+(?P<updatetime>\S+))?', re.IGNORECASE)
 jobstatepat = re.compile(r'^JOBSTATE_LOG\s+(?P<filename>\S+)', re.IGNORECASE)
 donepat = re.compile(r'^DONE\s+(?P<name>\S+)', re.IGNORECASE)

Detailed Description

Representation of the contents of a Condor DAG file.

BUGS:  the semantics of the "+" special character in category names
is not understood.  For now, it is an error for a node's category
to not be found verbatim in a MAXJOBS line.  The "+" character is a
wildcard-like character used in the assignment of MAXJOBS values to
job categories in splices;  see the Condor documentation for more
information.

Definition at line 346 of file dagfile.py.

Constructor & Destructor Documentation

◆ __init__()

python.dagfile.DAG.__init__ ( self,
nodes = {},
maxjobs = {},
config = None,
dot = None,
dotupdate = False,
dotoverwrite = True,
dotinclude = None,
node_status_file = None,
node_status_file_updatetime = None,
jobstate_log = None )
The meanings of the keyword arguments are:

nodes:
    name --> JOB object mapping
maxjobs:
    category name --> integer max jobs value mapping.  all
    categories are listed, that is it is an error for a JOB
    in the DAG to claim to be in a category that cannot be
    found in this dictionary.  categories that don't have a
    MAXJOBS set for them use None as their max jobs value
    in this dictionary.
config:
    filename or None
dot:
    filename or None
dotupdate:
dotoverwrite:
    booleans, defaults match Condor's
dotinclude:
    filename or None
node_status_file:
node_status_file_updatetime:
    filename and update time or None for both
jobstate_log:
    filename or None

It is also possible to initialize a DAG object from another
DAG (-like) object with.

>> new = DAG(old)

Definition at line 390 of file dagfile.py.

Member Function Documentation

◆ check_edges()

python.dagfile.DAG.check_edges ( self)
Check all graph edges for validity.  Checks that each of
every node's children lists that node as a parent, and vice
versa, and that all nodes listed in the parent and child
sets of all nodes are contained in this DAG.  Raises
ValueError if a problem is found, otherwise returns None.

Example:

>>> try:
... dag.check_edges()
... except ValueError as e:
... print("edges are broken: %s" % str(e))
... else:
... print("all edges are OK")
...

Definition at line 742 of file dagfile.py.

◆ dot_source()

python.dagfile.DAG.dot_source ( self,
title = "DAG",
rename = False,
colour = "black",
bgcolour = "#a3a3a3",
statecolours = {'wait': 'yellow', 'idle': 'yellow', 'run': 'lightblue', 'abort': 'red', 'stop': 'red', 'success': 'green', 'fail': 'red'} )
Generator yielding a sequence of strings containing DOT
code to generate a visualization of the DAG graph.  See
http://www.graphviz.org for more information.

title provides a title for the graph.  If rename is True,
instead of using the names of the nodes for the node names
in the graph, numbers will be used instead.  The numbers
are assigned to the nodes in alphabetical order by node
name.  This might be required if the nodes have names that
are incompatible with the DOT syntax.

colour and bgcolour set the outline colour of the graph
nodes and the background colour for the graph respectively.
statecolours is a dictionary mapping node state (see the
.state attribute of the JOB class and its derivatives) to a
colour.  Set statecolours to None to disable state-based
colouring of graph nodes.

Example:

>>> import sys
>>> sys.stdout.writelines(dag.dot_source(statecolours = None))

BUGS:  the JOB class does not implement the ability to
retrieve the job state at this time, therefore it is always
necessary to set statecolours to None.  This might change
in the future.

Definition at line 950 of file dagfile.py.

◆ get_all_child_names()

python.dagfile.DAG.get_all_child_names ( self,
names )
Trace the DAG forward from the children of the nodes whose
names are given to the leaf nodes, inclusively, and return
the set of the names of all nodes visited.

Example:

>>> all_children = dag.get_all_child_names(["triggergen"])

Definition at line 724 of file dagfile.py.

◆ get_all_parent_names()

python.dagfile.DAG.get_all_parent_names ( self,
names )
Trace the DAG backward from the parents of the nodes whose
names are given to the head nodes, inclusively, and return
the set of the names of all nodes visited.

Example:

>>> all_parents = dag.get_all_parent_names(["triggergen"])

Definition at line 706 of file dagfile.py.

◆ load_rescue()

python.dagfile.DAG.load_rescue ( self,
f,
progress = None )
Parse the file-like object f as a rescue DAG, using the
DONE lines therein to set the job states of this DAG.

In the past, rescue DAGs were full copies of the original
DAG with the word DONE added to the JOB lines of completed
jobs.  In version 7.7.2 of Condor, the default format of
rescue DAGs was changed to a condensed format consisting of
only the names of completed jobs and the number of retries
remaining for incomplete jobs.  Currently Condor still
supports the original rescue DAG format, but the user must
set the DAGMAN_WRITE_PARTIAL_RESCUE config variable to
false to obtain one.  This module does not directly support
the new format, however this method allows a new-style
rescue DAG to be parsed to set the states of the jobs in a
DAG.  This, in effect, converts a new-style rescue DAG to
an old-style rescue DAG, allowing the result to be
manipulated as before.

If the progress argument is not None, it should be a
callable object.  This object will be called periodically
and passed the f argument, the current line number, and a
boolean indicating if parsing is complete.  The boolean is
always False until parsing is complete, then the callable
will be invoked one last time with the final line count and
the boolean set to True.

Definition at line 773 of file dagfile.py.

◆ parse()

python.dagfile.DAG.parse ( cls,
f,
progress = None )
Parse the file-like object f as a Condor DAG file.  Return
a DAG object.  The file object must be iterable, yielding
one line of text of the DAG file in each iteration.

If the progress argument is not None, it should be a
callable object.  This object will be called periodically
and passed the f argument, the current line number, and a
boolean indicating if parsing is complete.  The boolean is
always False until parsing is complete, then the callable
will be invoked one last time with the final line count and
the boolean set to True.

Example:

>>> def progress(f, n, done):
... print("reading %s: %d lines\\r" % (f.name, n)),
... if done:
...     print
...
>>> dag = DAG.parse(open("pipeline.dag"), progress = progress)

Definition at line 476 of file dagfile.py.

◆ reindex()

python.dagfile.DAG.reindex ( self)
Rebuild the .nodes index.  This is required if the names of
nodes are changed.

Definition at line 461 of file dagfile.py.

◆ select_nodes_by_name()

python.dagfile.DAG.select_nodes_by_name ( cls,
dag,
nodenames )
Construct a new DAG object containing only the nodes whose
names are in nodenames.

Example:

>>> names_to_rerun = set(["triggergen"])
>>> dag = DAG.select_nodes_by_name(dag, names_to_rerun | dag.get_all_parent_names(names_to_rerun))

NOTE:  the new DAG object is given references to the node
(JOB, DATA, etc.) objects in the original DAG, not copies
of them.  Therefore, editing the node objects, for example
modifying their parent or child sets, will affect both
DAGs.  To obtain an independent DAG with its own node
objects, make a deepcopy of the object that is returned
(see the copy module in the Python standard library for
more information).

Example:

>>> import copy
>>> dag = copy.deepcopy(DAG.select_nodes_by_name(dag, names_to_rerun | dag.get_all_parent_names(names_to_rerun)))

Definition at line 677 of file dagfile.py.

◆ write()

python.dagfile.DAG.write ( self,
f,
progress = None,
rescue = None )
Write the DAG to the file-like object f.  The object must
provide a .write() method.  In the special case that the
optional rescue argument is not None (see below) then f can
be set to None and no DAG file will be written (just the
rescue DAG will be written).

If the progress argument is not None, it should be a
callable object.  This object will be called periodically
and passed the f argument, the current line number, and a
boolean indicating if writing is complete.  The boolean is
always False until writing is complete, then the callable
will be invoked one last time with the final line count and
the boolean set to True.

Example:

>>> def progress(f, n, done):
... print "writing %s: %d lines\\r" % (f.name, n),
... if done:
...     print
...
>>> dag.write(open("pipeline.dag", "w"), progress = progress)

NOTE:  when writing PARENT/CHILD graph edges, this method
will silently skip any node names that are not in this
DAG's graph.  This is a convenience to simplify writing
DAGs constructed by the .select_nodes_by_name() class
method.  If one wishes to check for broken parent/child
links before writing the DAG use the .check_edges() method.

If the optional rescue argument is not None, it must be a
file-like object providing a .write() method and the DONE
state of jobs will be written to this file instead of the
.dag (in the .dag all jobs will be marked not done).

Example:

>>> dag.write(open("pipeline.dag", "w"), rescue = open("pipeline.dag.rescue001", "w"))

NOTE:  it is left as an exercise for the calling code to
ensure the name chosen for the rescue file is consistent
with the naming convention assumed by condor_dagman when it
starts up.

Definition at line 832 of file dagfile.py.

Member Data Documentation

◆ abortdagonpat

python.dagfile.DAG.abortdagonpat = re.compile(r'^ABORT-DAG-ON\s+(?P<name>\S+)\s+(?P<exitvalue>\S+)(\s+RETURN\s+(?P<returnvalue>\S+))?', re.IGNORECASE)
static

Definition at line 373 of file dagfile.py.

◆ arcpat

python.dagfile.DAG.arcpat = re.compile(r'^PARENT\s+(?P<parents>.+?)\s+CHILD\s+(?P<children>.+)', re.IGNORECASE)
static

Definition at line 374 of file dagfile.py.

◆ categorypat

python.dagfile.DAG.categorypat = re.compile(r'^CATEGORY\s+(?P<name>\S+)\s+(?P<category>\S+)', re.IGNORECASE)
static

Definition at line 368 of file dagfile.py.

◆ config

python.dagfile.DAG.config = config

Definition at line 427 of file dagfile.py.

◆ configpat

python.dagfile.DAG.configpat = re.compile(r'^CONFIG\s+(?P<filename>\S+)', re.IGNORECASE)
static

Definition at line 376 of file dagfile.py.

◆ datapat

python.dagfile.DAG.datapat = re.compile(r'^DATA\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?(\s+(?P<noop>NOOP))?(\s+(?P<done>DONE))?', re.IGNORECASE)
static

Definition at line 364 of file dagfile.py.

◆ donepat

python.dagfile.DAG.donepat = re.compile(r'^DONE\s+(?P<name>\S+)', re.IGNORECASE)
static

Definition at line 384 of file dagfile.py.

◆ dot

python.dagfile.DAG.dot = dot

Definition at line 428 of file dagfile.py.

◆ dotinclude

python.dagfile.DAG.dotinclude = dotinclude

Definition at line 431 of file dagfile.py.

◆ dotoverwrite

bool python.dagfile.DAG.dotoverwrite = dotoverwrite

Definition at line 430 of file dagfile.py.

◆ dotpat

python.dagfile.DAG.dotpat = re.compile(r'^DOT\s+(?P<filename>\S+)(\s+(?P<options>.+))?', re.IGNORECASE)
static

Definition at line 362 of file dagfile.py.

◆ dotupdate

bool python.dagfile.DAG.dotupdate = dotupdate

Definition at line 429 of file dagfile.py.

◆ jobpat

python.dagfile.DAG.jobpat = re.compile(r'^JOB\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?(\s+(?P<noop>NOOP))?(\s+(?P<done>DONE))?', re.IGNORECASE)
static

Definition at line 363 of file dagfile.py.

◆ jobstate_log

python.dagfile.DAG.jobstate_log = jobstate_log

Definition at line 434 of file dagfile.py.

◆ jobstatepat

python.dagfile.DAG.jobstatepat = re.compile(r'^JOBSTATE_LOG\s+(?P<filename>\S+)', re.IGNORECASE)
static

Definition at line 378 of file dagfile.py.

◆ maxjobs

python.dagfile.DAG.maxjobs = maxjobs

Definition at line 426 of file dagfile.py.

◆ maxjobspat

python.dagfile.DAG.maxjobspat = re.compile(r'^MAXJOBS\s+(?P<category>\S+)\s+(?P<value>\S+)', re.IGNORECASE)
static

Definition at line 375 of file dagfile.py.

◆ node_status_file

python.dagfile.DAG.node_status_file = node_status_file

Definition at line 432 of file dagfile.py.

◆ node_status_file_updatetime

python.dagfile.DAG.node_status_file_updatetime = node_status_file_updatetime

Definition at line 433 of file dagfile.py.

◆ nodes

python.dagfile.DAG.nodes = nodes

Definition at line 425 of file dagfile.py.

◆ nodestatuspat

python.dagfile.DAG.nodestatuspat = re.compile(r'^NODE_STATUS_FILE\s+(?P<filename>\S+)(\s+(?P<updatetime>\S+))?', re.IGNORECASE)
static

Definition at line 377 of file dagfile.py.

◆ prioritypat

python.dagfile.DAG.prioritypat = re.compile(r'^PRIORITY\s+(?P<name>\S+)\s+(?P<value>\S+)', re.IGNORECASE)
static

Definition at line 367 of file dagfile.py.

◆ retrypat

python.dagfile.DAG.retrypat = re.compile(r'^RETRY\s+(?P<name>\S+)\s+(?P<retries>\S+)(\s+UNLESS-EXIT\s+(?P<retry_unless_exit_value>\S+))?', re.IGNORECASE)
static

Definition at line 369 of file dagfile.py.

◆ scriptpat

python.dagfile.DAG.scriptpat = re.compile(r'^SCRIPT\s+(?P<type>(PRE)|(POST))\s(?P<name>\S+)\s+(?P<executable>\S+)(\s+(?P<arguments>.+))?', re.IGNORECASE)
static

Definition at line 372 of file dagfile.py.

◆ splicepat

python.dagfile.DAG.splicepat = re.compile(r'^SPLICE\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?', re.IGNORECASE)
static

Definition at line 366 of file dagfile.py.

◆ subdagpat

python.dagfile.DAG.subdagpat = re.compile(r'^SUBDAG\s+EXTERNAL\s+(?P<name>\S+)\s+(?P<filename>\S+)(\s+DIR\s+(?P<directory>\S+))?(\s+(?P<noop>NOOP))?(\s+(?P<done>DONE))?', re.IGNORECASE)
static

Definition at line 365 of file dagfile.py.

◆ varspat

python.dagfile.DAG.varspat = re.compile(r'^VARS\s+(?P<name>\S+)\s+(?P<vars>.+)', re.IGNORECASE)
static

Definition at line 370 of file dagfile.py.

◆ varsvaluepat

python.dagfile.DAG.varsvaluepat = re.compile(r'(?P<name>\S+)\s*=\s*"(?P<value>.*?)(?<!\\‍)"', re.IGNORECASE)
static

Definition at line 371 of file dagfile.py.


The documentation for this class was generated from the following file: