Skip to content

Commit

Permalink
cache docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikey-vyas committed Aug 25, 2024
1 parent d876aa0 commit cff81ad
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
38 changes: 37 additions & 1 deletion .github/workflows/predict-parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,43 @@ jobs:
id: start-time
run: echo "start-time=$(date +%s)" >> "$GITHUB_OUTPUT"


pull-model-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ersilia-os/ersilia

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: set up ersilia
run: |
echo $CONDA/bin >> $GITHUB_PATH
source $CONDA/etc/profile.d/conda.sh
conda install -y python=3.10
conda init
conda install git-lfs -c conda-forge
git-lfs install
conda install gh -c conda-forge
python -m pip install -e .[test]
pip install pyairtable
- name: fetch and save requested model image
run: |
source activate
ersilia fetch ${{ inputs.model-id }}
docker save ersiliaos/${{ inputs.model-id }} -o /tmp/${{ inputs.model-id }}.tar
- name: cache model Docker image
uses: actions/cache@v3
with:
path: /tmp/${{ inputs.model-id }}.tar
key: ${{ runner.os }}-docker-${{ inputs.model-id }}
restore-keys: |
${{ runner.os }}-docker-${{ inputs.model-id }}
generate-matrix:
runs-on: ubuntu-latest
outputs:
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/predict.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y make

- name: Set up Python environment
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Run make install
run: make install-prod
cache: 'poetry'
- run: make install-prod

# we need this step as ersilia will use the default conda environment to run the example model during `ersilia serve`
# could get around this eventually if we only use conda for env management, but there are complexities around referencing a dev
Expand All @@ -67,6 +66,18 @@ jobs:
- name: Activate virtual environment
run: source .venv/bin/activate

- name: Restore cached Docker image
uses: actions/cache@v3
with:
path: /tmp/${{ inputs.model-id }}.tar
key: ${{ runner.os }}-docker-${{ inputs.model-id }}
restore-keys: |
${{ runner.os }}-docker-${{ inputs.model-id }}
- name: Load Docker image
run: |
docker load -i /tmp/${{ inputs.model-id }}.tar
- name: Run Python script to generate predictions and upload to S3
env:
Expand Down

0 comments on commit cff81ad

Please sign in to comment.