Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for caching an arbitrary path to a virtual environment #276

Open
lijok opened this issue Nov 19, 2021 · 1 comment
Open

Support for caching an arbitrary path to a virtual environment #276

lijok opened this issue Nov 19, 2021 · 1 comment
Labels
feature request New feature or request to improve the current logic

Comments

@lijok
Copy link

lijok commented Nov 19, 2021

Description:
Would be great if an arbirary path to a virtual environment could be cached, instead of / in addition to the default pip and pipenv caching behaviours.

Justification:
Using actions/cache@v2 and actions/setup-python@v1 we would cache our venvs like so:

      - name: setup python
        id: python_setup
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python_version }}

      - name: cache dependencies
        uses: actions/cache@v2
        with:
          path: ./.venv
          key: python-${{ steps.python_setup.outputs.python-version }}-${{ hashFiles('setup.cfg') }}

A major cause of irritation with this is having to figure out what the cache key should be, resulting in every repo having a different one. So, I was very glad when I saw that actions/setup-python@v2 supports caching out of the box, figuring out the cache key itself, and we can ditch the cache action altogether
However, looking at the code it appears that the caching behaviour here is different

Using:

      - name: setup python
        id: python_setup
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python_version }}
          cache: pip
          cache-dependency-path: setup.cfg

my understanding is that the pip global cache is what's being cached
Meaning, when we run python3 -m venv .venv && . .venv/bin/activate && python3 -m pip install ., although pip no longer has to download the dependencies, because they're cached, it still has to make api calls against upstream to check that local cached dependency hashes match upstream
Overall, in our tests, for a small-ish repo with 75 dependencies total, totaling cache size of 30MB, our setup step with the old caching method would take 1-2s, whereas with v2 it takes about 50s

Are you willing to submit a PR?

Yes, if a design is proposed

@lijok lijok added feature request New feature or request to improve the current logic needs triage labels Nov 19, 2021
@nikita-bykov
Copy link
Contributor

nikita-bykov commented Nov 22, 2021

Hello @lijok!
Thanks for your feature request. We will look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

No branches or pull requests

3 participants