Skip to content

Commit da49fec

Browse files
authored
Merge pull request #47 from vkt1414/master
Fix github actions
2 parents 946c99e + f9ce635 commit da49fec

8 files changed

+76
-8666
lines changed

.github/workflows/test_colab.yml

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@ name: Check Commits and Colab Images
33
on:
44
push:
55
branches: [ "master" ]
6+
paths:
7+
- ".github/workflows/test_colab.yml"
8+
- "notebooks/getting_started/part**.ipynb"
69
pull_request:
710
branches: [ "master" ]
11+
paths:
12+
- ".github/workflows/test_colab.yml"
13+
- "notebooks/getting_started/part**.ipynb"
814
workflow_dispatch:
915
schedule:
1016
- cron: 0 12 */1 * *
1117

1218
jobs:
13-
check_commits_and_images:
19+
check_colab_images:
1420
runs-on: ubuntu-latest
1521
permissions:
1622
contents: write
23+
pull-requests: write
1724

1825
steps:
1926
- name: Checkout code
@@ -28,15 +35,15 @@ jobs:
2835
run: pip install requests==2.31.0 pandas==2.1.1 google-cloud-bigquery==3.12.0 pyarrow==13.0.0 nbformat==5.9.2
2936

3037
- name: Authorize Google Cloud
38+
if: github.event_name != 'pull_request'
3139
uses: google-github-actions/auth@v1
3240
with:
3341
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }}
3442
create_credentials_file: true
3543
export_environment_variables: true
3644

37-
- name: Run check-commits.py and check-colab-images.py, preprocess notebooks scripts
45+
- name: Run check-colab-images.py and preprocess notebooks
3846
run: |
39-
python test/src/check-commits.py
4047
python test/src/check-colab-images.py
4148
python test/src/preProcessNotebooks.py
4249
@@ -60,59 +67,59 @@ jobs:
6067
swap-storage: true
6168

6269
- name: Docker login
70+
if: github.event_name != 'pull_request'
6371
uses: docker/login-action@v3
6472
with:
6573
username: ${{ secrets.DOCKER_USERNAME }}
6674
password: ${{ secrets.DOCKER_PASSWORD }}
6775

6876
- name: Pull from GCP and Push Docker image to Docker Hub
69-
if: env.RESULT == 'true'
77+
if: github.event_name != 'pull_request' && env.RESULT == 'true'
7078
run: |
7179
docker pull us-docker.pkg.dev/colab-images/public/runtime:latest
7280
docker tag us-docker.pkg.dev/colab-images/public/runtime:latest imagingdatacommons/idc-testing-colab:latest
7381
docker push imagingdatacommons/idc-testing-colab:latest
7482
7583
- name: Pull Docker image from Docker Hub
76-
if: env.RESULT == 'false'
84+
if: github.event_name == 'pull_request' || env.RESULT == 'false'
7785
run: |
7886
docker pull imagingdatacommons/idc-testing-colab:latest
7987
8088
- name: Copy Google Cloud credentials to Docker container
89+
if: github.event_name != 'pull_request'
8190
run: |
8291
CREDENTIALS_FILE_PATH="${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
8392
CREDENTIALS_FILE_NAME=$(basename "$CREDENTIALS_FILE_PATH")
8493
GOOGLE_APPLICATION_CREDENTIALS="/content/$CREDENTIALS_FILE_NAME"
8594
echo "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" >> $GITHUB_ENV
8695
8796
- name: Run notebook with papermill
97+
if: github.event_name != 'pull_request'
8898
run: |
8999
for nb in part1_prerequisites part2_searching_basics part3_exploring_cohorts; do
100+
# Create a new directory for each notebook
101+
sudo mkdir -p "temp/${nb}"
102+
90103
docker run -d --name colab -v "$(pwd):/content" -e GOOGLE_APPLICATION_CREDENTIALS="${{ env.GOOGLE_APPLICATION_CREDENTIALS }}" imagingdatacommons/idc-testing-colab:latest
91104
docker exec -t colab /bin/bash -c "pip install papermill==2.4.0"
92-
docker exec -t colab /bin/bash -c "set -o xtrace && set -o errexit && set -o pipefail && set -o nounset && set +o errexit && cd content/ && papermill /content/notebooks/getting_started/${nb}.ipynb /content/test/outputs/${nb}_papermill_output.ipynb && set -o errexit && ls -A"
93-
#docker exec -t colab /bin/bash -c "jupyter nbconvert --to html --ExtractOutputPreprocessor.enabled=False /content/test/outputs/output_${nb}.ipynb"
105+
106+
# Change the working directory to the new directory
107+
docker exec -t colab /bin/bash -c "set -o xtrace && set -o errexit && set -o pipefail && set -o nounset && set +o errexit && cd /content/temp/${nb} && papermill --log-level='DEBUG' /content/notebooks/getting_started/${nb}.ipynb /content/temp/${nb}_papermill_output.ipynb && set -o errexit && ls -A"
108+
94109
docker stop colab
95110
docker rm colab
111+
sudo rm -r "temp"
96112
done
97-
98-
# skip commit
99-
#- name: Commit changes
100-
# if: ${{ github.event_name != 'pull_request' }}
101-
# uses: stefanzweifel/git-auto-commit-action@v4
102-
# with:
103-
# commit_message: 'Check colab env'
104-
# file_pattern: 'test/*.csv test/outputs/*.ipynb'
105-
# branch: 'master'
106-
107-
#- name: Check output notebooks for errors
108-
# run: |
109-
# for nb in part1_prerequisites part2_searching_basics part3_exploring_cohorts; do
110-
# if grep -q '"name": "stderr"\|"status": "failed"' test/outputs/output_${nb}.ipynb; then
111-
# echo "Error messages found in the ${nb} notebook output:"
112-
# cat test/outputs/output_${nb}.ipynb
113-
# exit 1
114-
# else
115-
# echo "No errors found in the ${nb} notebook output."
116-
# fi
117-
# done
118-
# exit $EXIT_CODE
113+
114+
- name: Create Pull Request to update the colab image metadata database
115+
if: github.event_name != 'pull_request'
116+
uses: peter-evans/create-pull-request@v5
117+
with:
118+
title: Update colab images list
119+
body: Update colab-images-list.csv so that when a colab image is updated, we do not keep pulling colab docker image from gcp and pushing to dockerhub everytime
120+
base: master
121+
branch: update-colab-images-list
122+
add-paths: |
123+
test/colab-images-list.csv
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ __pycache__/
55
# Pycharm project files
66
.idea
77
.idea/*
8+
9+
10+
gha-creds-**.json

test/colab-images-list.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
date,tag,sha256,docker_pull_tag,docker_pull_sha256_tag
2-
,latest,sha256:4a26494c9c92ab4d0515e0715d79dfecbe8cfacb9b86fcfd55bc0274cb89530d,us-docker.pkg.dev/colab-images/public/runtime:latest,us-docker.pkg.dev/colab-images/public/runtime@sha256:4a26494c9c92ab4d0515e0715d79dfecbe8cfacb9b86fcfd55bc0274cb89530d
2+
,latest,sha256:9634a9786cde027a5c115a2a2df31aebe0c9ef9a4a06951cb32bcf6edec84ef7,us-docker.pkg.dev/colab-images/public/runtime:latest,us-docker.pkg.dev/colab-images/public/runtime@sha256:9634a9786cde027a5c115a2a2df31aebe0c9ef9a4a06951cb32bcf6edec84ef7
33
20230515,release-colab-20230515-060150-RC00,sha256:3a8fc58f7e81b96dc59a2fb48b7973802f59fdd634fb538569228d830a7e76a9,us-docker.pkg.dev/colab-images/public/runtime:release-colab-20230515-060150-RC00,us-docker.pkg.dev/colab-images/public/runtime@sha256:3a8fc58f7e81b96dc59a2fb48b7973802f59fdd634fb538569228d830a7e76a9
44
20230622,release-colab-20230622-060123-RC01,sha256:7dac57e02aae4e83aab349563190a71bdd07374e1365f53bd6a50280046c6091,us-docker.pkg.dev/colab-images/public/runtime:release-colab-20230622-060123-RC01,us-docker.pkg.dev/colab-images/public/runtime@sha256:7dac57e02aae4e83aab349563190a71bdd07374e1365f53bd6a50280046c6091
55
20230711,release-colab-20230711-060203-RC00,sha256:53dc33f450cd162d8a42c5aff02d50ac24eb9fc68be77f0374614ad07247e9cd,us-docker.pkg.dev/colab-images/public/runtime:release-colab-20230711-060203-RC00,us-docker.pkg.dev/colab-images/public/runtime@sha256:53dc33f450cd162d8a42c5aff02d50ac24eb9fc68be77f0374614ad07247e9cd
66
20230803,release-colab-20230803-060151-RC00,sha256:ae8a5bf22a84c67fb4b35aa4b1f19dac94b01b56a97c5c7bb15db57552e8d38c,us-docker.pkg.dev/colab-images/public/runtime:release-colab-20230803-060151-RC00,us-docker.pkg.dev/colab-images/public/runtime@sha256:ae8a5bf22a84c67fb4b35aa4b1f19dac94b01b56a97c5c7bb15db57552e8d38c
77
20230921,release-colab_20230921-060057_RC00,sha256:4a26494c9c92ab4d0515e0715d79dfecbe8cfacb9b86fcfd55bc0274cb89530d,us-docker.pkg.dev/colab-images/public/runtime:release-colab_20230921-060057_RC00,us-docker.pkg.dev/colab-images/public/runtime@sha256:4a26494c9c92ab4d0515e0715d79dfecbe8cfacb9b86fcfd55bc0274cb89530d
8+
20231214,release-colab_20231214-060137_RC00,sha256:9634a9786cde027a5c115a2a2df31aebe0c9ef9a4a06951cb32bcf6edec84ef7,us-docker.pkg.dev/colab-images/public/runtime:release-colab_20231214-060137_RC00,us-docker.pkg.dev/colab-images/public/runtime@sha256:9634a9786cde027a5c115a2a2df31aebe0c9ef9a4a06951cb32bcf6edec84ef7

0 commit comments

Comments
 (0)