Skip to content

[Python] Document user_data parameter for Session.run_async#28639

Open
adityasingh2400 wants to merge 1 commit into
microsoft:mainfrom
adityasingh2400:docs/run-async-user-data
Open

[Python] Document user_data parameter for Session.run_async#28639
adityasingh2400 wants to merge 1 commit into
microsoft:mainfrom
adityasingh2400:docs/run-async-user-data

Conversation

@adityasingh2400
Copy link
Copy Markdown

Closes #20367. The user_data argument has been part of Session.run_async since the API was introduced in #16760, but the docstring never described it and the example call dropped it, so users reading help(sess.run_async) had to read the pybind layer to figure out what to pass.

This change documents user_data as an opaque Python object that ONNX Runtime forwards unchanged to the supplied callback, which matches the actual behavior in onnxruntime_pybind_state.cc where the value is stored on the AsyncResource and handed back to the callback verbatim. The callback description is also adjusted from "accepts an array of results and a status string" to the three-argument signature the callback already uses (results, user_data, err), so the docstring stops contradicting itself and the existing test in onnxruntime_test_python.py::test_run_async.

The example is updated to actually pass a user_data argument so that copy-pasting it no longer raises TypeError: run_async() missing 1 required positional argument. Documentation only, no behavior or signature change.

Fixes microsoft#20367.

The user_data parameter has been part of the run_async signature since it
was introduced in microsoft#16760, but the docstring did not describe it, and the
example call dropped it. Update the docstring to describe user_data as an
opaque Python object that ONNX Runtime forwards unchanged to the callback,
align the callback description with the three-argument signature it
already has, and fix the example to actually pass a user_data value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Documentation] run_async missing documention for user_data parameter

1 participant