-
Notifications
You must be signed in to change notification settings - Fork 37
Graph Utilities API
github-actions[bot] edited this page Jul 19, 2024
·
1 revision
The main utility functions of CSP are documented here. These functions enable users to execute and visualize graphs.
csp.run(
g,
*args,
starttime=None,
endtime=MAX_END_TIME,
realtime=False,
output_numpy=False,
**kwargs,
):
Runs the graph g
from starttime
to endtime
.
Args:
-
g
: a graph function or CSP node. -
args
: any positional arguments passed tog
. -
starttime
: the engine time that the graph will start at. -
endtime
: the engine time that the graph will end at. Can be adatetime
or atimedelta
. If atimedelta
, the end time is treated as an offset from the start time. -
realtime
: whether the graph runs in realtime versus historical mode. Defaults to historical. -
output_numpy
: if True, will return each output ofg
as a two element tuple of Numpy arrays, one for the times and one for the values. -
kwargs
: any keyword arguments passed tog
.
Returns the outputs of g
in a dictionary where the key is the output name and the value is a list of tuples. Each tuple has two elements, the time of the event and its value.
def run_on_thread(
g,
*args,
starttime=None,
endtime=MAX_END_TIME,
queue_wait_time=None,
realtime=False,
auto_shutdown=False,
daemon=False,
**kwargs,
):
Runs the graph g
on a separate thread.
Args:
See csp.run
for overlapping arguments.
-
auto_shutdown
: if True, the graph will automatically stop and join when the runner goes out scope. Defaults to False. -
daemon
: if True, will launch the thread as a daemon. Defaults to False.
Returns a runner object, which has the following methods:
def join(self, suppress=False):
"""wait for engine thread to finish and return results. If suppress=True, will suppress exceptions."""
def is_alive(self):
"""Checks whether the thread is still running"""
def stop_engine(self):
"""request engine to stop ( async )"""
def show_graph(
graph_func,
*args,
graph_filename=None,
**kwargs,
):
Displays the graph using graphviz
.
Args:
-
graph_func
: a graph function or CSP node. -
args
: any positional arguments passed tograph_func
. -
graph_filename
: a file path to save the image. Default format ispng
butjpg
and others are also supported. -
kwargs
: any keyword arguments passed tograph_func
.
Returns None.
This wiki is autogenerated. To made updates, open a PR against the original source file in docs/wiki
.
Get Started (Tutorials)
Concepts
- CSP Node
- CSP Graph
- Historical Buffers
- Execution Modes
- Adapters
- Feedback and Delayed Edge
- Common Mistakes
How-to guides
- Use Statistical Nodes
- Create Dynamic Baskets
- Write Adapters:
- Profile CSP Code
References
- API Reference
- Glossary of Terms
- Examples
Developer Guide