MCPcopy
hub / github.com/reflex-dev/reflex / load_state

Method load_state

reflex/istate/manager/disk.py:114–131  ·  view source on GitHub ↗

Load a state object based on the provided token. Args: token: The token used to identify the state object. Returns: The loaded state object or None.

(self, token: StateToken[TOKEN_TYPE])

Source from the content-addressed store, hash-verified

112 ).absolute()
113
114 async def load_state(self, token: StateToken[TOKEN_TYPE]) -> TOKEN_TYPE | None:
115 """Load a state object based on the provided token.
116
117 Args:
118 token: The token used to identify the state object.
119
120 Returns:
121 The loaded state object or None.
122 """
123 token_path = self.token_path(token)
124
125 if token_path.exists():
126 try:
127 with token_path.open(mode="rb") as file:
128 return token.deserialize(fp=file)
129 except Exception:
130 pass
131 return None
132
133 async def populate_substates(
134 self, token: BaseStateToken, state: BaseState, root_state: BaseState

Callers 2

populate_substatesMethod · 0.95
get_stateMethod · 0.95

Calls 4

token_pathMethod · 0.95
existsMethod · 0.80
openMethod · 0.80
deserializeMethod · 0.45

Tested by

no test coverage detected