omnipy.data.snapshot
Snapshot helpers that support change detection for Omnipy data objects.
| CLASS | DESCRIPTION |
|---|---|
SnapshotHolder |
Manage weakly referenced content snapshots for Omnipy models and datasets. |
SnapshotWrapper |
Store a snapshot together with the identity of the source object. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
obj_getattr |
|
obj_setattr |
|
SnapshotHolder
Bases: WeakKeyRefContainer[HasContentT, IsSnapshotWrapper[HasContentT, ContentT]], Generic[HasContentT, ContentT]
flowchart BT
omnipy.data.snapshot.SnapshotHolder[SnapshotHolder]
omnipy.util.weak.WeakKeyRefContainer[WeakKeyRefContainer]
omnipy.util.weak.WeakKeyRefContainer --> omnipy.data.snapshot.SnapshotHolder
click omnipy.data.snapshot.SnapshotHolder href "" "omnipy.data.snapshot.SnapshotHolder"
click omnipy.util.weak.WeakKeyRefContainer href "" "omnipy.util.weak.WeakKeyRefContainer"
Manage weakly referenced content snapshots for Omnipy models and datasets.
The holder keeps snapshot copies alongside memoized deepcopy state so Omnipy can compare current content against prior state without permanently retaining deleted objects.
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
all_are_empty |
Return whether both snapshot storage and deepcopy bookkeeping are empty. |
clear |
Remove all stored snapshots and deepcopy bookkeeping state. |
delete_scheduled_deepcopy_content_ids |
Remove any queued content ids from the deepcopy memo. |
get |
Return the value associated with a live key object. |
get_deepcopy_content_ids |
Return the content ids currently retained by the deepcopy memo. |
get_deepcopy_content_ids_scheduled_for_deletion |
Return the queued content ids that should be pruned from the deepcopy memo. |
in_deepcopy_content_ids |
Return whether |
schedule_deepcopy_content_ids_for_deletion |
Queue deepcopy-tracked content ids for deferred deletion when they are still known. |
take_snapshot |
Capture and store a snapshot of |
take_snapshot_setup |
Disable garbage collection before a snapshot run begins. |
take_snapshot_teardown |
Prune stale deepcopy state and re-enable garbage collection after snapshotting. |
Source code in src/omnipy/data/snapshot.py
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
__init__
all_are_empty
Return whether both snapshot storage and deepcopy bookkeeping are empty.
| PARAMETER | DESCRIPTION |
|---|---|
debug
|
Whether to print detailed internal state before returning.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Source code in src/omnipy/data/snapshot.py
clear
Remove all stored snapshots and deepcopy bookkeeping state.
delete_scheduled_deepcopy_content_ids
Remove any queued content ids from the deepcopy memo.
Source code in src/omnipy/data/snapshot.py
get
Return the value associated with a live key object.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
Key object to look up by identity.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_ValT | None
|
The stored value for the key, or |
Source code in src/omnipy/util/weak.py
get_deepcopy_content_ids
get_deepcopy_content_ids() -> SetDeque[int]
get_deepcopy_content_ids_scheduled_for_deletion
get_deepcopy_content_ids_scheduled_for_deletion() -> SetDeque[int]
Return the queued content ids that should be pruned from the deepcopy memo.
in_deepcopy_content_ids
schedule_deepcopy_content_ids_for_deletion
Queue deepcopy-tracked content ids for deferred deletion when they are still known.
Source code in src/omnipy/data/snapshot.py
take_snapshot
take_snapshot(obj: HasContentT) -> None
Capture and store a snapshot of obj.content.
The method first tries a memo-aware deepcopy so repeated snapshots can reuse preserved
object fragments efficiently. If that fails, it falls back to plain deepcopy and then
copy.
| PARAMETER | DESCRIPTION |
|---|---|
obj
|
Object whose
TYPE:
|
Source code in src/omnipy/data/snapshot.py
take_snapshot_setup
take_snapshot_teardown
Prune stale deepcopy state and re-enable garbage collection after snapshotting.
SnapshotWrapper
dataclass
Bases: Generic[ObjContraT, ContentT]
flowchart BT
omnipy.data.snapshot.SnapshotWrapper[SnapshotWrapper]
click omnipy.data.snapshot.SnapshotWrapper href "" "omnipy.data.snapshot.SnapshotWrapper"
Store a snapshot together with the identity of the source object.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
TYPE:
|
snapshot |
Copied content captured from that object.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
differs_from |
Return whether |
taken_of_same_obj |
Return whether this snapshot was taken from |
Source code in src/omnipy/data/snapshot.py
differs_from
differs_from(obj: ObjContraT) -> bool
taken_of_same_obj
taken_of_same_obj(obj: ObjContraT) -> bool