Skip to content

Override __repr__ for some proto classes (#7259)#7314

Merged
justinchuby merged 2 commits intorel-1.19.1from
justinchu/pick-38c3fb
Sep 23, 2025
Merged

Override __repr__ for some proto classes (#7259)#7314
justinchuby merged 2 commits intorel-1.19.1from
justinchu/pick-38c3fb

Conversation

@justinchuby
Copy link
Copy Markdown
Member

Override repr for some proto classes to make it more efficient
because. Prior to this change, calling repr on a big model proto would
cause a costly serialization to run which dumps a lot of text. This
change makes repr(model_proto) to return
'<onnx.onnx_ml_pb2.ModelProto object at 0x7572f254ada0>'.

Users can still call str() model proto classes to obtain a prototext
representation.

This also does not affect print() because print calls str().

Fix #4738


Signed-off-by: Justin Chu justinchuby@users.noreply.github.com

Override __repr__ for some proto classes to make it more efficient
because. Prior to this change, calling repr on a big model proto would
cause a costly serialization to run which dumps a lot of text. This
change makes `repr(model_proto)` to return
`'<onnx.onnx_ml_pb2.ModelProto object at 0x7572f254ada0>'`.

Users can still call `str()` model proto classes to obtain a prototext
representation.

This also does not affect `print()` because print calls `str()`.

Fix #4738

---------

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (rel-1.19.1@6130272). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@              Coverage Diff              @@
##             rel-1.19.1    #7314   +/-   ##
=============================================
  Coverage              ?   53.76%           
=============================================
  Files                 ?      512           
  Lines                 ?    32217           
  Branches              ?     2948           
=============================================
  Hits                  ?    17321           
  Misses                ?    14123           
  Partials              ?      773           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justinchuby justinchuby enabled auto-merge (squash) September 22, 2025 19:08
Comment thread onnx/__init__.py
@github-project-automation github-project-automation Bot moved this from In progress to Reviewer approved in PR Tracker Sep 22, 2025
@justinchuby
Copy link
Copy Markdown
Member Author

I am going to merge this PR, and if desired create a follow up

@justinchuby justinchuby enabled auto-merge (squash) September 22, 2025 22:38
@justinchuby justinchuby merged commit 1d5b64b into rel-1.19.1 Sep 23, 2025
34 of 35 checks passed
@justinchuby justinchuby deleted the justinchu/pick-38c3fb branch September 23, 2025 04:17
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in PR Tracker Sep 23, 2025
@yuanyao-nv yuanyao-nv mentioned this pull request Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants