From 40add94be8a370f6ce99d2c5655f1a44bc58d8bc Mon Sep 17 00:00:00 2001 From: Lewis Cowles Date: Sun, 31 Mar 2024 08:48:39 +0100 Subject: [PATCH 1/2] fix: memory profiler psutil api updates --- pycallgraph/memory_profiler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pycallgraph/memory_profiler.py b/pycallgraph/memory_profiler.py index 4771f12..27a158e 100644 --- a/pycallgraph/memory_profiler.py +++ b/pycallgraph/memory_profiler.py @@ -23,7 +23,7 @@ def _get_memory(pid): process = psutil.Process(pid) try: - mem = float(process.get_memory_info()[0]) / (1024 ** 2) + mem = float(process.memory_info()[0]) / (1024 ** 2) except psutil.AccessDenied: mem = -1 return mem @@ -422,10 +422,10 @@ def magic_mprun(self, parameter_s=''): from io import StringIO # Local imports to avoid hard dependency. - from packaging.version import parse + from distutils.version import LooseVersion import IPython - ipython_version = parse(IPython.__version__) - if ipython_version < parse('0.11'): + ipython_version = LooseVersion(IPython.__version__) + if ipython_version < '0.11': from IPython.genutils import page from IPython.ipstruct import Struct from IPython.ipapi import UsageError From 915f0d2f2ae70321aca42e62e35fbee9667863d8 Mon Sep 17 00:00:00 2001 From: Lewis Cowles Date: Sun, 31 Mar 2024 08:53:54 +0100 Subject: [PATCH 2/2] ci: add curated tests --- .github/workflows/ci.yml | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3221e42..1f631cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,3 +97,75 @@ jobs: run: | coverage run --source pycallgraph,scripts -m pytest coverage report -m + curated_tests: + needs: + - setup + strategy: + matrix: + python_version: ["3.8.18", "3.9.19", "3.10.14", "3.11.8", "3.12.2"] + fail-fast: false + name: Curated Tests - Python ${{ matrix.python_version }} + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python_version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python_version }} + cache: 'pip' + cache-dependency-path: | + requirements/development.txt + - name: Install dependencies + run: | + python -m pip install -r requirements/development.txt + - name: Install system dependencies + run: sudo apt update -yqq && sudo apt install -yqq graphviz + - name: Run tests + run: | + export PYTHONPATH=$PYTHONPATH:$(pwd) + echo "" + echo "" + echo "" + echo "#" + echo "# Help command test" + echo "#" + scripts/pycallgraph --help + echo "" + echo "" + echo "" + echo "#" + echo "# Example from docs with real existing file" + echo "#" + python scripts/pycallgraph graphviz -- examples/graphviz/basic.py + echo "" + echo "" + echo "" + echo "#" + echo "# Basic using example file and no groups" + echo "#" + python scripts/pycallgraph --no-groups graphviz -- examples/graphviz/basic.py + echo "" + echo "" + echo "" + echo "#" + echo "# Basic using example file tracing standard library calls also" + echo "#" + python scripts/pycallgraph --stdlib graphviz -- examples/graphviz/basic.py + echo "" + echo "" + echo "" + echo "#" + echo "# Basic using example with experimental memory tracking (without psutil)" + echo "#" + python scripts/pycallgraph --memory graphviz -- examples/graphviz/basic.py + echo "" + echo "" + echo "" + pip install psutil + echo "#" + echo "# Basic using example with experimental memory tracking (with psutil)" + echo "#" + python scripts/pycallgraph --memory graphviz -- examples/graphviz/basic.py + echo "" + echo "" + echo "" \ No newline at end of file