zeropybench 0.2__tar.gz → 0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. zeropybench-0.4/.github/workflows/ci.yml +82 -0
  2. {zeropybench-0.2 → zeropybench-0.4}/.github/workflows/release.yml +14 -4
  3. zeropybench-0.4/.gitignore +14 -0
  4. zeropybench-0.4/.pre-commit-config.yaml +46 -0
  5. zeropybench-0.4/.readthedocs.yaml +28 -0
  6. {zeropybench-0.2 → zeropybench-0.4}/PKG-INFO +6 -2
  7. {zeropybench-0.2 → zeropybench-0.4}/README.md +5 -1
  8. zeropybench-0.4/docs/source/api/index.md +10 -0
  9. zeropybench-0.4/docs/source/conf.py +91 -0
  10. zeropybench-0.4/docs/source/developer-guide.md +124 -0
  11. zeropybench-0.4/docs/source/index.md +47 -0
  12. zeropybench-0.4/docs/source/user-guide/getting-started.ipynb +196 -0
  13. zeropybench-0.4/docs/source/user-guide/installation.md +75 -0
  14. zeropybench-0.4/docs/source/user-guide/jax-examples.ipynb +214 -0
  15. {zeropybench-0.2 → zeropybench-0.4}/pyproject.toml +52 -2
  16. {zeropybench-0.2 → zeropybench-0.4}/src/zeropybench/_benchmark.py +13 -7
  17. {zeropybench-0.2 → zeropybench-0.4}/src/zeropybench/_jax.py +5 -3
  18. {zeropybench-0.2 → zeropybench-0.4}/uv.lock +685 -25
  19. zeropybench-0.2/.github/workflows/ci.yml +0 -58
  20. zeropybench-0.2/.gitignore +0 -13
  21. zeropybench-0.2/.pre-commit-config.yaml +0 -66
  22. {zeropybench-0.2 → zeropybench-0.4}/LICENSE +0 -0
  23. {zeropybench-0.2 → zeropybench-0.4}/docs/source/_static/logo.svg +0 -0
  24. {zeropybench-0.2 → zeropybench-0.4}/src/zeropybench/__init__.py +0 -0
  25. {zeropybench-0.2 → zeropybench-0.4}/tests/__init__.py +0 -0
  26. {zeropybench-0.2 → zeropybench-0.4}/tests/test_jax.py +0 -0
  27. {zeropybench-0.2 → zeropybench-0.4}/tests/test_python.py +0 -0
@@ -0,0 +1,82 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+
17
+ pre-commit:
18
+ name: Pre-commit
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: j178/prek-action@v1
23
+
24
+ test:
25
+ name: Run tests on Python ${{ matrix.python.version }}
26
+ runs-on: ubuntu-latest
27
+ strategy:
28
+ matrix:
29
+ python:
30
+ - version: '3.10'
31
+ jax: '>=0.4,<0.5'
32
+ - version: '3.11'
33
+ jax: '>=0.4,<0.5'
34
+ - version: '3.12'
35
+ jax: '>=0.5,<0.6'
36
+ - version: '3.13'
37
+ jax: '>=0.5,<0.6'
38
+ - version: '3.14'
39
+ jax: '>=0.8'
40
+
41
+ steps:
42
+ - name: Checkout code
43
+ uses: actions/checkout@v4
44
+
45
+ - name: Set up Python ${{ matrix.python.version }}
46
+ uses: actions/setup-python@v5
47
+ with:
48
+ python-version: ${{ matrix.python.version }}
49
+
50
+ - name: Install uv
51
+ uses: astral-sh/setup-uv@v7
52
+ with:
53
+ enable-cache: true
54
+
55
+ - name: Build wheel
56
+ run: uv build --wheel
57
+
58
+ - name: Install project's wheel and dependencies
59
+ run: |
60
+ uv sync --locked --no-install-project
61
+ uv pip install dist/zeropybench-*.whl
62
+ uv pip install "jax${{ matrix.python.jax }}"
63
+
64
+ - name: Run unit tests
65
+ run: uv run pytest -v --cov=zeropybench --cov-report=xml tests
66
+
67
+ - name: Install system dependencies
68
+ run: |
69
+ sudo apt-get update
70
+ sudo apt-get install -y graphviz
71
+
72
+ - name: Run notebook tests
73
+ if: matrix.python.version == '3.14'
74
+ run: uv run pytest -v docs
75
+
76
+ - name: Upload coverage to Codecov
77
+ if: matrix.python.version == '3.12'
78
+ uses: codecov/codecov-action@v5
79
+ with:
80
+ token: ${{ secrets.CODECOV_TOKEN }}
81
+ files: coverage.xml
82
+ fail_ci_if_error: false
@@ -17,22 +17,26 @@ jobs:
17
17
  - name: Checkout repository
