Skip to content

Commit

Permalink
Fix not cached virtualenv (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdvllrs authored Apr 11, 2024
1 parent 877291e commit 93c4f1b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 99 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/docs-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ jobs:
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
- name: Poetry config
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config installer.parallel true
- name: Update torch's source to use CPU
run: |
poetry source add torch-cpu --priority=explicit --no-interaction https://download.pytorch.org/whl/cpu
torch_version=$(poetry show torch --no-ansi | sed -n 2p | sed 's/^\(\s*\)version\(\s*\):\(\s*\)\([0-9\.\+a-zA-Z]*\)\(.*\)$/\4/')
poetry add --lock --no-interaction --source torch-cpu "torch@$torch_version"
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
Expand All @@ -34,11 +44,7 @@ jobs:
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry source add torch-cpu --priority=explicit https://download.pytorch.org/whl/cpu
torch_version=$(poetry show torch --no-ansi | sed -n 2p | sed 's/^\(\s*\)version\(\s*\):\(\s*\)\([0-9\.\+a-zA-Z]*\)\(.*\)$/\4/')
poetry add --source torch-cpu "torch@$torch_version"
poetry install --with test,dev,docs
run: poetry install --no-interaction --with test,dev,docs
- name: Create new branch
run: |
git config user.name "github-actions"
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ jobs:
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
- name: Poetry config
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config installer.parallel true
- name: Update torch's source to use CPU
run: |
poetry source add torch-cpu --priority=explicit --no-interaction https://download.pytorch.org/whl/cpu
torch_version=$(poetry show torch --no-ansi | sed -n 2p | sed 's/^\(\s*\)version\(\s*\):\(\s*\)\([0-9\.\+a-zA-Z]*\)\(.*\)$/\4/')
poetry add --lock --no-interaction --source torch-cpu "torch@$torch_version"
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
Expand All @@ -33,11 +43,7 @@ jobs:
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry source add torch-cpu --priority=explicit https://download.pytorch.org/whl/cpu
torch_version=$(poetry show torch --no-ansi | sed -n 2p | sed 's/^\(\s*\)version\(\s*\):\(\s*\)\([0-9\.\+a-zA-Z]*\)\(.*\)$/\4/')
poetry add --source torch-cpu "torch@$torch_version"
poetry install --with test,dev,docs
run: poetry install --no-interaction --with test,dev,docs
- run: poetry run python ./docs/make.py
- uses: actions/upload-pages-artifact@v3
with:
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ jobs:
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Poetry config
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config installer.parallel true
- name: Update torch's source to use CPU
run: |
poetry source add torch-cpu --priority=explicit --no-interaction https://download.pytorch.org/whl/cpu
torch_version=$(poetry show torch --no-ansi | sed -n 2p | sed 's/^\(\s*\)version\(\s*\):\(\s*\)\([0-9\.\+a-zA-Z]*\)\(.*\)$/\4/')
poetry add --lock --no-interaction --source torch-cpu "torch@$torch_version"
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
Expand All @@ -37,18 +43,12 @@ jobs:
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry source add torch-cpu --priority=explicit https://download.pytorch.org/whl/cpu
torch_version=$(poetry show torch --no-ansi | sed -n 2p | sed 's/^\(\s*\)version\(\s*\):\(\s*\)\([0-9\.\+a-zA-Z]*\)\(.*\)$/\4/')
poetry add --source torch-cpu "torch@$torch_version"
poetry install --with test,dev,docs
run: poetry install --no-interaction --with test,dev,docs
- name: Ruff Formatting
run: poetry run ruff format --check
- name: Ruff Linter
run: poetry run ruff check
- name: Analysing the code with mypy
run: |
poetry run mypy --install-types --non-interactive .
run: poetry run mypy --install-types --non-interactive .
- name: Test with pytest
run: |
poetry run pytest tests/
run: poetry run pytest tests/
101 changes: 25 additions & 76 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ types-pywin32 = "^306.0.0.2"
types-setuptools = "^67.8.0.0"
types-tabulate = "^0.9.0.2"
types-dataclasses = "^0.6.6"
types-pyyaml = "^6.0.12.20240311"
mypy = "^1.4.0"
ruff = "^0.3.0"
pre-commit = "^3.6.2"
types-protobuf = "^4.25.0.20240410"

[tool.poetry.group.test.dependencies]
pytest = "^7.3.2"
Expand Down

0 comments on commit 93c4f1b

Please sign in to comment.