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
93
94
95
96
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
    async def load(self):
        """
        Called after construction.  Load any resources associated with this Node
        """
        pass

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

    @abstractmethod
    async def open_client(self, client:ClientInterface):
        """
        Called when a client is attached to the node

        Arguments:
            client: a service instance allowing messages to be sent to and recieved from the client
        """
        pass

    @abstractmethod
    async def close_client(self, client:ClientInterface):
        """
        Called when a client is detached from the node

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

        Notes:
            a call to close_client is preceeded by a call to open_client with the same parameter
        """
        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
    async def remove(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_client(client) abstractmethod async

Called when a client is detached from the node

Parameters:

Name Type Description Default
client ClientInterface

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

required
Notes

a call to close_client is preceeded by a call to open_client with the same parameter

Source code in hyrrokkin_engine/node_interface.py
65
66
67
68
69
70
71
72
73
74
75
76
@abstractmethod
async def close_client(self, client:ClientInterface):
    """
    Called when a client is detached from the node

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

    Notes:
        a call to close_client is preceeded by a call to open_client with the same parameter
    """
    pass

load() abstractmethod async

Called after construction. Load any resources associated with this Node

Source code in hyrrokkin_engine/node_interface.py
41
42
43
44
45
46
@abstractmethod
async def load(self):
    """
    Called after construction.  Load any resources associated with this Node
    """
    pass

open_client(client) abstractmethod async

Called when a client is attached to the node

Parameters:

Name Type Description Default
client ClientInterface

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

required
Source code in hyrrokkin_engine/node_interface.py
55
56
57
58
59
60
61
62
63
@abstractmethod
async def open_client(self, client:ClientInterface):
    """
    Called when a client is attached to the node

    Arguments:
        client: a service instance allowing messages to be sent to and recieved from the client
    """
    pass

remove() abstractmethod async

Called before the node instance is deleted

Source code in hyrrokkin_engine/node_interface.py
91
92
93
94
95
96
@abstractmethod
async def remove(self):
    """
    Called before the node instance is deleted
    """
    pass

reset_run() abstractmethod async

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

Source code in hyrrokkin_engine/node_interface.py
48
49
50
51
52
53
@abstractmethod
async 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
78
79
80
81
82
83
84
85
86
87
88
89
@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