Skip to content

Commit

Permalink
do not hardcode num_pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ashors1 committed Mar 22, 2024
1 parent 3453fd8 commit 44b1618
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/baselines/download_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ fi

[ "$#" -ge "1" ] || usage

EXPECTED_NUM_PAGES=2

for WORKFLOW_RUN in $*; do
mkdir -p $WORKFLOW_RUN

ARTIFACTS=$(curl -L \
"https://api.github.com/repos/NVIDIA/JAX-Toolbox/actions/runs/${WORKFLOW_RUN}/artifacts?per_page=100&page=1")

COUNT=$(echo $ARTIFACTS | jq -r '.total_count')
NUM_PAGES=$(((COUNT+99)/100)) ## ceil of count / 100
pushd $WORKFLOW_RUN
# cURL the list of artifacts
ARTIFACTS=$(for i in $(seq 1 $EXPECTED_NUM_PAGES); do curl -L \
ARTIFACTS+=$(for i in $(seq 2 $NUM_PAGES); do curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/NVIDIA/JAX-Toolbox/actions/runs/${WORKFLOW_RUN}/artifacts?per_page=100&page=$i"; done)

COUNT=$(echo $ARTIFACTS | jq -r '.total_count' | head -n 1)
NAMES=$(echo $ARTIFACTS | jq -r '.artifacts[].name')

URLS=$(echo $ARTIFACTS | jq -r '.artifacts[].archive_download_url')
Expand All @@ -35,6 +39,7 @@ for WORKFLOW_RUN in $*; do

# Download artifacts
for (( i=0; i<$COUNT; i++ )); do

N=${NAMES[$i]}
U=${URLS[$i]}

Expand Down

0 comments on commit 44b1618

Please sign in to comment.