18
18
  uses: actions/checkout@v4
19
19
  with:
20
- fetch-depth: 0
20
+ fetch-depth: 0 # Full history for dynamic versioning
21
21
 
22
22
  - name: Set up Python
23
23
  uses: actions/setup-python@v5
24
24
  with:
25
- python-version: '3.10'
25
+ python-version: '3.12'
26
26
 
27
27
  - name: Install uv
28
28
  uses: astral-sh/setup-uv@v6
29
29
  with:
30
30
  enable-cache: true
31
31
 
32
- - name: Check tag of last commit
32
+ - name: Debug Git tags and versioning
33
33
  run: |
34
+ echo "Git tags:"
35
+ git tag -l
34
36
  echo "Current tag:"
35
- git describe --tags --exact-match HEAD
37
+ git describe --tags --exact-match HEAD || echo "No exact tag match"
38
+ echo "Version info:"
39
+ git describe --tags --always
36
40
 
37
41
  - name: Clean uv cache for dynamic versioning
38
42
  run: uv cache clean
@@ -40,5 +44,11 @@ jobs:
40
44
  - name: Build package
41
45
  run: uv build
42
46
 
47
+ - name: Verify build artifacts
48
+ run: |
49
+ ls -la dist/
50
+ echo "Built artifacts:"
51
+ find dist/ -name "*.whl" -o -name "*.tar.gz" | head -10
52
+
43
53
  - name: Publish to PyPI
44
54
  uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,14 @@
1
+ /.idea/
2
+ /.venv/
3
+ /.vscode/
4
+ /build/
5
+ /dist/
6
+ /docs/build/
7
+
8
+ .ipynb_checkpoints/
9
+ __pycache__/
10
+
11
+ .coverage
12
+ .DS_Store
13
+ *.py[cod]
14
+ coverage.xml
@@ -0,0 +1,46 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: "v0.11.8"
4
+ hooks:
5
+ - id: ruff
6
+ name: ruff linting
7
+ - id: ruff-format
8
+ name: ruff formatting
9
+
10
+ - repo: https://github.com/nbQA-dev/nbQA
11
+ rev: "1.9.1"
12
+ hooks:
13
+ - id: nbqa-ruff
14
+ name: nbqa ruff linting
15
+ args: [--fix, --ignore=E402]
16
+ - id: nbqa-ruff-format
17
+ name: nbqa ruff formatting
18
+
19
+ - repo: https://github.com/pre-commit/pre-commit-hooks
20
+ rev: 'v5.0.0'
21
+ hooks:
22
+ - id: trailing-whitespace
23
+ - id: end-of-file-fixer
24
+ - id: check-merge-conflict
25
+
26
+ - repo: https://github.com/kynan/nbstripout
27
+ rev: 0.6.1
28
+ hooks:
29
+ - id: nbstripout
30
+ name: notebook stripping
31
+ args: [--extra-keys=metadata.language_info.version]
32
+
33
+ - repo: https://github.com/pre-commit/mirrors-mypy
34
+ rev: 'v1.15.0'
35
+ hooks:
36
+ - id: mypy
37
+ additional_dependencies:
38
+ - jax
39
+ - polars
40
+ - matplotlib
41
+ args:
42
+ - --strict
43
+ - --show-error-codes
44
+ - --enable-error-code=ignore-without-code
45
+ - --allow-untyped-calls
46
+ files: ^src/zeropybench/
@@ -0,0 +1,28 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version, and other tools you might need
8
+ build:
9
+ os: ubuntu-24.04
10
+ apt_packages:
11
+ - graphviz
12
+ tools:
13
+ python: "3.14"
14
+ jobs:
15
+ install:
16
+ - pip install --upgrade pip
17
+ - pip install --group docs .
18
+
19
+ # Build documentation in the "docs/" directory with Sphinx
20
+ sphinx:
21
+ builder: html
22
+ configuration: docs/source/conf.py
23
+ fail_on_warning: false
24
+
25
+ # Set the version of Python and other tools you might need
26
+ submodules:
27
+ include: all
28
+ recursive: true
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zeropybench
3
- Version: 0.2
3
+ Version: 0.4
4
4
  Summary: A multidimensional benchmarking library with minimal overhead
