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

Install python packages into venvs across workflows. #640

Merged
merged 10 commits into from
Dec 5, 2024

Conversation

ScottTodd
Copy link
Member

@ScottTodd ScottTodd commented Dec 3, 2024

Many of these workflows are using persistent self-hosted runners, so it looks like they have been reusing the same system-wide Python environment between workflow runs (plus layer of caching on top). This switches to using venvs at ${{ github.workspace }}/.venv that should be ephemeral, giving us more explicit control over which packages are installed.

More work is planned as part of #584 to refactor these workflows further - replacing the package installs code like pip install --no-compile -r requirements.txt -r sharktank/requirements-tests.txt -e sharktank/ with a setup_venv.py script that uses dev/nightly/stable packages (from an appropriate source).

This also disables pip caching, since that is not directly compatible with using venvs. As a result, some workflows are slower now, but they are more predictable in what they install. Good reading for adding caching back:

@ScottTodd ScottTodd marked this pull request as ready for review December 4, 2024 22:59
@ScottTodd ScottTodd requested a review from stbaione December 4, 2024 23:18
@ScottTodd ScottTodd merged commit 57a7390 into nod-ai:main Dec 5, 2024
8 checks passed
@ScottTodd ScottTodd deleted the workflow-venvs branch December 5, 2024 18:00
monorimet pushed a commit that referenced this pull request Dec 13, 2024
Many of these workflows are using persistent self-hosted runners, so it
looks like they have been reusing the same system-wide Python
environment between workflow runs (plus layer of caching on top). This
switches to using venvs at `${{ github.workspace }}/.venv` that should
be ephemeral, giving us more explicit control over which packages are
installed.

More work is planned as part of
#584 to refactor these
workflows further - replacing the package installs code like `pip
install --no-compile -r requirements.txt -r
sharktank/requirements-tests.txt -e sharktank/` with a `setup_venv.py`
script that uses dev/nightly/stable packages (from an appropriate
source).

This also disables pip caching, since that is not directly compatible
with using venvs. As a result, some workflows are slower now, but they
are more predictable in what they install. Good reading for adding
caching back:
*
https://adamj.eu/tech/2023/11/02/github-actions-faster-python-virtual-environments/
*
https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants