List of BaseOperator Methods
When subclassing BaseOperator, you will need to use a set of methods to set callbacks, send messages, etc. The list below summarizes the BaseOperator methods you might need.
- _get_operator_info(self)
- This method should be overridden by a subclass. It should return the OperatorInfo of this operator. OperatorInfo defines some key features of the operator such as port names and other things.
- _init(self)
- This method can be overridden by a subclass. This method will be called after the user definedconfigurations have already been set. This method will be called for all graph's operators before any operator has been started.
- _prestart(self)
- This method can be overridden by a subclass. It should contain code to be executed before the operator's callbacks start being called. The code here should be non-blocking. If it is blocking, the callbacks you have registered will never be called. You are allowed to use the method self._send_message inself._prestart. However, bare in mind that other operators will only receive this data sent when their _prestart have already finished. This is because their callback will only be active after their _prestart have finished
- shutdown(self)
- This method can be overridden by a subclass. It should contain code to be executed after the operator's main loop is finished.
- _send_message(self, port, message)
- Puts an item into an output queue.
- _set_port_callback(self, ports, callback)
- This method associate input 'ports' to the 'callback'. The 'callback' will only be called when there are messages available in all ports in 'ports'. If this method is called multiple times for the same group of ports then the old 'callback' will be replaced by a new one. Different ports group cannot overlap.
- _remove_port_callback(self, callback)
- Remove the 'callback' function. If it doesn't exist, the method will exit quietly.
- _add_periodic_callback(self, callback, milliseconds=0)
- Multiple distinct periodic callbacks can be added. If an already added callback is added again, the period 'milliseconds' will be replaced by the new one. If you want two callbacks with identical behavior to be run simultaneously then you will need to create two different functions with identical body.
- _change_period(self, callback, milliseconds)
- Args:
- _remove_periodic_callback(self, callback)
- Args: