Skip to content

self-hosted-gpu-test #826

self-hosted-gpu-test

self-hosted-gpu-test #826

name: self-hosted-gpu-test
on:
push:
branches:
- main
workflow_dispatch:
schedule:
# nightly tests
- cron: "0 0 * * *"
jobs:
start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Try to start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@main
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ami-04d16a12bbc76ff0b
ec2-instance-type: g4dn.xlarge
subnet-id: subnet-0dee8543e12afe0cd # us-east-1a
security-group-id: sg-0f9809618550edb98
# iam-role-name: self-hosted-runner # optional, requires additional permissions
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
do-the-job:
name: Do the job on the runner
needs: start-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
timeout-minutes: 1200 # 20 hrs
env:
TEST_MODE: GPU
OPENMM: 8.0
OE_LICENSE: ${{ github.workspace }}/oe_license.txt
HOME: /home/ec2-user
defaults:
run:
shell: bash -l {0}
steps:
- name: setup env
run: |
echo $HOME
export HOME=/home/ec2-user
echo $HOME
- uses: actions/checkout@v3
- uses: mamba-org/provision-with-micromamba@main
with:
environment-file: devtools/conda-envs/test_env.yaml
channels: conda-forge,openeye
extra-specs: |
python==3.9
openmm>=8.0
cudatoolkit==11.7
- name: Additional info about the build
run: |
uname -a
df -h
ulimit -a
micromamba info
micromamba list
python -c "import openmm; print(openmm.Platform.getPluginLoadFailures())"
python -m openmm.testInstallation
- name: Install package
run: |
python -m pip install --no-deps -v .
- name: Environment Information
run: |
micromamba info
micromamba list
- name: Decrypt OpenEye license
env:
OE_LICENSE_TEXT: ${{ secrets.OE_LICENSE }}
run: |
echo "${OE_LICENSE_TEXT}" > ${OE_LICENSE}
python -c "import openeye; assert openeye.oechem.OEChemIsLicensed(), 'OpenEye license checks failed!'"
- name: Test the package
run: |
export TRAVIS=true
micromamba list
pytest -v --cov-report xml --cov=perses --durations=0 -a "not advanced" -m "gpu_ci or gpu_needed" perses/tests
- name: Codecov
if: ${{ github.repository == 'choderalab/perses'
&& github.event != 'schedule' }}
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: false
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- do-the-job # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@main
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}