fix: declare psutil as a runtime dependency#937
Merged
Conversation
DingmaomaoBJTU
approved these changes
Jun 23, 2026
DingmaomaoBJTU
left a comment
Collaborator
There was a problem hiding this comment.
The fix is correct and complete. memory_tracker.py imports psutil unconditionally at module level (line 13), so any user running winml perf / --monitor / --memory on a clean install hits a hard ModuleNotFoundError. The dependency was previously declared only as a dev type stub (types-psutil>=7.2.2 in [dependency-groups].dev), so the published wheel's Requires-Dist omitted it entirely.
The single-line addition of psutil>=7 to [project].dependencies is the right surgical fix:
- Placement is alphabetically correct (between
pandasandpydantic). - The
>=7lower bound aligns with the existingtypes-psutil>=7.2.2stub and the stablepsutil.Process.memory_info().rssAPI used in the tracker. - No other runtime code paths need updating; the underlying logic was always correct.
Approve.
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.
Summary
winml perfcrashes on a clean install withNo module named 'psutil'becausesrc/winml/modelkit/session/monitor/memory_tracker.pyimportspsutilat module level, and the perf flow imports that module unconditionally.psutilwas never declared in[project].dependencies— only the dev type stubtypes-psutilis present — so the published wheel'sRequires-Distomits it, breakingwinml perf(and--monitor/--memory) out-of-the-box for every user.Regression from #861 (
feat: add --memory flag);memory_tracker.pydid not exist in v0.1.0, sowinml perfwas unaffected there. Installingpsutilmanually confirms perf/build/--monitorotherwise work correctly — the only defect is the missing dependency declaration.Change
Add
psutil>=7to[project].dependencies(aligns with the existingtypes-psutil>=7.2.2stub).Targeting
release/v0.2.0directly as a release hotfix;mainwill pick it up via the post-release merge-back.Closes #936