Summary
After PR #398 removes the eager TracerWarning filter from `_warnings.py` (the root-cause fix for the CLI startup regression), three call sites that invoke `torch.onnx.export` (transitively via `export_onnx`/`export_pytorch`) now emit `TracerWarning` to stderr because they have no local `warnings.catch_warnings()` wrapper:
| Path |
Wrapped? |
| `commands/build.py:1060-1061` |
✅ Yes (the wrapping that #398 relies on) |
| `commands/export.py:347` (`winml export` direct CLI) |
❌ No |
| `build/hf.py:216` (called by `winml.modelkit.build.hf.build_hf_model()`) |
❌ No |
| `commands/perf.py` (perf invocation paths) |
❌ No |
Why not in #398
#398's core change is reverting the eager `from torch.jit import TracerWarning` because it imported all of torch (~1.7s) at startup. Wrapping each call site is a separate concern — and the cleanest fix is "wrap once inside `export_pytorch()`" rather than touching every caller.
Recommended fix
Move the `with warnings.catch_warnings(): warnings.filterwarnings("ignore"):` block from `commands/build.py:1060-1061` into `src/winml/modelkit/export/pytorch.py::export_pytorch()` so all callers get the same TracerWarning suppression by default. Removes:
- The duplication (no need to re-wrap at every caller)
- The "remember to add catch_warnings" footgun for new callers
- The "_warnings.py says build.py wraps it" claim that's only partially true
Severity
Low — UX/stderr noise. Functional behavior unaffected. Acknowledged as a known caveat in #398.
Reported by @DingmaomaoBJTU and @timenick in code review of #398.
Summary
After PR #398 removes the eager TracerWarning filter from `_warnings.py` (the root-cause fix for the CLI startup regression), three call sites that invoke `torch.onnx.export` (transitively via `export_onnx`/`export_pytorch`) now emit `TracerWarning` to stderr because they have no local `warnings.catch_warnings()` wrapper:
Why not in #398
#398's core change is reverting the eager `from torch.jit import TracerWarning` because it imported all of torch (~1.7s) at startup. Wrapping each call site is a separate concern — and the cleanest fix is "wrap once inside `export_pytorch()`" rather than touching every caller.
Recommended fix
Move the `with warnings.catch_warnings(): warnings.filterwarnings("ignore"):` block from `commands/build.py:1060-1061` into `src/winml/modelkit/export/pytorch.py::export_pytorch()` so all callers get the same TracerWarning suppression by default. Removes:
Severity
Low — UX/stderr noise. Functional behavior unaffected. Acknowledged as a known caveat in #398.
Reported by @DingmaomaoBJTU and @timenick in code review of #398.