ryvencore.Node module - ryvencore v0.1.0 documentation

Hide navigation sidebar
Hide table of contents sidebar
Toggle table of contents sidebar

# ryvencore.Node module

class Node(params)

  Bases: `ryvencore.Base.Base`

  Base class for all node blueprints. Such a blueprint is made by subclassing this class and registering that subclass in the session. Actual node objects are instances of it. The node’s static properties are static attributes, which works really well in Python.

  static title

    the node’s title

  static type_

    conditional type field

  static tags

    a list of tag strings, usually for searching

  static version

    version tag, use it!

  static init_inputs

    initial inputs list. the type BP in NodeInputBP stands for ‘blueprint’, as they only serve as containers, the actual input objects will be created later

  static init_outputs

    initial outputs list, see init_inputs

  static identifier

    unique node identifier string. if not given, the session will set it to the class name on register

  static identifier_comp

    a list of compatible identifiers, useful if you change the class name (and hence the identifier) to provide backward compatibility to older projects

  title = ''
  type_ = ''
  tags: List[str] = []
  version: str = None
  visible: bool = True
  init_inputs: List[ryvencore.NodePortBP.NodeInputBP] = []
  init_outputs: List[ryvencore.NodePortBP.NodeOutputBP] = []
  identifier: str = None
  identifier_comp: List[str] = []
  identifier_prefix: str = None

    INITIALIZATION —————————————————————————————————–

  classmethod build_identifier()

    sets the identifier to class name if it’s not set, and adds the identifier prefix

  initialize()

    Loads all default properties from initial data if it was provided, sets up inputs and outputs, enables the logs, and loads user_data (doesn’t crash on exception here as this is not uncommon when developing nodes).

  setup_ports(inputs_data=None, outputs_data=None)
  after_placement()

    Called from Flow when the nodes gets added

  prepare_removal()

    Called from Flow when the node gets removed

  update(inp=- 1)

    ‘Activates’ the node, causing an update_event(); prints an exception if something crashed, but prevents the application from crashing in such a case

  input(index: int)

    Returns the value of a data input. If the input is connected, the value of the connected output is used: If not, the value of the widget is used.

  exec_output(index: int)

    Executes an exec output, causing activation of all connections

  set_output_val(index, val)

    Sets the value of a data output causing activation of all connections in data mode

  update_event(inp=- 1)

    Gets called when an input received a signal or some node requested data of an output in exec mode

  place_event()

    place_event() is called once the node object has been fully initialized and placed in the flow. When loading content, place_event() is executed before the connections are built, which is important for nodes that need to update once and, during this process, set output data values, to prevent later connected (potentially sequential) nodes from receiving false updates because of that. Notice that this method gets executed every time the node is added to the flow, which can happen multiple times for the same object, for example due to undo/redo operations. Also note that GUI content is usually not accessible yet from here, for that use view_place_event().

  view_place_event()

    Called once all GUI for the node has been created by the frontend, if one exists. Any initial communication to widgets is supposed to happen here, and this method is not called when running without gui.

  remove_event()

    Called when the node is removed from the flow; useful for stopping threads and timers etc.

  additional_data() → dict

    Additional_data()/load_additional_data() is almost equivalent to get_state()/set_state(), but it’s often useful for frontends to have their own, get_state()/set_state() then stays clean for all specific node subclasses

  load_additional_data(data: dict)

    For loading the data returned by additional_data()

  get_state() → dict

    Used to store node-specific custom data that needs to be reloaded when loading a project or pasting copied components. All values will be serialized by pickle and base64. The corresponding method for the opposite operation is set_state().

  set_state(data: dict, version)

    Used for reloading node-specific custom data which has been previously returned by get_state()

  new_logger(title) → ryvencore.logging.Logger.Logger

    Requesting a new custom Log

  disable_loggers()

    Disables custom logs

  enable_loggers()

    Enables custom logs

  create_input(label: str = '', type_: str = 'data', add_data={}, insert: Optional[int] = None)

    Creates and adds a new input at index pos

  create_input_dt(dtype: ryvencore.dtypes.dtypes.DType, label: str = '', add_data={}, insert: Optional[int] = None)

    Creates and adds a new data input with a DType

  rename_input(index: int, label: str)
  delete_input(index: int)

    Disconnects and removes input

  create_output(label: str = '', type_: str = 'data', insert: Optional[int] = None)

    Creates and adds a new output

  rename_output(index: int, label: str)
  delete_output(index: int)

    Disconnects and removes output

  get_vars_manager()

    Returns a ref to the script’s variables manager

  get_var_val(name: str)

    Gets the value of a script variable

  set_var_val(name: str, val)

    Sets the value of a script variable

  register_var_receiver(name: str, method)

    Registers the node with given method as vars receiver in the script’s variables manager to catch value changes of any variable with the given name

  unregister_var_receiver(name: str, method)

    Unregisters previously registered node as receiver for value changes of script variables with given name

  is_active()
  flow_in_data_opt_mode()
  data() → dict

    Returns all metadata of the node in JSON-compatible dict. Used to rebuild the Flow when loading a project or pasting components.