5
5
  Author: Pierre Chanial
6
6
  License-Expression: MIT
@@ -31,6 +31,8 @@ Description-Content-Type: text/markdown
31
31
  [![Continuous integration](https://github.com/pchanial/zeropybench/actions/workflows/ci.yml/badge.svg)](https://github.com/pchanial/zeropybench/actions/workflows/ci.yml)
32
32
  [![Coverage](https://codecov.io/gh/pchanial/zeropybench/graph/badge.svg)](https://codecov.io/gh/pchanial/zeropybench)
33
33
 
34
+ <!-- Start common text with source/index.md -->
35
+
34
36
  **zeropybench** is a Python benchmarking library with zero overhead, designed for multidimensional performance analysis.
35
37
 
36
38
  ## Features
@@ -84,7 +86,7 @@ print(bench)
84
86
 
85
87
  ## JAX Support
86
88
 
87
- zeropybench automatically detects JAX arrays and optimizes benchmarking accordingly:
89
+ ZeroPyBench automatically detects JAX arrays and optimizes benchmarking accordingly:
88
90
 
89
91
  ```python
90
92
  import jax.numpy as jnp
@@ -145,6 +147,8 @@ Benchmark(
145
147
  )
146
148
  ```
147
149
 
150
+ <!-- End common text with source/index.md -->
151
+
148
152
  ## License
149
153
 
150
154
  MIT
@@ -10,6 +10,8 @@
10
10
  [![Continuous integration](https://github.com/pchanial/zeropybench/actions/workflows/ci.yml/badge.svg)](https://github.com/pchanial/zeropybench/actions/workflows/ci.yml)
11
11
  [![Coverage](https://codecov.io/gh/pchanial/zeropybench/graph/badge.svg)](https://codecov.io/gh/pchanial/zeropybench)
12
12
 
13
+ <!-- Start common text with source/index.md -->
14
+
13
15
  **zeropybench** is a Python benchmarking library with zero overhead, designed for multidimensional performance analysis.
14
16
 
15
17
  ## Features
@@ -63,7 +65,7 @@ print(bench)
63
65
 
64
66
  ## JAX Support
65
67
 
66
- zeropybench automatically detects JAX arrays and optimizes benchmarking accordingly:
68
+ ZeroPyBench automatically detects JAX arrays and optimizes benchmarking accordingly:
67
69
 
68
70
  ```python
69
71
  import jax.numpy as jnp
@@ -124,6 +126,8 @@ Benchmark(
124
126
  )
125
127
  ```
126
128
 
129
+ <!-- End common text with source/index.md -->
130
+
127
131
  ## License
128
132
 
129
133
  MIT
@@ -0,0 +1,10 @@
1
+ # API Reference
2
+
3
+ ## Benchmark
4
+
5
+ ```{eval-rst}
6
+ .. autoclass:: zeropybench.Benchmark
7
+ :members:
8
+ :undoc-members:
9
+ :show-inheritance:
10
+ ```
@@ -0,0 +1,91 @@
1
+ """Sphinx configuration file for zeropybench documentation."""
2
+
3
+ import sys
4
+ from importlib.metadata import version as get_version
5
+ from pathlib import Path
6
+
7
+ # Add the src directory to the Python path
8
+ src_path = Path(__file__).parent.parent.parent / 'src'
9
+ sys.path.insert(0, str(src_path))
10
+
11
+ # Project information
12
+ project = 'zeropybench'
13
+ copyright = '2025, Pierre Chanial'
14
+ author = 'Pierre Chanial'
15
+ release = get_version('zeropybench')
16
+ version = '.'.join(release.split('.')[:2]) # Major.minor
17
+
18
+ # General configuration
19
+ extensions = [
20
+ 'sphinx.ext.autodoc',
21
+ 'sphinx.ext.autosummary',
22
+ 'sphinx.ext.viewcode',
23
+ 'sphinx.ext.napoleon',
24
+ 'sphinx.ext.intersphinx',
25
+ 'sphinx.ext.mathjax',
26
+ 'myst_parser',
27
+ 'nbsphinx',
28
+ ]
29
+
30
+ templates_path = ['_templates']
31
+ exclude_patterns = []
32
+
33
+ # HTML output configuration
34
+ html_theme = 'furo'
35
+ html_static_path = ['_static']
36
+ html_title = f'{project} v{version}'
37
+ html_theme_options = {
38
+ 'light_css_variables': {
39
+ 'color-brand-primary': '#2EBF4F',
40
+ 'color-brand-content': '#2EBF4F',
41
+ },
42
+ 'dark_css_variables': {
43
+ 'color-brand-primary': '#34D058',
44
+ 'color-brand-content': '#34D058',
45
+ },
46
+ }
47
+
48
+ # Extension configuration
49
+ autodoc_default_options = {
50
+ 'members': True,
51
+ 'undoc-members': True,
52
+ 'show-inheritance': True,
53
+ 'special-members': '__init__',
54
+ }
55
+ autodoc_typehints = 'description' # Show type hints in parameter descriptions
56
+
57
+ # Napoleon settings
58
+ napoleon_google_docstring = True
59
+ napoleon_numpy_docstring = True
60
+ napoleon_include_init_with_doc = False
61
+ napoleon_include_private_with_doc = False
62
+
63
+ # MyST parser configuration
64
+ myst_enable_extensions = [
65
+ 'colon_fence',
66
+ 'deflist',
67
+ 'dollarmath',
68
+ 'html_admonition',
69
+ 'html_image',
70
+ 'linkify',
71
+ 'replacements',
72
+ 'smartquotes',
73
+ 'substitution',
74
+ 'tasklist',
75
+ ]
76
+
77
+ # Intersphinx mapping
78
+ intersphinx_mapping = {
79
+ 'python': ('https://docs.python.org/3', None),
80
+ 'jax': ('https://jax.readthedocs.io/en/latest/', None),
81
+ 'numpy': ('https://numpy.org/doc/stable/', None),
82
+ 'polars': ('https://docs.pola.rs/api/python/stable/', None),
83
+ }
84
+
85
+ # nbsphinx configuration
86
+ nbsphinx_execute = 'always' # Execute notebooks during build
87
+ nbsphinx_allow_errors = True # Continue building even if there are errors
88
+ nbsphinx_timeout = 300 # Timeout for notebook execution in seconds
89
+
90
+ # Additional nbsphinx settings
91
+ nbsphinx_execute_arguments = []
@@ -0,0 +1,124 @@
1
+ # Development
2
+
3
+ ## Development Setup
4
+
5
+ 1. Clone the repository:
6
+ ```bash
7
+ git clone https://github.com/pchanial/zeropybench.git
8
+ cd zeropybench
9
+ ```
10
+
11
+ 2. Install in development mode:
12
+ ```bash
13
+ pip install --group dev -e .
14
+ or
15
+ uv sync
16
+ ```
17
+ 3. Install `pre-commit` (or equivalently `prek`):
18
+ ```bash
19
+ pipx --user install pre-commit
20
+ or
21
+ uv tool install pre-commit
22
+ ```
23
+ The pre-commit hooks need to be installed (see more details in the section [Code Quality](#code-quality)). After doing so, they will be run at each commit.
24
+ ```
25
+ pre-commit install
26
+ ```
27
+
28
+ ## Running Tests
29
+
30
+ The project uses pytest for testing:
31
+
32
+ ```bash
33
+ # Run all tests
34
+ pytest
35
+
36
+ # Run with verbose output
37
+ pytest -v
38
+
39
+ # Run notebook tests
40
+ pytest docs/source/user-guide/
41
+
42
+ # Run specific test file
43
+ pytest tests/test_jax.py
44
+ ```
45
+
46
+ The test suite includes:
47
+ - **Unit tests**: Individual function testing
48
+ - **JAX tests**: JAX-specific benchmarking tests
49
+ - **Functional tests**: The documentation notebooks
50
+
51
+ ## Code Quality
52
+
53
+ The project uses several pre-commit hooks for code quality. They include
54
+ - ruff (linting and formatting)
55
+ - mypy (type checking)
56
+ - and others
57
+
58
+ The pre-commit will be run against the files that are part of a Git commit. To run against all files
59
+ (modified but not added or already committed):
60
+ ```bash
61
+ pre-commit run --all-files
62
+ ```
63
+
64
+ ## Documentation
65
+
66
+ Build documentation locally:
67
+ The dependencies required to build the documentation have already been installed through `uv sync`. If you prefer using
68
+ pip, this extra step is required:
69
+ ```bash
70
+ pip install --group docs .
71
+ ```
72
+
73
+ Then, the HTML documentation is built and inspected by:
74
+ ```
75
+ cd docs
76
+ make html
77
+ firefox build/html/index.html
78
+ ```
79
+
80
+ The documentation uses:
81
+ - **Sphinx**: Documentation generator
82
+ - **MyST**: Markdown support in Sphinx
83
+ - **Furo**: Clean, responsive theme
84
+ - **nbsphinx**: Jupyter notebook support
85
+
86
+
87
+ ## Project Structure
88
+
89
+ ```
90
+ zeropybench/
91
+ ├── src/zeropybench/ # Main package
92
+ │ ├── __init__.py # Public API exports
93
+ │ ├── _benchmark.py # Benchmark class
94
+ │ └── _jax.py # JAX code transformation utilities
95
+ ├── tests/ # Test suite
96
+ │ ├── test_benchmark.py # Benchmark tests
97
+ │ └── test_jax.py # JAX-specific tests
98
+ ├── docs/ # Documentation
99
+ │ └── source/
100
+ │ ├── user-guide/ # User guide and examples
101
+ │ ├── api/ # API reference
102
+ │ └── developer-guide.md # This file
103
+ ├── .github/ # CI/CD workflows
104
+ └── pyproject.toml # Project configuration
105
+ ```
106
+
107
+ ## Contributing
108
+
109
+ 1. Fork the repository
110
+ 2. Install pre-commit
111
+ 3. Create a feature branch: `git checkout -b feature-name`
112
+ 4. Make your changes
113
+ 5. Add tests for new functionality
114
+ 6. Ensure all tests pass: `pytest`
115
+ 7. Submit a pull request
116
+
117
+ ## Release Process
118
+
119
+ Releases are automated through GitHub Actions:
120
+
121
+ 1. Create a new tag: `git tag v0.x.x`
122
+ 2. Push the tag: `git push origin v0.x.x`
123
+ 3. Create a GitHub release
124
+ 4. The CI will automatically build and publish to PyPI
@@ -0,0 +1,47 @@
1
+ <div align="center">
2
+ <img src="_static/logo.svg" alt="zeropybench" width="100%">
3
+ </div>
4
+
5
+
6
+ # Documentation
7
+
8
+ [![PyPI version](https://img.shields.io/pypi/v/zeropybench?color=%232EBF4F)](https://pypi.org/project/zeropybench)
9
+ [![Python versions](https://img.shields.io/pypi/pyversions/zeropybench.svg?color=%232EBF4F)](https://pypi.org/project/zeropybench)
10
+
11
+ ```{include} ../../README.md
12
+ ---
13
+ start-after: "<!-- Start common text with source/index.md -->"
14
+ end-before: "<!-- End common text with source/index.md -->"
15
+ ---
16
+ ```
17
+
18
+ ## Content
19
+
20
+ ```{toctree}
21
+ :maxdepth: 2
22
+ :caption: User Guide
23
+
24
+ user-guide/installation
25
+ user-guide/getting-started
26
+ user-guide/jax-examples
27
+ ```
28
+
29
+ ```{toctree}
30
+ :maxdepth: 2
31
+ :caption: API Reference
32
+
33
+ api/index
34
+ ```
35
+
36
+ ```{toctree}
37
+ :maxdepth: 1
38
+ :caption: Developer Guide
39
+
40
+ developer-guide
41
+ ```
42
+
43
+ ## Indices and tables
44
+
45
+ - {ref}`genindex`
46
+ - {ref}`modindex`
47
+ - {ref}`search`