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

Method _to_schema

reflex/state.py:2120–2141  ·  view source on GitHub ↗

Convert a state to a schema. Returns: The hash of the schema.

(cls)

Source from the content-addressed store, hash-verified

2118 @classmethod
2119 @functools.lru_cache
2120 def _to_schema(cls) -> str:
2121 """Convert a state to a schema.
2122
2123 Returns:
2124 The hash of the schema.
2125 """
2126
2127 def _field_tuple(
2128 field_name: str,
2129 ) -> tuple[str, Any, Any]:
2130 model_field = cls.__fields__[field_name]
2131 return (
2132 field_name,
2133 _serialize_type(model_field.type_),
2134 (model_field.default if is_serializable(model_field.default) else None),
2135 )
2136
2137 return md5(
2138 pickle.dumps(
2139 sorted(_field_tuple(field_name) for field_name in cls.base_vars)
2140 )
2141 ).hexdigest()
2142
2143 def _serialize(self) -> bytes:
2144 """Serialize the state for redis.

Callers 2

_serializeMethod · 0.95
_deserializeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected