Delegate cache key calculation to CacheKeyController objects
Description
Cache key generation in Element is currently done inside _update_state(), which is intricate and hard to understand.
This commit is hopefully a step towards making it more understandable and easier to split up.
Changes proposed in this merge request:
- Element now owns a
__strict_cache_key_objand__cache_key_obj, instead of storing cache keys itself. - A base class
CacheKeyControllerexists, with implementationsStrictCacheKeyControllerandNonStrictCacheKeyController -
StrictCacheKeyControllerandNonStrictCacheKeyControllerobjects exist that perform cache key calculation and hold cache keys - In strict mode, the
__strict_cache_key_objand__cache_key_objare the same object. -
Element._calculate_cache_keyhas been replaced byElement._get_cache_key_dict, deferring the cache key calculation logic to theCacheKeyController.- In doing so, it has grown an ugly workaround for handling the ArtifactElement - it needs special treatment now we're not expecting Elements to generate their own keys. To remove the workaround would require leaving the cache key calculation logic inside the Element, or removing the ArtifactElement (which, as I understand it, was a temporary workaround for the Artifact class).
-
Element._get_strong_key_from_artifact()has been added, because now the CacheKeyController needs to get information from the Element's Artifact. -
Element._get_strict_cache_keyhas been added, because now the StrictCacheKeyController needs to get the strict keys of an element's dependencies from outside of theElementclass.
This merge request is part of #902 (closed), but will not close it.