Skip to content

Commit

Permalink
Merge pull request #66 from nschloe/modernize
Browse files Browse the repository at this point in the history
Modernize
  • Loading branch information
nschloe authored Apr 2, 2020
2 parents 5a83f34 + 4481d12 commit 4d438eb
Show file tree
Hide file tree
Showing 10 changed files with 763 additions and 102 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: "10.x"
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Lint with flake8
run: |
pip install flake8
Expand All @@ -32,18 +32,20 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/setup-python@v1
with:
python-version: "3.x"
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Install package
run: |
python -m pip install --upgrade pip
pip install .
- name: Test with pytest
run: |
pip install pytest pytest-cov
pytest --cov tuna
- name: Submit to codecov
run: bash <(curl -s https://codecov.io/bash)
# - name: Submit to codecov
# run: bash <(curl -s https://codecov.io/bash)
695 changes: 674 additions & 21 deletions LICENSE.txt

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
VERSION=$(shell python3 -c "import tuna; print(tuna.__version__)")
VERSION=$(shell python3 -c "from configparser import ConfigParser; p = ConfigParser(); p.read('setup.cfg'); print(p['metadata']['version'])")

default:
@echo "\"make publish\"?"

tag:
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
@echo "Tagging v$(VERSION)..."
git tag v$(VERSION)
git push --tags
curl -H "Authorization: token `cat $(HOME)/.github-access-token`" -d '{"tag_name": "$(VERSION)"}' https://api.github.com/repos/nschloe/tuna/releases
# @echo "Tagging v$(VERSION)..."
# git tag v$(VERSION)
# git push --tags
curl -H "Authorization: token `cat $(HOME)/.github-access-token`" -d '{"tag_name": "v$(VERSION)"}' https://api.github.com/repos/nschloe/tuna/releases

dep:
npm install
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ tuna is a modern, lightweight Python profile viewer inspired by
profiles, has no Python dependencies, uses [d3](https://d3js.org/) and
[bootstrap](https://getbootstrap.com/), and avoids
[certain](https://github.com/jiffyclub/snakeviz/issues/111)
[errors](https://github.com/jiffyclub/snakeviz/issues/112) present in SnakeViz.
[errors](https://github.com/jiffyclub/snakeviz/issues/112) present in SnakeViz (see
below).

Create a runtime profile with
```
Expand Down Expand Up @@ -47,21 +48,18 @@ import time
def a(t0, t1):
c(t0)
d(t1)
return


def b():
return a(1, 4)
a(1, 4)


def c(t):
time.sleep(t)
return


def d(t):
time.sleep(t)
return


if __name__ == "__main__":
Expand All @@ -75,8 +73,14 @@ total of 5 seconds when called from `a()`, and likewise `d()`. The information t
program spent more time in `c()` when called in `root -> a() -> c()` than when called in
`root -> b() -> a() -> c()` is not present in the profile.

tuna only displays the part of the timed call tree that can be deduced from the profile:
![](https://nschloe.github.io/tuna/foo.png)
tuna only displays the part of the timed call tree that can be deduced from the profile.
SnakeViz, on the other hand, tries to construct the entire call tree, but ends up
providing lots of _wrong_ timings.

| ![](https://nschloe.github.io/tuna/snakeviz-example-wrong.png) | ![](https://nschloe.github.io/tuna/foo.png) |
|:----:|:----:|
| SnakeViz output. **Wrong.** | tuna output. Only shows what can be retrieved from the
profile. |

### Installation

Expand All @@ -96,5 +100,4 @@ pytest
```

### License

tuna is published under the [MIT license](https://en.wikipedia.org/wiki/MIT_License).
This software is published under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.en.html).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "tuna",
"dependencies": {
"bootstrap": "4.4.1",
"d3": "5.15.0"
"d3": "5.15.1"
}
}
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
47 changes: 47 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[metadata]
name = tuna
version = 0.4.0
author = Nico Schlömer
email = nico.schloemer@gmail.com
description = Visualize Python performance profiles
url = https://github.com/nschloe/tuna
project_urls =
Code=https://github.com/nschloe/tuna
Issues=https://github.com/nschloe/tuna/issues
long_description = file: README.md
long_description_content_type = text/markdown
license = GPLv3
platforms = any
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Topic :: Software Development :: User Interfaces
Topic :: Utilities

[options]
packages = find:
# importlib_metadata can be removed when we support Python 3.8+ only
install_requires =
importlib_metadata
python_requires = >=3.6
setup_requires =
setuptools>=42
wheel

[options.entry_points]
console_scripts =
tuna = tuna.cli:main

[options.package_data]
* =
web/*.html
web/static/*.js
web/static/*.css
web/static/favicon256.png
46 changes: 3 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,4 @@
import os
from setuptools import setup

from setuptools import find_packages, setup

# https://packaging.python.org/single_source_version/
base_dir = os.path.abspath(os.path.dirname(__file__))
about = {}
with open(os.path.join(base_dir, "tuna", "__about__.py"), "rb") as f:
exec(f.read(), about)


setup(
name="tuna",
version=about["__version__"],
author=about["__author__"],
author_email=about["__author_email__"],
packages=find_packages(),
description="Visualize Python profiles in the browser",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://github.com/nschloe/tuna",
license=about["__license__"],
platforms="any",
python_requires=">=3.6",
classifiers=[
about["__status__"],
about["__license__"],
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: User Interfaces",
],
entry_points={"console_scripts": ["tuna = tuna.cli:main"]},
package_data={
"tuna": [
"web/*.html",
"web/static/*.js",
"web/static/*.css",
"web/static/favicon256.png",
]
},
)
if __name__ == "__main__":
setup()
17 changes: 10 additions & 7 deletions tuna/__about__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
__author__ = "Nico Schlömer"
__author_email__ = "nico.schloemer@gmail.com"
__copyright__ = f"Copyright (c) 2018-2020, {__author__} <{__author_email__}>"
__license__ = "License :: OSI Approved :: MIT License"
__version__ = "0.3.7"
__maintainer__ = "Nico Schlömer"
__status__ = "Development Status :: 5 - Production/Stable"
try:
# Python 3.8
from importlib import metadata
except ImportError:
import importlib_metadata as metadata

try:
__version__ = metadata.version("tuna")
except Exception:
__version__ = "unknown"
12 changes: 1 addition & 11 deletions tuna/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
from . import cli
from .__about__ import (
__author__,
__author_email__,
__license__,
__status__,
__version__,
)
from .__about__ import __version__
from .main import read_import_profile

__all__ = [
"__author__",
"__author_email__",
"__license__",
"__version__",
"__status__",
"cli",
"read_import_profile",
]

0 comments on commit 4d438eb

Please sign in to comment.