Skip to content

Add annotations to pylibcudf source files - #23643

Open
vyasr wants to merge 13 commits into
NVIDIA:mainfrom
vyasr:codex/pylibcudf-source-annotations-stubgen
Open

Add annotations to pylibcudf source files#23643
vyasr wants to merge 13 commits into
NVIDIA:mainfrom
vyasr:codex/pylibcudf-source-annotations-stubgen

Conversation

@vyasr

@vyasr vyasr commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Currently pylibcudf maintains handwritten .pyi annotations. We want to generate these annotations from source files. In order to do so, the source files must contain all annotation information that cannot be inferred from the Cython typing. Currently all of that information is only maintained in the handwritten .pyi files. This PR migrates all of that typing information to annotations in the .pyx source files. By doing so, we can generate fully descriptive type stubs.

Some specific changes in this PR:

  • Adds public typing protocols and aliases for CUDA stream-like and array-interface inputs.
  • Annotates stream parameters, array-interface inputs, collection/container inputs, IO source/sink contracts, and selected domain aliases.
  • Adds eligible Python def/property return annotations where Cython accepts them.

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added Python Affects Python cuDF API. pylibcudf Issues specific to the pylibcudf package labels Aug 13, 2026
@vyasr
vyasr force-pushed the codex/pylibcudf-source-annotations-stubgen branch from f617fb7 to 93e1691 Compare August 13, 2026 00:49
@vyasr vyasr changed the title Add pylibcudf source annotations for generated stubs Add annotations to pylibcudf source files Aug 13, 2026
@vyasr vyasr added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Aug 13, 2026
@vyasr
vyasr marked this pull request as ready for review August 13, 2026 00:53
@vyasr
vyasr requested a review from a team as a code owner August 13, 2026 00:53
@vyasr
vyasr requested a review from TomAugspurger August 13, 2026 00:53
Comment thread python/pylibcudf/pylibcudf/types.pyx Outdated
from functools import cache
from typing import Any, TypeAlias

PyarrowDataType: TypeAlias = type[Any]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we import pyarrow in a if TYPE_CHECKING block and use -> pa.DataType?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 8839ca3: this now uses if TYPE_CHECKING: import pyarrow as pa and annotates with pa.DataType.

Comment thread python/pylibcudf/pylibcudf/utils.pyx Outdated
Comment on lines +23 to +30
from typing import Protocol


class HasCudaStream(Protocol):
def __cuda_stream__(self) -> object: ...


CudaStreamLike = Stream | HasCudaStream

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we consider adding this to a pylibcudf.typing module and expose CudaStreamLike (and other aliases) just in case another library wants to use this annotation in their library with pylibcudf?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 8839ca3: added pylibcudf.typing and exposed the shared aliases/protocols there.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0c8aa01b-b1c2-4abd-b573-fccd0a7d51d4

📥 Commits

Reviewing files that changed from the base of the PR and between 29945c3 and 4bdd079.

📒 Files selected for processing (2)
  • docs/cudf/source/conf.py
  • python/pylibcudf/pylibcudf/io/text.pyx
🚧 Files skipped from review as they are similar to previous changes (2)
  • python/pylibcudf/pylibcudf/io/text.pyx
  • docs/cudf/source/conf.py

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Added comprehensive type annotations across the Python API, including CUDA streams, columns, tables, metadata, inputs, and return values.
    • Added public typing support for CUDA and standard array interfaces.
    • Improved annotations for file-format readers and writers, text processing, joins, sorting, aggregation, and string operations.
    • Added clearer type definitions for CUDA stream-like objects and related data structures.
  • Chores
    • Updated copyright attributions where applicable.
    • Runtime behavior remains unchanged.

Walkthrough

The PR adds static type annotations across pylibcudf Cython APIs. It defines shared CUDA stream, array-interface, metadata, and recursive structure types. Existing defaults, control flow, native calls, and runtime behavior remain unchanged.

Changes

Public API typing

Layer / File(s) Summary
Typing foundations and core APIs
python/pylibcudf/pylibcudf/typing.py, python/pylibcudf/pylibcudf/*.pyx
Adds CudaStreamLike, array-interface protocols, typed collections, return annotations, and optional stream annotations across core APIs.
IO and metadata contracts
python/pylibcudf/pylibcudf/io/*
Adds typed reader, writer, source, sink, metadata, stream, and return declarations.
Text and string APIs
python/pylibcudf/pylibcudf/strings/*, python/pylibcudf/pylibcudf/nvtext/*
Annotates optional CUDA streams and selected mapping, sequence, and collection parameters.
Supporting exports and documentation
python/pylibcudf/pylibcudf/__init__.py, types.pyx, expressions.pyx, aggregation.pyx, gpumemoryview.pyx, docs/cudf/source/conf.py
Adds package typing exports, Arrow and metadata annotations, factory parameter annotations, GPU memory-view annotations, copyright updates, and Sphinx suppressions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Mergeability Score: 🟡 Moderate · up to 4bdd0

The annotation changes may pass an unnormalized stream through an unchecked cast and may narrow valid stream-like inputs in generated stubs. This could cause incorrect stream handling or reject supported calls, so owner follow-up is needed before merging.

Suggested reviewers: tomaugspurger

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the migration of type information from handwritten stubs to pylibcudf source annotations.
Title check ✅ Passed The title is concise and accurately summarizes the primary change: adding annotations to pylibcudf source files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/pylibcudf/pylibcudf/scalar.pyx (1)

160-164: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Align all public Scalar stream annotations.

scalar.pyi declares five methods with CudaStreamLike | None, but scalar.pyx still declares Stream | None. Update the five source annotations before regenerating the stub. Regeneration should also preserve is_valid’s default None.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/pylibcudf/pylibcudf/scalar.pyx` around lines 160 - 164, Update the
five public Scalar method annotations in scalar.pyx, including Scalar.is_valid,
from Stream | None to CudaStreamLike | None; retain None as the default value
for is_valid, then regenerate scalar.pyi so its declarations remain aligned.

Sources: Coding guidelines, Learnings, MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/pylibcudf/pylibcudf/column.pyx`:
- Around line 88-104: Update the module’s __all__ declaration to include the
public typing symbols ArrayInterfaceBase, SupportsCudaArrayInterface, and
SupportsArrayInterface, preserving all existing exports.

In `@python/pylibcudf/pylibcudf/concatenate.pyx`:
- Around line 28-32: Added typing-contract tests and representative unit
benchmarks across the cohort: in
python/pylibcudf/pylibcudf/concatenate.pyx:28-32 cover correlated Column/Table
typing and concatenate benchmarking; contiguous_split.pyx:169-174 cover
ChunkedPack.create’s return type and packing; copying.pyx:458-462 and :519-523
cover slice and split element typing; datetime.pyx:58 cover generated stream
annotations and a representative benchmark; experimental/_join_streams.pyx:23-25
cover stream-like inputs and stream joining; expressions.pyx:479 cover the
Expression return contract and construction; and filling.pyx:49 cover generated
stream annotations and a representative operation. Use the existing test and
benchmark conventions, including generated-stub/runtime validation.

Apply the same fix in `@python/pylibcudf/pylibcudf/nvtext/replace.pyx` at line 36:
Representative stream-like typing and benchmark coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/utils.pyx` at line 58: Shared
coverage for stream, alias, and collection annotations.

Apply the same fix in `@python/pylibcudf/pylibcudf/aggregation.pyx` at line 431:
Generated quantile stub and representative benchmark coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/datetime.pyx` at line 58:
Generated datetime stubs and representative operation coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/filling.pyx` at line 49:
Generated filling stubs and representative operation coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyx` at
line 37: Stream-like generated signature and runtime coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/io/json.pyx` around lines 72 -
73: Recursive alias and accepted input contract coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/join.pyx` around lines 24 - 27:
Compiled import and generated stream signature coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/merge.pyx` around lines 27 -
32: Generated stream and ordering signature coverage.

Apply the same fix in `@python/pylibcudf/pylibcudf/strings/char_types.pyx` around
lines 14 - 17: Representative string API typing coverage.

In `@python/pylibcudf/pylibcudf/io/parquet.pyx`:
- Around line 689-694: Add return annotations to read_parquet in
python/pylibcudf/pylibcudf/io/parquet.pyx at lines 689-694,
ChunkedParquetWriter.from_options in python/pylibcudf/pylibcudf/io/parquet.pyx
at lines 791-793, and OrcChunkedWriter.from_options in
python/pylibcudf/pylibcudf/io/orc.pyx at lines 732-734. Match each annotation to
the corresponding declared return type in parquet.pyi or orc.pyi, preserving the
existing implementations.

In `@python/pylibcudf/pylibcudf/io/types.pyx`:
- Around line 688-695: Update the SinkInfo.__init__ sinks parameter and its
corresponding types.pyi declaration so both accept the advertised Sequence
variants, including tuples, by removing the list-only Cython annotation;
preserve the existing runtime validation and keep documentation consistent with
the shared contract.

In `@python/pylibcudf/pylibcudf/strings/translate.pyx`:
- Around line 53-56: Align the Cython runtime boundary with the public Mapping
annotation by changing the chars_table parameter from dict to object in both
public function declarations and _table_to_c_table, then ensure conversion
accepts Mapping implementations such as UserDict. Add coverage using UserDict
for both public translation functions while preserving existing dict behavior.

In `@python/pylibcudf/pylibcudf/table.pyx`:
- Line 135: Update both return paths that call from_table_view_of_arbitrary to
pass the normalized _stream value instead of the original stream argument,
ensuring objects implementing __cuda_stream__ are converted before the callee’s
unchecked cast.

In `@python/pylibcudf/pylibcudf/types.pyx`:
- Around line 29-31: Update the PyarrowDataType alias in types.pyx to represent
PyArrow DataType instances rather than class objects: use pa.DataType under
TYPE_CHECKING and provide a runtime fallback that avoids importing optional
PyArrow. Ensure the checked-in types.pyi exposes the same instance-based alias
for from_arrow parameters and to_arrow returns.

---

Outside diff comments:
In `@python/pylibcudf/pylibcudf/scalar.pyx`:
- Around line 160-164: Update the five public Scalar method annotations in
scalar.pyx, including Scalar.is_valid, from Stream | None to CudaStreamLike |
None; retain None as the default value for is_valid, then regenerate scalar.pyi
so its declarations remain aligned.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 11b7070b-b8d7-43c9-a793-7869d626652c

📥 Commits

Reviewing files that changed from the base of the PR and between d833615 and 93e1691.

📒 Files selected for processing (91)
  • python/pylibcudf/pylibcudf/aggregation.pyx
  • python/pylibcudf/pylibcudf/binaryop.pyx
  • python/pylibcudf/pylibcudf/column.pyx
  • python/pylibcudf/pylibcudf/column_factories.pyx
  • python/pylibcudf/pylibcudf/concatenate.pyx
  • python/pylibcudf/pylibcudf/contiguous_split.pyx
  • python/pylibcudf/pylibcudf/copying.pyx
  • python/pylibcudf/pylibcudf/datetime.pyx
  • python/pylibcudf/pylibcudf/experimental/_join_streams.pyx
  • python/pylibcudf/pylibcudf/expressions.pyx
  • python/pylibcudf/pylibcudf/filling.pyx
  • python/pylibcudf/pylibcudf/gpumemoryview.pyx
  • python/pylibcudf/pylibcudf/groupby.pyx
  • python/pylibcudf/pylibcudf/hashing.pyx
  • python/pylibcudf/pylibcudf/interop.pyx
  • python/pylibcudf/pylibcudf/io/avro.pyx
  • python/pylibcudf/pylibcudf/io/csv.pyx
  • python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyx
  • python/pylibcudf/pylibcudf/io/json.pyx
  • python/pylibcudf/pylibcudf/io/orc.pyx
  • python/pylibcudf/pylibcudf/io/parquet.pyx
  • python/pylibcudf/pylibcudf/io/parquet_metadata.pyx
  • python/pylibcudf/pylibcudf/io/text.pyx
  • python/pylibcudf/pylibcudf/io/timezone.pyx
  • python/pylibcudf/pylibcudf/io/types.pyx
  • python/pylibcudf/pylibcudf/join.pyx
  • python/pylibcudf/pylibcudf/json.pyx
  • python/pylibcudf/pylibcudf/labeling.pyx
  • python/pylibcudf/pylibcudf/lists.pyx
  • python/pylibcudf/pylibcudf/merge.pyx
  • python/pylibcudf/pylibcudf/null_mask.pyx
  • python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyx
  • python/pylibcudf/pylibcudf/nvtext/deduplicate.pyx
  • python/pylibcudf/pylibcudf/nvtext/edit_distance.pyx
  • python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyx
  • python/pylibcudf/pylibcudf/nvtext/jaccard.pyx
  • python/pylibcudf/pylibcudf/nvtext/minhash.pyx
  • python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyx
  • python/pylibcudf/pylibcudf/nvtext/normalize.pyx
  • python/pylibcudf/pylibcudf/nvtext/replace.pyx
  • python/pylibcudf/pylibcudf/nvtext/stemmer.pyx
  • python/pylibcudf/pylibcudf/nvtext/tokenize.pyx
  • python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyx
  • python/pylibcudf/pylibcudf/partitioning.pyx
  • python/pylibcudf/pylibcudf/quantiles.pyx
  • python/pylibcudf/pylibcudf/reduce.pyx
  • python/pylibcudf/pylibcudf/replace.pyx
  • python/pylibcudf/pylibcudf/reshape.pyx
  • python/pylibcudf/pylibcudf/rolling.pyx
  • python/pylibcudf/pylibcudf/round.pyx
  • python/pylibcudf/pylibcudf/scalar.pyx
  • python/pylibcudf/pylibcudf/search.pyx
  • python/pylibcudf/pylibcudf/sorting.pyx
  • python/pylibcudf/pylibcudf/stream_compaction.pyx
  • python/pylibcudf/pylibcudf/strings/attributes.pyx
  • python/pylibcudf/pylibcudf/strings/capitalize.pyx
  • python/pylibcudf/pylibcudf/strings/case.pyx
  • python/pylibcudf/pylibcudf/strings/char_types.pyx
  • python/pylibcudf/pylibcudf/strings/combine.pyx
  • python/pylibcudf/pylibcudf/strings/contains.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyx
  • python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyx
  • python/pylibcudf/pylibcudf/strings/extract.pyx
  • python/pylibcudf/pylibcudf/strings/find.pyx
  • python/pylibcudf/pylibcudf/strings/find_multiple.pyx
  • python/pylibcudf/pylibcudf/strings/findall.pyx
  • python/pylibcudf/pylibcudf/strings/padding.pyx
  • python/pylibcudf/pylibcudf/strings/repeat.pyx
  • python/pylibcudf/pylibcudf/strings/replace.pyx
  • python/pylibcudf/pylibcudf/strings/replace_re.pyx
  • python/pylibcudf/pylibcudf/strings/reverse.pyx
  • python/pylibcudf/pylibcudf/strings/slice.pyx
  • python/pylibcudf/pylibcudf/strings/split/partition.pyx
  • python/pylibcudf/pylibcudf/strings/split/split.pyx
  • python/pylibcudf/pylibcudf/strings/strip.pyx
  • python/pylibcudf/pylibcudf/strings/translate.pyx
  • python/pylibcudf/pylibcudf/strings/wrap.pyx
  • python/pylibcudf/pylibcudf/table.pyx
  • python/pylibcudf/pylibcudf/table_equality.pyx
  • python/pylibcudf/pylibcudf/transform.pyx
  • python/pylibcudf/pylibcudf/transpose.pyx
  • python/pylibcudf/pylibcudf/types.pyx
  • python/pylibcudf/pylibcudf/unary.pyx
  • python/pylibcudf/pylibcudf/utils.pyx

Comment thread python/pylibcudf/pylibcudf/column.pyx Outdated
Comment thread python/pylibcudf/pylibcudf/concatenate.pyx
Comment thread python/pylibcudf/pylibcudf/io/parquet.pyx Outdated
Comment thread python/pylibcudf/pylibcudf/io/types.pyx
Comment thread python/pylibcudf/pylibcudf/strings/translate.pyx
obj: ArrowLike,
dtype: DataType | None = None,
object stream=None,
object stream: CudaStreamLike | None = None,

@coderabbitai coderabbitai Bot Aug 13, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- candidate file structure ---'
ast-grep outline python/pylibcudf/pylibcudf/table.pyx

printf '%s\n' '--- relevant implementation ---'
sed -n '120,245p' python/pylibcudf/pylibcudf/table.pyx
sed -n '300,345p' python/pylibcudf/pylibcudf/table.pyx

printf '%s\n' '--- stream definitions and call sites ---'
rg -n -C 4 'CudaStreamLike|from_table_view_of_arbitrary|def from_arrow|_stream\s*=' python/pylibcudf python -g '*.pyx' -g '*.pxd' -g '*.py' | head -n 500

Repository: NVIDIA/cudf

Length of output: 41079


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path

path = Path("python/pylibcudf/pylibcudf/table.pyx")
text = path.read_text()
lines = text.splitlines()

for i, line in enumerate(lines, 1):
    if "def from_arrow" in line or "from_table_view_of_arbitrary" in line or "_stream" in line:
        start = max(1, i - 8)
        end = min(len(lines), i + 14)
        print(f"--- {path}:{start}-{end} ---")
        for n in range(start, end + 1):
            print(f"{n}: {lines[n-1]}")
PY

printf '%s\n' '--- all stream-like definitions ---'
rg -n -C 5 'CudaStreamLike|class Stream|cdef class Stream|def.*stream|stream_from' python -g '*.pyx' -g '*.pxd' -g '*.py' | head -n 500

Repository: NVIDIA/cudf

Length of output: 50367


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- utility files ---'
fd -t f -i 'utils' python/pylibcudf | head -n 50

printf '%s\n' '--- exact stream definitions and normalization ---'
rg -n -C 12 'CudaStreamLike|def _get_stream|cpdef _get_stream|cdef _get_stream|_get_stream\(' python/pylibcudf/pylibcudf -g '*.py' -g '*.pyx' -g '*.pxd' | head -n 300

printf '%s\n' '--- Stream declarations ---'
rg -n -C 8 'cdef class Stream|class Stream|cdef Stream|from .*Stream' python/pylibcudf/pylibcudf -g '*.pyx' -g '*.pxd' -g '*.py' | head -n 300

Repository: NVIDIA/cudf

Length of output: 41629


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- focused diff ---'
git diff --unified=12 -- python/pylibcudf/pylibcudf/table.pyx | sed -n '1,220p'

printf '%s\n' '--- direct arbitrary-owner stream conversions ---'
rg -n -C 5 'cdef Stream _stream = <Stream>stream|from_column_view_of_arbitrary' python/pylibcudf/pylibcudf -g '*.pyx' -g '*.pxd' | head -n 250

printf '%s\n' '--- read-only structural verifier ---'
python3 - <<'PY'
from pathlib import Path

text = Path("python/pylibcudf/pylibcudf/table.pyx").read_text()
required = [
    "cdef Stream _stream = _get_stream(stream)",
    "cdef Stream _stream = <Stream>stream",
]
assert required[0] in text
assert required[1] in text

returns = text[text.index("def from_arrow("):text.index("cdef table_view view(self):")]
calls = returns.count("Table.from_table_view_of_arbitrary(")
raw_streams = returns.count("                stream,")
normalized_streams = returns.count("                _stream,")

print({
    "from_arrow_arbitrary_table_calls": calls,
    "raw_stream_arguments": raw_streams,
    "normalized_stream_arguments": normalized_streams,
    "normalizer": "_get_stream(stream)",
    "callee_conversion": "<Stream>stream",
})
assert calls == 2
assert raw_streams == 2
assert normalized_streams == 0
PY

Repository: NVIDIA/cudf

Length of output: 8909


Pass _stream to from_table_view_of_arbitrary.

CudaStreamLike includes objects that implement __cuda_stream__, but the callee performs an unchecked <Stream>stream cast. Both return paths currently pass the unnormalized stream instead of _stream.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/pylibcudf/pylibcudf/table.pyx` at line 135, Update both return paths
that call from_table_view_of_arbitrary to pass the normalized _stream value
instead of the original stream argument, ensuring objects implementing
__cuda_stream__ are converted before the callee’s unchecked cast.

Source: Learnings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a runtime behavior fix rather than a typing/source-annotation change, so I am leaving it out of scope for this PR. It looks reasonable as a separate follow-up if we want Table.from_arrow to accept the full CudaStreamLike contract along that path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vyasr, agreed. This is a valid runtime behavior issue, but it is outside the scope of this typing-only pull request.

Would you like me to open a follow-up GitHub issue for the Table.from_arrow CudaStreamLike normalization path?


🧠 Learnings used
Learnt from: CR
Repo: NVIDIA/cudf PR: 0
File: python/REVIEW_GUIDELINES.md:0-0
Timestamp: 2026-08-12T20:45:50.605Z
Learning: Applies to python/**/pylibcudf/**/*.{pyx,pxd} : - Incorrect CUDA stream handling in Cython bindings

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No issue from this PR, thanks. Since this branch is intentionally scoped to source annotations for generated stubs, I will leave follow-up tracking for that runtime stream-normalization path to maintainers if they want it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@vyasr, understood. No follow-up issue will be created from this PR.


🧠 Learnings used
Learnt from: CR
Repo: NVIDIA/cudf PR: 0
File: python/REVIEW_GUIDELINES.md:0-0
Timestamp: 2026-08-12T20:45:50.605Z
Learning: Applies to python/**/pylibcudf/**/*.{pyx,pxd} : - Incorrect CUDA stream handling in Cython bindings

Learnt from: vyasr
Repo: NVIDIA/cudf PR: 23643
File: python/pylibcudf/pylibcudf/concatenate.pyx:28-32
Timestamp: 2026-08-13T01:27:58.502Z
Learning: For source-annotation-only pull requests affecting Python-facing pylibcudf Cython files, validate changes with `build-pylibcudf-python`, focused `stubgen-pyx` generation, runtime import and type-hint checks for the public typing module, and relevant pre-commit hooks. Do not require generated-stub tests or benchmarks unless the pull request changes runtime behavior.

You are interacting with an AI system.

Comment thread python/pylibcudf/pylibcudf/types.pyx Outdated
)

def all_row_groups(self, ParquetReaderOptions options):
def all_row_groups(self, ParquetReaderOptions options) -> list[int]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: Some of these changes don't introduce a python-like type-annotation for method arguments. Is that because it is not necessary because the type stub generation already knows how to turn ParquetReaderOptions options into options: ParquetReaderOptions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement / enhancement to an existing function non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants