aazuspan / eerepr

Interactive Code Editor-style reprs for Earth Engine objects in a Jupyter notebook
MIT License
34 stars 1 forks source link

Fix caching bug on ee.List.shuffle(seed=False) #7

Closed aazuspan closed 1 year ago

aazuspan commented 1 year ago

As explained in #6, ee.List.shuffle(seed=False) is non-deterministic and therefore returns different results from the same serialized object. This is (arguably) an underlying issue in the Earth Engine API. To prevent incorrect cache hits that would display the same data for differently shuffled lists (and objects built from shuffled lists), this PR adds a check against the serialized object. If ee.List.shuffle(seed=False) was used to construct the object, a randomized _eerepr_id attr is added to the object, causing equality checks (ee.ComputedObject.__eq__) to fail and the cache to miss.

To accomplish that, we had to slightly change the repr setup by wrapping the cached repr generation function _repr_html_ in an uncached _ee_repr function where the deterministic check takes place.

Close #6