CircleCI-Public / python-orb

Common CircleCI tasks for the Python programming language.
https://circleci.com/developer/orbs/orb/circleci/python
MIT License
13 stars 37 forks source link

feat: add support for partial cache hit #112

Closed tboddyspargo closed 19 hours ago

tboddyspargo commented 1 year ago

Describe Request:

Currently, the only restore_cache key is the full key including the lockfile hash. As a result, if any package in the lockfile changes, no cache will be available to the install step at all. This can be fairly impactful as significant time could be saved if the pypi-cache or the venv-cache was available so that unchanged dependencies wouldn't have to be re-downloaded, rebuilt, and/or re-installed.

I would love it if you could add the option to include cache key prefixes in the restore-cache step to enable this performance and time saver.

Examples:

In this example, one key represents a version prefix, the python version checksum, and the lockfile checksum. The other includes only the version prefix and the python version checksum. The cache would be updated/saved every time the lockfile, python version, or version prefix changed, but there would still be cache hits even if the lockfile had changed.

- restore_cache:
    keys:
      - v9-cci_pycache-bZAMiWuI9QoA2ErSht0XerDW8Sj18wFhkD_+AQFP54Q=-hW4M+yWz96peTRx9JL1x6TLus+SELu6466Ftu5NiKz8=-
      - v9-cci_pycache-bZAMiWuI9QoA2ErSht0XerDW8Sj18wFhkD_+AQFP54Q=

Supporting Documentation Links: