-
Notifications
You must be signed in to change notification settings - Fork 433
Description
Is there an existing proposal for this?
- I have searched the existing proposals
Is your feature request related to a problem?
Currently memray has a comprehensive CLI which is probably the recommended way to use. It also provides a context to use it inline for cases where CLI is not applicable. However, the output could only be either a file path or a socket.
In our use case, we want to track memory usage on many python runners on remote clusters - CLI is obviously not applicable. We also rely on the only communication channel we can use in our framework (which means a separate socket is not available).
In theory, we could dump to a file, read it as bytes and send it, but it seems a bit more complicated than it needs to be. Also when we read it, we probably need to dump it to a file again and utilize CLI to read it.
Is there a way to add more Python native APIs so we can save the data as a pickleable object (or json) and send it through our own channels? Also maybe a way to generate a traditional pure text report that could be used in python script directly?
Describe the solution you'd like
They easy thing would be to support at least
data = io.BytesIO()
with memray.Tracker(data):
...Or
with memray.Tracker() as tracker:
...
data = tracker.get_data()It would be nice to be able to generate a report like
memray.show(data)Alternatives you considered
No response