Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improvements from 2.x.x #14

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
8 changes: 4 additions & 4 deletions pycallgraph/memory_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading