Graph Scheduler
A graph scheduler generates the order in which the nodes of a directed acyclic graph (DAG) are executed using the structure of the graph and expressive conditions. Specifically, a scheduler uses a topological ordering of the nodes as a base sequence of execution and further restricts execution based on predefined or custom conditions provided by the user. Patterns of execution are linked to abstract units of time and may optionally be mapped to real time units using pint.
Documentation is available on github-pages for the current
release and for the
current main
branch. For
prior releases, go to
https://kmantel.github.io/graph-scheduler/tag/<tag_name>
.
Installation
Install from pypi:
pip install graph-scheduler
Example
The graph is specified here in dependency dictionary format, but networkx Digraphs are also supported.
>>> import graph_scheduler
>>> graph = {
'A': set(),
'B': {'A'},
'C': {'A'},
'D': {'B', 'C'},
}
>>> sched = graph_scheduler.Scheduler(graph=graph)
>>> sched.add_condition('C', graph_scheduler.EveryNCalls('A', 2))
>>> sched.add_condition('D', graph_scheduler.EveryNCalls('C', 2))
>>> print(list(sched.run()))
[{'A'}, {'B'}, {'A'}, {'C', 'B'}, {'A'}, {'B'}, {'A'}, {'C', 'B'}, {'D'}]
Contents:
- Graph Scheduler
- Scheduler
- Condition
- Overview
- Creating Conditions
- Structure
- Execution
- Class Reference
Operation
ConditionSet
ConditionBase
Condition
AbsoluteCondition
While
WhileNot
Always
Never
CompositeCondition
All
Any
And
Or
Not
NWhen
TimeInterval
TimeTermination
BeforeConsiderationSetExecution
AtConsiderationSetExecution
AfterConsiderationSetExecution
AfterNConsiderationSetExecutions
BeforePass
AtPass
AfterPass
AfterNPasses
EveryNPasses
BeforeEnvironmentStateUpdate
AtEnvironmentStateUpdate
AfterEnvironmentStateUpdate
AfterNEnvironmentStateUpdates
AtEnvironmentSequence
AfterEnvironmentSequence
AfterNEnvironmentSequences
BeforeNCalls
AtNCalls
AfterCall
AfterNCalls
AfterNCallsCombined
EveryNCalls
JustRan
AllHaveRun
WhenFinished
WhenFinishedAny
WhenFinishedAll
AtEnvironmentStateUpdateStart
AtEnvironmentStateUpdateNStart
AtEnvironmentSequenceStart
AtEnvironmentSequenceNStart
Threshold
GraphStructureCondition
CustomGraphStructureCondition
BeforeNodes
BeforeNode
WithNode
AfterNodes
AfterNode
AddEdgeTo
RemoveEdgeFrom
- Time