ianozsvald / ipython_memory_usage Goto Github PK
View Code? Open in Web Editor NEWIPython tool to report memory usage deltas for every command you type
License: MIT License
IPython tool to report memory usage deltas for every command you type
License: MIT License
When calling start_watching_memory consecutively unclear output is printed:
In [1]: import ipython_memory_usage.ipython_memory_usage as imu
In [2]: import numpy as np
In [3]: imu.start_watching_memory()
In [3] used 17.2734 MiB RAM in 174.15s, peaked 0.00 MiB above current, total RAM usage 68.12 MiB
In [4]: imu.start_watching_memory()
In [4] used 0.0977 MiB RAM in 0.10s, peaked 0.00 MiB above current, total RAM usage 68.21 MiB
In [4] used -0.0117 MiB RAM in 0.21s, peaked 0.01 MiB above current, total RAM usage 68.20 MiB
It's unclear what the output in the last call refers to.
perf
still works? Ian can't install it on his 4.9 kernelAs noted in the README.md
we have %run -i ipython_memory_usage_perf.py
but Ian can't run perf
on his kernel - can someone please check if this code still works?
We need a conda dependency on memory_profiler and IPython to mirror the setup.py
This would help with making self-contained conda-forge packages.
Re-raise if the import is done outside of the ipython environment to give the user a clue. With python
this lacks the appropriate attributes:
$ python
Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipython_memory_usage
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ian/workspace/personal_projects/hackathon_ipython_memory_usage/ipython_memory_usage/src/ipython_memory_usage/__init__.py", line 5, in <module>
import ipython_memory_usage.ipython_memory_usage as imu
File "/home/ian/workspace/personal_projects/hackathon_ipython_memory_usage/ipython_memory_usage/src/ipython_memory_usage/ipython_memory_usage.py", line 19, in <module>
input_cells = get_ipython().user_ns['In']
AttributeError: 'NoneType' object has no attribute 'user_ns'
Using IPython is good:
$ ipython
Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import ipython_memory_usage
In [2]:
Rather than print that the user should run %start_imu
, instead kick it off and tell them how to stop it
It would be nice to retrieve the memory delta, peak and usage values after executing a command in IPython. After looking at the code, it seems that these are measured inside a thread, making accessing them a bit difficult.
When trying to debug notebook with XPython kernel (used for debugging in JupyterLab) import was fail:
import ipython_memory_usage
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
In [8]:
Line 3: import ipython_memory_usage
File /home/user/anaconda3/lib/python3.8/site-packages/ipython_memory_usage/__init__.py, in <module>:
Line 5: import ipython_memory_usage.ipython_memory_usage as imu
File /home/user/anaconda3/lib/python3.8/site-packages/ipython_memory_usage/ipython_memory_usage.py, in <module>:
Line 19: input_cells = get_ipython().user_ns['In']
KeyError: 'In'
Try switching to support wheels https://pythonwheels.com/ and move the subfolder up 1 level
Thanks for publishing this useful package! Any interest in uploading it to PyPI so it's easier for users to discover and install?
Rather than showing the maximal cpu usage, instead consider making a graphical representation if <17 cores (just 'cos that'd fit ok on screen).
Consider also making a time-series sparkline memory plot, so we can see if anything weird happens with that maximal usage during the cell's execution.
a = np.sqrt(a)
example, the behaviour seems to have changed, fix the docd = a * b + c
behaviour has changed too, fix the docThis looks like a change in numpy behaviour:
In [4]: a = np.ones(1e7)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-a702330132ac> in <module>()
----> 1 a = np.ones(1e7)
~/anaconda3/envs/ipython_memory_usage/lib/python3.6/site-packages/numpy/core/numeric.py in ones(shape, dtype, order)
186
187 """
--> 188 a = empty(shape, dtype, order)
189 multiarray.copyto(a, 1, casting='unsafe')
190 return a
TypeError: 'float' object cannot be interpreted as an integer
In [4] used 0.6836 MiB RAM in 0.17s, peaked 0.00 MiB above current, total RAM usage 55.93 MiB
In [5]: a = np.ones(int(1e7))
In [5] used 76.1758 MiB RAM in 0.12s, peaked 0.00 MiB above current, total RAM usage 132.11 MiB
Ian to check https://github.com/cpcloud/ipython-autotime
Add a docstring to the package and add %ipython_memory_usage_start
to give the user a clue.
Update init.py with a """docstring that tells the user how to get started""" so that when they do:
import ipython_memory_usage
ipython_memory_usage?
they get a couple of lines telling them to start with %ipython_memory_usage_start
or %ipython_memory_usage_stop
to show memory changes on each typed command
https://github.com/ianozsvald/ipython_memory_usage/blob/master/src/ipython_memory_usage/ipython_memory_usage.py was written in Python 2 several years ago. You'll see from __future__
imports - these could do with being removed!
The functions lack useful 1-liner docstrings, these could be added.
There's a __version__
number in the file, that ought to be updated, maybe to v 1.1?
Double check that the README is still valid after you've refactored
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.