[Python] Document user_data parameter for Session.run_async#28639
Open
adityasingh2400 wants to merge 1 commit into
Open
[Python] Document user_data parameter for Session.run_async#28639adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20367. The
user_dataargument has been part ofSession.run_asyncsince the API was introduced in #16760, but the docstring never described it and the example call dropped it, so users readinghelp(sess.run_async)had to read the pybind layer to figure out what to pass.This change documents
user_dataas an opaque Python object that ONNX Runtime forwards unchanged to the supplied callback, which matches the actual behavior inonnxruntime_pybind_state.ccwhere the value is stored on theAsyncResourceand 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 inonnxruntime_test_python.py::test_run_async.The example is updated to actually pass a
user_dataargument so that copy-pasting it no longer raisesTypeError: run_async() missing 1 required positional argument. Documentation only, no behavior or signature change.