File size: 563 Bytes
6756386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from dataclasses import dataclass, field


@dataclass
class State:
    graph_state: str = ""
    logs: list[str] = field(default_factory=list)

    def set_graph_state(self, actor: str, value: str) -> None:
        previous_value = self.graph_state
        self.graph_state = value
        self.logs.append(
            f"{actor}: graph_state changed from {previous_value!r} to {value!r}"
        )

    def log_node_end(self, node_name: str) -> None:
        self.logs.append(
            f"{node_name}: finished with graph_state={self.graph_state!r}"
        )