MCPcopy
hub / github.com/marimo-team/marimo / SideEffect

Class SideEffect

marimo/_runtime/side_effect.py:13–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class SideEffect(CellLifecycleItem):
14 def __init__(self, key: str | bytes) -> None:
15 self._key = key
16
17 @property
18 def key(self) -> bytes:
19 assert self._key is not None
20 if isinstance(self._key, bytes):
21 return self._key
22 return self._key.encode("utf-8")
23
24 @property
25 def hash(self) -> bytes:
26 """Hash the lookup to a consistent size."""
27 return hashlib.sha256(self.key).digest()
28
29 def create(self, context: RuntimeContext | None) -> None:
30 """NoOp for side effect.
31 Typically hook to expose the object to the context, but the existence of
32 the object is enough for side effect tracking.
33 """
34 del context
35
36 def dispose(self, context: RuntimeContext, deletion: bool) -> bool:
37 """Clean up and mark the object for deletion"""
38 # Side effects can always be disposed since they are just a cell level
39 # marker that some event has occurred.
40 del context
41 del deletion
42 return True
43
44
45class CellHash(CellLifecycleItem):

Callers 5

__call__Method · 0.90
_execute_cachedMethod · 0.90
__exit__Method · 0.90
write_side_effectFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…