Skip to content

Commit f8874a5

Browse files
committed
Merge remote-tracking branch 'origin/documentation-remove-gpu-dependency' into documentation-remove-gpu-dependency
2 parents 0ae6cde + 80dc45d commit f8874a5

File tree

6 files changed

+130
-10
lines changed

6 files changed

+130
-10
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Preview or clean up docs built from PRs
2+
3+
# A re-implementation based on the logic of https://github.com/rossjrw/pr-preview-action/blob/41a957c44a456a34718e9bcf825363194db5e6d5/README.md, due to limitations illustrated in NVIDIA/cuda-python#380.
4+
5+
inputs:
6+
source-folder:
7+
required: true
8+
type: string
9+
10+
runs:
11+
using: composite
12+
steps:
13+
# The steps below are executed only when testing in a PR.
14+
# Note: the PR previews will be removed once merged to main (see below)
15+
- name: Get PR info
16+
if: ${{ github.ref_name != 'main' }}
17+
uses: nv-gha-runners/get-pr-info@main
18+
id: get-pr-info
19+
20+
- name: Extract PR number from info
21+
if: ${{ github.ref_name != 'main' }}
22+
shell: bash --noprofile --norc -xeuo pipefail {0}
23+
run: |
24+
PR_NUMBER="${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}"
25+
if [[ "$PR_NUMBER" == "" ]]; then
26+
echo "cannot extract PR number"
27+
exit 1
28+
else
29+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
30+
fi
31+
32+
- name: Deploy doc preview
33+
if: ${{ github.ref_name != 'main' }}
34+
uses: JamesIves/github-pages-deploy-action@v4
35+
with:
36+
git-config-name: cuda-python-bot
37+
git-config-email: [email protected]
38+
folder: ${{ inputs.source-folder }}
39+
target-folder: docs/pr-preview/pr-${{ env.PR_NUMBER }}/
40+
commit-message: "Deploy doc preview for PR ${{ env.PR_NUMBER }} (${{ github.sha }})"
41+
42+
- name: Leave a comment after deployment
43+
if: ${{ github.ref_name != 'main' }}
44+
uses: marocchino/sticky-pull-request-comment@v2
45+
with:
46+
header: pr-preview
47+
number: ${{ env.PR_NUMBER }}
48+
skip_unchanged: true
49+
message: |
50+
Doc Preview CI
51+
:---:
52+
| <p></p> :rocket: View preview at <br> https://nvidia.github.io/cuda-python/pr-preview/pr-${{ env.PR_NUMBER }}/ <br><br>
53+
| <h6><br> Preview will be ready when the GitHub Pages deployment is complete. <br><br></h6>
54+
55+
# The steps below are executed only when building on main.
56+
- name: Get PR data
57+
if: ${{ github.ref_name == 'main' }}
58+
uses: actions/github-script@v7
59+
id: get-pr-data
60+
with:
61+
script: |
62+
return (
63+
await github.rest.repos.listPullRequestsAssociatedWithCommit({
64+
commit_sha: context.sha,
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
})
68+
).data[0];
69+
70+
- name: Extract PR number from data
71+
if: ${{ github.ref_name == 'main' }}
72+
shell: bash --noprofile --norc -xeuo pipefail {0}
73+
run: |
74+
PR_NUMBER="${{ fromJSON(steps.get-pr-data.outputs.result).number }}"
75+
if [[ "$PR_NUMBER" == "" ]]; then
76+
echo "cannot extract PR number"
77+
exit 1
78+
else
79+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
80+
fi
81+
82+
- name: Remove doc preview
83+
if: ${{ github.ref_name == 'main' }}
84+
uses: JamesIves/github-pages-deploy-action@v4
85+
with:
86+
git-config-name: cuda-python-bot
87+
git-config-email: [email protected]
88+
folder: ${{ inputs.source-folder }}
89+
target-folder: docs/pr-preview/pr-${{ env.PR_NUMBER }}/
90+
commit-message: "Clean up doc preview for PR ${{ env.PR_NUMBER }} (${{ github.sha }})"
91+
92+
- name: Leave a comment after removal
93+
if: ${{ github.ref_name == 'main' }}
94+
uses: marocchino/sticky-pull-request-comment@v2
95+
with:
96+
header: pr-preview
97+
number: ${{ env.PR_NUMBER }}
98+
hide_and_recreate: true
99+
hide_classify: "OUTDATED"
100+
message: |
101+
Doc Preview CI
102+
:---:
103+
Preview removed because the pull request was closed or merged.

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
REPO_DIR=$(cygpath -w $PWD)
7777
fi
7878
79-
echo "PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
79+
echo "CUDA_BINDINGS_PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
8080
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}"
8181
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
8282
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
@@ -139,10 +139,10 @@ jobs:
139139
# CIBW mounts the host filesystem under /host
140140
CIBW_ENVIRONMENT_LINUX: >
141141
CUDA_PATH=/host/${{ env.CUDA_PATH }}
142-
PARALLEL_LEVEL=${{ env.PARALLEL_LEVEL }}
142+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
143143
CIBW_ENVIRONMENT_WINDOWS: >
144144
CUDA_HOME="$(cygpath -w ${{ env.CUDA_PATH }})"
145-
PARALLEL_LEVEL=${{ env.PARALLEL_LEVEL }}
145+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
146146
with:
147147
package-dir: ./cuda_bindings/
148148
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
@@ -263,6 +263,7 @@ jobs:
263263
permissions:
264264
id-token: write
265265
contents: write
266+
pull-requests: write
266267
needs:
267268
- build
268269
secrets: inherit

.github/workflows/build-docs.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jobs:
5050
# WAR: Building the doc currently requires CTK installed (NVIDIA/cuda-python#326,327)
5151
- name: Set up mini CTK
5252
uses: ./.github/actions/fetch_ctk
53-
continue-on-error: false
5453
with:
5554
host-platform: linux-64
5655
cuda-version: ${{ inputs.build-ctk-ver }}
@@ -126,22 +125,29 @@ jobs:
126125
mkdir -p artifacts/docs
127126
mv cuda_python/docs/build/html/* artifacts/docs/
128127
129-
# Note: currently this is only for manual inspection. This step will become
130-
# required once we switch to use GHA for doc deployment (see the bottom).
128+
# create an empty folder for removal use
129+
mkdir -p artifacts/empty_docs
130+
131+
# TODO: Consider removing this step?
131132
- name: Upload doc artifacts
132133
uses: actions/upload-pages-artifact@v3
133134
with:
134135
path: artifacts/
135136
retention-days: 3
136137

137-
# The step below is not executed unless when building on main.
138+
- name: Deploy or clean up doc preview
139+
uses: ./.github/actions/doc_preview
140+
with:
141+
source-folder: ${{ (github.ref_name != 'main' && 'artifacts/docs') ||
142+
'artifacts/empty_docs' }}
143+
138144
- name: Deploy doc update
139-
if: ${{ github.ref_name == 'main' && success() }}
145+
if: ${{ github.ref_name == 'main' }}
140146
uses: JamesIves/github-pages-deploy-action@v4
141147
with:
142-
folder: artifacts/docs/
143148
git-config-name: cuda-python-bot
144149
git-config-email: [email protected]
150+
folder: artifacts/docs/
145151
target-folder: docs/
146152
commit-message: "Deploy latest docs: ${{ github.sha }}"
147153
clean: false

cuda_bindings/cuda/bindings/_lib/cyruntime/cyruntime.pyx.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4639,7 +4639,7 @@ cdef cudaError_t _cudaGraphExecGetFlags(cudaGraphExec_t graphExec, unsigned long
46394639
err = m_global.lazyInitContextState()
46404640
if err != cudaSuccess:
46414641
return err
4642-
err = <cudaError_t>cydriver._cuGraphExecGetFlags(<cydriver.CUgraphExec>graphExec, flags)
4642+
err = <cudaError_t>cydriver._cuGraphExecGetFlags(<cydriver.CUgraphExec>graphExec, <cydriver.cuuint64_t *>flags)
46434643
if err != cudaSuccess:
46444644
_setLastError(err)
46454645
return err

cuda_bindings/docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
release.md
1212
environment_variables.md
1313
api.rst
14+
tips_and_tricks.rst
1415

1516

1617
Indices and tables
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Tips and Tricks
2+
---------------
3+
4+
Getting the address of underlying C objects from the low-level bindings
5+
=======================================================================
6+
7+
All CUDA C types are exposed to Python as Python classes. For example, the :class:`~cuda.bindings.driver.CUstream` type is exposed as a class with methods :meth:`~cuda.bindings.driver.CUstream.getPtr()` and :meth:`~cuda.bindings.driver.CUstream.__int__()` implemented.
8+
9+
There is an important distinction between the ``getPtr()`` method and the behaviour of ``__int__()``. If you need to get the pointer address *of* the underlying ``CUstream`` C object wrapped in the Python class, you can do so by calling ``int(instance_of_CUstream)``, which returns the address as a Python `int`, while calling ``instance_of_CUstream.getPtr()`` returns the pointer *to* the ``CUstream`` C object (that is, ``&CUstream``) as a Python `int`.

0 commit comments

Comments
 (0)