|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +# Update the html links file in the s3 bucket Pip uses this html file to look |
| 6 | +# through all the wheels and pick the most recently uploaded one (by the |
| 7 | +# version, not the actual date of upload). There is one html file per cuda/cpu |
| 8 | +# version |
| 9 | + |
| 10 | +# Upload for all CUDA/cpu versions if not given one to use |
| 11 | +if [[ -z "$CUDA_VERSIONS" ]]; then |
| 12 | + export CUDA_VERSIONS=('cpu' 'cu92' 'cu100' 'cu101' 'cu102' 'cu110' 'rocm5.0' 'rocm5.1.1') |
| 13 | +fi |
| 14 | + |
| 15 | +if [[ -z "$HTML_NAME" ]]; then |
| 16 | + export HTML_NAME='torch_nightly.html' |
| 17 | +fi |
| 18 | + |
| 19 | +# Dry run disabled by default for legacy purposes |
| 20 | +DRY_RUN=${DRY_RUN:-disabled} |
| 21 | +DRY_RUN_FLAG="" |
| 22 | +if [[ "${DRY_RUN}" != disabled ]]; then |
| 23 | + DRY_RUN_FLAG="--dryrun" |
| 24 | +fi |
| 25 | + |
| 26 | +# NB: includes trailing slash (from PIP_UPLOAD_FOLDER) |
| 27 | +s3_base="s3://pytorch/whl/${PIP_UPLOAD_FOLDER}" |
| 28 | + |
| 29 | +# Pull all existing whls in this directory and turn them into html links |
| 30 | +# N.B. we use the .dev as a hacky way to exclude all wheels with old |
| 31 | +# 'yyyy.mm.dd' versions |
| 32 | +# |
| 33 | +# NB: replacing + with %2B is to fix old versions of pip which don't |
| 34 | +# this transform automatically. This makes the display a little |
| 35 | +# ugly but whatever |
| 36 | +function generate_html() { |
| 37 | + # Trailing slash required in both cases |
| 38 | + dir="$1" |
| 39 | + url_prefix="$2" |
| 40 | + aws s3 ls "${s3_base}${dir}" | grep --only-matching '\S*\.whl' | sed 's#+#%2B#g' | sed 's#.*#<a href="'"${url_prefix}"'&">'"${url_prefix}"'&</a><br>#g' |
| 41 | +} |
| 42 | + |
| 43 | +# This will be included in all the sub-indices |
| 44 | +generate_html '' '../' > "root-$HTML_NAME" |
| 45 | +generate_html '' '' > "$HTML_NAME" |
| 46 | + |
| 47 | +for cuda_ver in "${CUDA_VERSIONS[@]}"; do |
| 48 | + generate_html "${cuda_ver}/" "" > "${cuda_ver}-$HTML_NAME" |
| 49 | + cat "root-$HTML_NAME" >> "${cuda_ver}-$HTML_NAME" |
| 50 | + generate_html "${cuda_ver}/" "${cuda_ver}/" >> "$HTML_NAME" |
| 51 | + |
| 52 | + # Check your work every once in a while |
| 53 | + echo "Setting ${cuda_ver}/$HTML_NAME to:" |
| 54 | + cat "${cuda_ver}-$HTML_NAME" |
| 55 | + ( |
| 56 | + set -x |
| 57 | + aws s3 cp ${DRY_RUN_FLAG} "${cuda_ver}-$HTML_NAME" "s3://pytorch/whl/${PIP_UPLOAD_FOLDER}${cuda_ver}/$HTML_NAME" --acl public-read --cache-control 'no-cache,no-store,must-revalidate' |
| 58 | + ) |
| 59 | + |
| 60 | +done |
| 61 | + |
| 62 | +# Check your work every once in a while |
| 63 | +echo "Setting $HTML_NAME to:" |
| 64 | +cat "$HTML_NAME" |
| 65 | +( |
| 66 | + set -x |
| 67 | + |
| 68 | + # Upload the html file back up |
| 69 | + # Note the lack of a / b/c duplicate / do cause problems in s3 |
| 70 | + aws s3 cp ${DRY_RUN_FLAG} "$HTML_NAME" "$s3_base$HTML_NAME" --acl public-read --cache-control 'no-cache,no-store,must-revalidate' |
| 71 | +) |
0 commit comments