Skip to content

Node api

Node API

In hyrrokkin, nodes are implemented using a python class which implements methods described in hyrrokkin_engine.node_interface.NodeInterface:

NodeInterface

Source code in hyrrokkin_engine/node_interface.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class NodeInterface:

    @abstractmethod
    def __init__(self, services: NodeServiceInterface):
        """
        Create an instance of this Node

        Args:
            services: an object providing useful services, for example to get or set property values
        """
        pass

    @abstractmethod
    def reset_run(self):
        """
        Called when this instance's node is about to be re-run
        """
        pass

    @abstractmethod
    def open_client(self, session_id:str, client_name:str, client_options:dict, client_service:ClientServiceInterface):
        """
        Called when a client is attached to the node

        Arguments:
            session_id: a unique identifier for the session
            client_name: the name of the client being opened
            client_options: a set of parameters accompanying the connection
            client_service: a service instance allowing messages to be sent to and recieved from the client
        """
        pass

    @abstractmethod
    def close_client(self, session_id:str, client_name:str):
        """
        Called when a client is detached from the node

        Arguments:
            session_id: a unique identifier for the session
            client_name: the name of the client being closed

        Notes:
            a call to close_client is preceeded by a call to open_client with the same session_id and client_name
        """
        pass

    @abstractmethod
    async def run(self, inputs: Dict[str,List[Any]]) -> Dict[str,Any]:
        """
        Called when a node should transform input values into output values

        Arguments:
            inputs: a dictionary mapping input port names to a list of values being presented at that import port

        Returns:
            a dictionary mapping output port names to a value output on that port
        """
        pass

    @abstractmethod
    def close(self):
        """
        Called before the node instance is deleted
        """
        pass

__init__(services) abstractmethod

Create an instance of this Node

Parameters:

Name Type Description Default
services NodeServiceInterface

an object providing useful services, for example to get or set property values

required
Source code in hyrrokkin_engine/node_interface.py
30
31
32
33
34
35
36
37
38
@abstractmethod
def __init__(self, services: NodeServiceInterface):
    """
    Create an instance of this Node

    Args:
        services: an object providing useful services, for example to get or set property values
    """
    pass

close() abstractmethod

Called before the node instance is deleted

Source code in hyrrokkin_engine/node_interface.py
87
88
89
90
91
92
@abstractmethod
def close(self):
    """
    Called before the node instance is deleted
    """
    pass

close_client(session_id, client_name) abstractmethod

Called when a client is detached from the node

Parameters:

Name Type Description Default
session_id str

a unique identifier for the session

required
client_name str

the name of the client being closed

required
Notes

a call to close_client is preceeded by a call to open_client with the same session_id and client_name

Source code in hyrrokkin_engine/node_interface.py
60
61
62
63
64
65
66
67
68
69
70
71
72
@abstractmethod
def close_client(self, session_id:str, client_name:str):
    """
    Called when a client is detached from the node

    Arguments:
        session_id: a unique identifier for the session
        client_name: the name of the client being closed

    Notes:
        a call to close_client is preceeded by a call to open_client with the same session_id and client_name
    """
    pass

open_client(session_id, client_name, client_options, client_service) abstractmethod

Called when a client is attached to the node

Parameters:

Name Type Description Default
session_id str

a unique identifier for the session

required
client_name str

the name of the client being opened

required
client_options dict

a set of parameters accompanying the connection

required
client_service ClientServiceInterface

a service instance allowing messages to be sent to and recieved from the client

required
Source code in hyrrokkin_engine/node_interface.py
47
48
49
50
51
52
53
54
55
56
57
58
@abstractmethod
def open_client(self, session_id:str, client_name:str, client_options:dict, client_service:ClientServiceInterface):
    """
    Called when a client is attached to the node

    Arguments:
        session_id: a unique identifier for the session
        client_name: the name of the client being opened
        client_options: a set of parameters accompanying the connection
        client_service: a service instance allowing messages to be sent to and recieved from the client
    """
    pass

reset_run() abstractmethod

Called when this instance's node is about to be re-run

Source code in hyrrokkin_engine/node_interface.py
40
41
42
43
44
45
@abstractmethod
def reset_run(self):
    """
    Called when this instance's node is about to be re-run
    """
    pass

run(inputs) abstractmethod async

Called when a node should transform input values into output values

Parameters:

Name Type Description Default
inputs Dict[str, List[Any]]

a dictionary mapping input port names to a list of values being presented at that import port

required

Returns:

Type Description
Dict[str, Any]

a dictionary mapping output port names to a value output on that port

Source code in hyrrokkin_engine/node_interface.py
74
75
76
77
78
79
80
81
82
83
84
85
@abstractmethod
async def run(self, inputs: Dict[str,List[Any]]) -> Dict[str,Any]:
    """
    Called when a node should transform input values into output values

    Arguments:
        inputs: a dictionary mapping input port names to a list of values being presented at that import port

    Returns:
        a dictionary mapping output port names to a value output on that port
    """
    pass