Skip to content

Commit

Permalink
Make conda’s package directories configurable (#328)
Browse files Browse the repository at this point in the history
Co-authored-by: Ken Odegard <kodegard@anaconda.com>
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent 6225267 commit 1a6b55c
Show file tree
Hide file tree
Showing 13 changed files with 2,901 additions and 104 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/caching-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ concurrency:
cancel-in-progress: true

jobs:
caching-example:
caching-ubuntu:
# prevent cronjobs from running on forks
if:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
name: Caching
name: Caching on Ubuntu
runs-on: "ubuntu-latest"
timeout-minutes: 30
steps:
Expand All @@ -35,6 +35,8 @@ jobs:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 2
with:
# Use faster GNU tar
enableCrossOsArchive: true
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
Expand All @@ -45,3 +47,32 @@ jobs:
channel-priority: strict
environment-file: etc/example-environment-caching.yml
use-only-tar-bz2: true
caching-windows:
# prevent cronjobs from running on forks
if:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
name: Caching on Windows
runs-on: "windows-latest"
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Cache conda
uses: actions/cache@v3
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 2
with:
# Use faster GNU tar
enableCrossOsArchive: true
path: D:\conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('etc/example-environment.yml') }}
- uses: ./
with:
activate-environment: anaconda-client-env
channel-priority: strict
environment-file: etc/example-environment-caching.yml
pkgs-dirs: D:\conda_pkgs_dir
- run: conda info
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,45 @@ jobs:
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
```

You may also set conda's package directories (`pkgs_dirs`) config value, if you
want to change setup-miniconda's default of `~/conda_pkgs_dir` with the
`pkgs-dirs` config option. This is a comma-separated string like the channels
config option:

```yaml
jobs:
caching-example:
name: Caching
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v4
- name: Cache conda
uses: actions/cache@v3
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
# Use faster GNU tar
enableCrossOsArchive: true
path: D:\conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('etc/example-environment.yml') }}
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: anaconda-client-env
channel-priority: strict
environment-file: etc/example-environment.yml
pkgs-dirs: D:\conda_pkgs_dir
```

> [!NOTE]
>
> - GitHub hosted Windows runners are currently faster during cache
> decompression when configuring the package directories on the `D:` drive as
> shown above. Make sure to use the `enableCrossOsArchive` cache config option
> as well.

If you are using pip to resolve any dependencies in your conda environment then
you may want to
[cache those dependencies separately](https://docs.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#caching-dependencies),
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ inputs:
for more information.'
required: false
default: ""
pkgs-dirs:
description:
'Conda configuration. Comma separated list of package directories
("pkgs_dirs") to configure conda. See
https://docs.conda.io/projects/conda/en/stable/user-guide/configuration/use-condarc.html#specify-pkg-directories
for more information.'
required: false
default: ""
use-only-tar-bz2:
description:
'Conda configuration. Conda 4.7 introduced a new .conda package file
Expand Down
Loading

0 comments on commit 1a6b55c

Please sign in to comment.