WIP
LoggingAddon
[source]¶Bases: AddOn
This addon implements very basic some logging functionality.
It provides an API to create and delete loggers that are owned by a particular node. The logger gets enabled/disabled automatically when the owning node is added to/removed from the flow.
Ownership might eventually be expanded to any component that preserves its global ID throughout save and load.
The contents of logs are currently not preserved. If a log’s content should be preserved, it should be saved in a file.
Refer to Python’s logging module documentation.
name
= 'Logging'¶version
= '0.0.1'¶Variable
(addon, flow, name='', val=None, data=None)[source]¶Bases: object
Implementation of flow variables
VarsAddon
[source]¶Bases: AddOn
This addon provides a simple variable system.
It provides an API to create Variable objects which can wrap any Python object.
Nodes can subscribe to variable names with a callback that is executed once a variable with that name changes or is created. The callback must be a method of the node, so the subscription can be re-established on loading.
This way nodes can react to changes of data and non-trivial data-flow is introduced, meaning that data dependencies are determined also by variable subscriptions and not purely by the edges in the graph anymore. This can be useful, but it can also prevent optimization. Variables are flow-local.
>>> import ryvencore as rc
>>>
>>> class MyNode(rc.Node):
... init_outputs = []
...
... def __init__(self, params):
... super().__init__(params)
...
... self.Vars = self.get_addon('Variables')
... self.var_val = None
...
... def place_event(self):
... self.Vars.subscribe(self, 'var1', self.var1_changed)
... self.var_val = self.Vars.var(self.flow, 'var1').get()
...
... def var1_changed(self, val):
... print('var1 changed!')
... self.var_val = val
>>>
>>> s = rc.Session()
>>> s.register_node(MyNode)
>>> f = s.create_flow('main')
>>>
>>> Vars = s.addons['Variables']
>>> v = Vars.create_var(f, 'var1', None)
>>>
>>> n1 = f.create_node(MyNode)
>>> v.set(42)
var1 changed!
>>> print(n1.var_val)
42
name
= 'Variables'¶version
= '0.0.3'¶var_name_valid
(flow, name: str) bool [source]¶Checks if name
is a valid variable identifier and hasn’t been take yet.
create_var
(flow, name: str, val=None, data=None) Optional[Variable] [source]¶Creates and returns a new variable and None if the name isn’t valid.
delete_var
(flow, name: str)[source]¶Deletes a variable and causes subscription update. Subscriptions are preserved.