loki.batch.sgraph
Classes
|
The dependency graph underpinning the |
- class SGraph
Bases:
object
The dependency graph underpinning the
Scheduler
It is built upon a
networkx.DiGraph
to expose the dependencies betweenItem
nodes. It is typically created from one or multiple seed items viafrom_seed()
by recursively chasing dependencies.Cyclic dependencies are broken for procedures that are marked as
RECURSIVE
, which would otherwise constitute a dependency on itself. See_break_cycles()
.- classmethod from_seed(seed, item_factory, config=None)
Create a new
SGraph
usingseed
as starting point.- Parameters:
seed ((list of) str) – The names of the root nodes
item_factory (
ItemFactory
) – The item factory to use when creating graph nodesconfig (
SchedulerConfig
, optional) – The config object to use when creating items
- as_filegraph(item_factory, config=None, item_filter=None, exclude_ignored=False)
Convert the
SGraph
to a dependency graph that only containsFileItem
nodes.- Parameters:
item_factory (
ItemFactory
) – The item factory to use when creating graph nodesconfig (
SchedulerConfig
, optional) – The config object to use when creating itemsitem_filter (list of
Item
subclasses, optional) – Only include files that include at least one dependency item of the given type. By default, all items are included.exclude_ignored (bool, optional) – Exclude
Item`s that have the ``is_ignored`
property
- Returns:
A new graph object
- Return type:
- property dependencies
Return all dependencies, i.e., edges of the dependency graph
- successors(item, item_filter=None)
Return the list of successor nodes in the dependency tree below
Item
This returns all immediate successors (but can be filtered accordingly using the item’s
targets
property) of the item in the dependency graphThe list of successors is provided to transformations during processing with the
Scheduler
.- Parameters:
item (
Item
) – The item node in the dependency graph for which to determine the successorsitem_filter (list of
Item
subclasses, optional) – Filter successor items to only include items of the provided type. By default, all items are considered. Note that includingProcedureItem
in theitem_filter
automatically addsProcedureBindingItem
andInterfaceItem
as well, since these are intermediate nodes. Their dependencies will also be included until they eventually resolve to aProcedureItem
.
- property depths
Return a mapping of
Item
nodes to their depth (topological generation) in the dependency graph
- add_node(item)
Add
item
as a node to the dependency graph
- add_edge(edge)
Add a dependency
edge
to the dependency graph
- add_edges(edges)
Add the dependency
edges
to the dependency graph
- export_to_file(dotfile_path)
Generate a dotfile from the current graph
- Parameters:
dotfile_path (str or pathlib.Path) – Path to write the dotfile to. A corresponding graphical representation will be created with an additional
.pdf
appendix.