mirror of
https://github.com/hwchase17/langchain
synced 2024-10-27 21:46:30 +00:00
7e63270e04
The previous caching configuration was attempting to cache poetry venvs created in the default shared virtualenvs directory. However, all langchain packages use `in-project = true` for their poetry virtualenv setup, which moves the venv inside the package itself instead. This meant that poetry venvs were not being cached at all. This PR ensures that the venv gets cached by adding the in-project venv directory to the cached directories list. It also makes sure that the cache key *only* includes the lockfile being installed, as opposed to *all lockfiles* (unnecessary cache misses) or just the *top-level lockfile* (cache hits when it shouldn't).
93 lines
2.8 KiB
YAML
93 lines
2.8 KiB
YAML
# An action for setting up poetry install with caching.
|
|
# Using a custom action since the default action does not
|
|
# take poetry install groups into account.
|
|
# Action code from:
|
|
# https://github.com/actions/setup-python/issues/505#issuecomment-1273013236
|
|
name: poetry-install-with-caching
|
|
description: Poetry install with support for caching of dependency groups.
|
|
|
|
inputs:
|
|
python-version:
|
|
description: Python version, supporting MAJOR.MINOR only
|
|
required: true
|
|
|
|
poetry-version:
|
|
description: Poetry version
|
|
required: true
|
|
|
|
install-command:
|
|
description: Command run for installing dependencies
|
|
required: false
|
|
default: poetry install
|
|
|
|
cache-key:
|
|
description: Cache key to use for manual handling of caching
|
|
required: true
|
|
|
|
working-directory:
|
|
description: Directory to run install-command in
|
|
required: false
|
|
default: ""
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- uses: actions/setup-python@v4
|
|
name: Setup python $${ inputs.python-version }}
|
|
with:
|
|
python-version: ${{ inputs.python-version }}
|
|
|
|
- uses: actions/cache@v3
|
|
id: cache-pip
|
|
name: Cache Pip ${{ inputs.python-version }}
|
|
env:
|
|
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "15"
|
|
with:
|
|
path: |
|
|
~/.cache/pip
|
|
key: pip-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}
|
|
|
|
- run: pipx install poetry==${{ inputs.poetry-version }} --python python${{ inputs.python-version }}
|
|
shell: bash
|
|
|
|
- name: Check Poetry File
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
poetry check
|
|
|
|
- name: Check lock file
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
poetry lock --check
|
|
|
|
- name: Set proper Poetry.lock file
|
|
shell: bash
|
|
env:
|
|
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
|
|
run: |
|
|
if [ -f "$WORKDIR/poetry.lock" ]; then
|
|
echo 'Using working directory poetry.lock in cache key'
|
|
cp "$WORKDIR/poetry.lock" poetry-lock.cache-key
|
|
else
|
|
echo 'Using the top-level poetry.lock in cache key'
|
|
cp poetry.lock poetry-lock.cache-key
|
|
fi
|
|
|
|
- uses: actions/cache@v3
|
|
id: cache-poetry
|
|
env:
|
|
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "15"
|
|
with:
|
|
path: |
|
|
~/.cache/pypoetry/virtualenvs
|
|
~/.cache/pypoetry/cache
|
|
~/.cache/pypoetry/artifacts
|
|
${{ inputs.working-directory == '' && '.' || inputs.working-directory }}/.venv
|
|
key: poetry-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}-poetry-${{ inputs.poetry-version }}-${{ inputs.cache-key }}-${{ hashFiles('poetry-lock.cache-key') }}
|
|
|
|
- run: ${{ inputs.install-command }}
|
|
working-directory: ${{ inputs.working-directory }}
|
|
shell: bash
|