echo.tracker module
- class echo.tracker.AttributeTracker(object: object)
Bases:
objectAttribute Tracker
Each checkpoint records all the attributes on the object at the checkpoint.
Therefore to see which attributes were added between two checkpoints, we need to calculate the difference, which we can do with the diff method.
Usage: >>> class Foo(object): … pass … >>> foo = Foo() >>> tracker = AttributeTracker() >>> tracker.track(foo, “init”) >>> foo.a = 1 >>> tracker.track(foo, “setting-a”) >>> tracker.diff(“setting-a”, “init”) >>> attrs = tracker.filtered_pairwise_attributes(include: lambda prev_k, k: k==”checkpoint-of-interest”) >>> tracker.to_html_string(foo, “setting-a”)
- diff(checkpoint1: str, checkpoint2: str) list[str]
Returns the attributes that are present at checkpoint2 but not a checkpoint1.
- filtered_pairwise_attributes(include: Callable[[str, str], bool]) dict[str, list[Any]]
Pairwise diff (attributes added to object between consecutive checkpoints). Only including pairs where filter function include(prev_checkpoint, checkpoint) returns True. And groups attributes by type (as class-name string).
Returns a mapping from attribute class name to a list of attributes (by name) belonging to that class.
- mark(checkpoint: str) None
Create a new checkpoint and associate it with the objects attributes.