Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
autoupdate_schedule: 'monthly'
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.4
rev: v0.15.5
hooks:
- id: ruff-format
args: ["--config", "pyproject.toml"]
Expand Down
40 changes: 32 additions & 8 deletions tools/rapids-get-pr-artifact
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
# --noarch: for conda python packages that use RAPIDS_PY_NOARCH_SUFFIX
# --stable: for wheel python packages that use stable ABI (abi3)
# --pkg_name: specify the package name to download if different from repo name (e.g. pylibraft)
#
# Additional environment variables recognized by 'rapids-get-pr-artifact':
#
# * RAPIDS_BUILD_WORKFLOW_NAME = Filename for the workflow that build the artifacts you're trying to fetch.
# Defaults to 'pr.yaml'.
#
set -euo pipefail

# Parse flags
Expand Down Expand Up @@ -73,7 +79,7 @@ fi

# Validate --stable flag
if (( stable_flag == 1 )); then
if [[ "${package_type}" != "python" ]]; then
if [[ "${package_type:-}" != "python" ]]; then
rapids-echo-stderr "Error: --stable flag is only compatible with package_type='python'"
rapids-echo-stderr "Got: package_format='${package_format}'"
exit 1
Expand All @@ -83,7 +89,7 @@ fi
source rapids-prompt-local-github-auth

# If commit is not provided, get the latest commit on the PR
if [[ -z "${commit}" ]]; then
if [[ -z "${commit:-}" ]]; then
commit=$(rapids-retry --quiet gh pr view "${pr}" --repo "${repo}" --json headRefOid --jq '.headRefOid')
fi

Expand All @@ -101,6 +107,14 @@ else
)
fi

# if RAPIDS_BUILD_WORKFLOW_NAME is set, use that instead of any RAPIDS conventions
if [[ -n "${RAPIDS_BUILD_WORKFLOW_NAME:-}" ]]; then
workflow_that_produced_artifacts="${RAPIDS_BUILD_WORKFLOW_NAME}"
else
# otherwise, rely on the RAPIDS workflow name conventions
workflow_that_produced_artifacts="pr.yaml"
fi

# get run ID
# NOTE: cannot reuse rapids-github-run-id here, because the environment variable
# GITHUB_RUN_ID will refer to the run this is being called from, not
Expand All @@ -109,13 +123,23 @@ fi
# For example, if this is called on a 'cudf' PR to download 'rmm' artifacts,
# here we want a run ID from an 'rmm' CI run, not the current 'cudf' one.
github_run_id=$(
rapids-retry --quiet gh run list \
--repo "${repo}" \
--branch "pull-request/${pr}" \
--commit "${commit}" \
--json 'createdAt,databaseId' \
--jq 'sort_by(.createdAt) | reverse | .[0] | .databaseId'
RAPIDS_RETRY_SLEEP=120 \
rapids-retry --quiet gh run list \
--repo "${repo}" \
--branch "pull-request/${pr}" \
--commit "${commit}" \
--workflow "${workflow_that_produced_artifacts}" \
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding --workflow limits the search space.

--json 'createdAt,databaseId' \
--jq 'sort_by(.createdAt) | reverse | .[0] | .databaseId'
)

# Passing an empty string to `gh run download` results in it searching all runs from all times... which could be
# thousands of results and result in exceeding GitHub rate limits. Prevent that.
if [[ -z "${github_run_id:-}" ]]; then
rapids-echo-stderr "ERROR: failed to find a GitHub Actions run for [repo=${repo}, workflow=${workflow_that_produced_artifacts}, branch=pull-request/${pr}, commit=${commit}]."
exit 1
fi

unzip_dest="${RAPIDS_UNZIP_DIR:-$(mktemp -d)}"

rapids-echo-stderr "Downloading and decompressing ${pkg_name} from Run ID ${github_run_id} into ${unzip_dest}"
Expand Down