epassaro / cache-conda-envs Goto Github PK
View Code? Open in Web Editor NEWSpeed up your builds by caching Anaconda environments on GitHub Actions
License: MIT License
Speed up your builds by caching Anaconda environments on GitHub Actions
License: MIT License
Thanks for the examples and blog post about this. I had trouble working with your example because you defined each matrix environment separately so you could define a label and prefix. However, I usually use lists for my matrix entries like:
matrix:
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
python-version: ["3.9", "3.10"]
which means I can't easily define prefix/label (as far as I know). I cam up with an alternative that doesn't require the user to know what platform they are on by updating the DATE job:
- name: Set cache environment variables
shell: bash -l {0}
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
CONDA_PREFIX=$(python -c "import sys; print(sys.prefix)")
echo "CONDA_PREFIX=$CONDA_PREFIX" >> $GITHUB_ENV
I also updated my cache entry to include the python version:
- uses: actions/cache@v3
with:
path: ${{ env.CONDA_PREFIX }}
key: ${{ matrix.os }}-${{matrix.python-version}}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
Hello, thanks for this code and the great blog post explaining it! This has been very helpful for setting up decent GitHub actions with Conda environments.
I'm wondering if you might be able to explain here, or add to the documentation, the process for manually triggering a new build via the CACHE_NUMBER variable? That is, how is this variable incremented to invalidate the cache? Does this require changing the variable value in the workflow script (therefore requiring a new commit), or can it be done externally somehow when running the workflow? I think the latter might be possible using the repository secret variables, but I might be missing how to do it with the regular environment variables in the workflow as designed. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.