Skip to content

Conversation

@Adraub
Copy link

@Adraub Adraub commented Oct 31, 2025

When running python -m tf2onnx.convert to convert a model i got this warning :

<frozen runpy>:128: RuntimeWarning: 'tf2onnx.convert' found in sys.modules after import of package 'tf2onnx', but prior to execution of 'tf2onnx.convert'; this may result in unpredictable behaviour

I looked for the root reason, and it seems most module are eagerly imported directly in the __init__.py while nothing seems to justify it.
It also happened to others (see #1831) and can be confusing when your conversion is going wrong.
I think these lines should be removed, i ran the tests and found no regressions.

…rt of package 'tf2onnx', but prior to execution of 'tf2onnx.convert'

Signed-off-by: Adraub <[email protected]>
Fixes some UT missing some submodules after removing heavy import

Signed-off-by: Adraub <[email protected]>
@Adraub
Copy link
Author

Adraub commented Nov 3, 2025

I added lazy loading of the submodules, it fixes the initial warning and the UT error

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.

2 participants