Closed ChrisDAT20 closed 2 hours ago
Memray depends on Textual, so that's why it's getting imported. skops
is iterating over all the imported modules and trying to get an agm
attribute from each. The textual.widgets
module raises an ImportError
rather than an AttributeError
when you try to get an attribute from it that it doesn't have, and skops.io._utils
is not prepared to deal with that exception. I think this is a bug in Textual, but it's certainly not a bug in Memray. I think this issue should be reported on the https://github.com/Textualize/textual repo instead.
Ok. Somehow this ImportError
has no effect when the app is executed outside of Memray.
That's because the textual.widgets
module is being imported by Memray, and not being imported when you're not running Memray. If you add an import textual.widgets
to your code, you'll see this error even when not running Memray.
Ok, thank you for your explanations. Is that agm
attribute some convention which should be there?
No, that seems to be something related to the working of the skops
module. It seems to be trying to figure out which module provides an particular object, or something like that, and doing a linear scan over all the modules to see if they contain that object.
Textual has fixed the bug, and the fix will be included in the next release.
Is there an existing issue for this?
Current Behavior
I want to profile a FastAPI based application, and use
memray run -o memory.log /usr/local/bin/uvicorn ...
to run the application. However, memray stops by throwing the following exception:I do not use the package
textual
not does the packageskops.io
. Why is that package imported? These versions are installed atm, does memray require another version?Expected Behavior
memray does not lead to a import problem, when the observed does not have such issue.
Steps To Reproduce
see current behavior
Memray Version
1.14.0
Python Version
3.9
Operating System
Linux
Anything else?