Skip to content
Merged

3.5.1 #205

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
63 changes: 36 additions & 27 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,59 @@ on:
branches: [ master ]
push:
tags:
- '*'
- 'v*'

jobs:
build_wheels:
name: Build wheels for ${{ matrix.os }}
name: Build wheels for ${{ matrix.python }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-22.04, windows-latest, macos-latest ]
# Operating systems for which pre-built wheels are provided
os: [ ubuntu-24.04, windows-latest, macos-latest ]
# Python versions for which pre-built wheels are provided
# See supported versions at https://cibuildwheel.pypa.io/en/stable/#what-does-it-do
# Be aware that all versions need to be supported by the used version of cibuildwheel
# https://github.com/pypa/cibuildwheel/releases
python: [ 'cp39', 'cp310', 'cp311', 'cp312', 'cp313', 'cp314' ]

steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-python@v5
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3.2.0
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0
platforms: arm64

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
uses: pypa/cibuildwheel@v3.3.1
env:
CIBW_SKIP: pp* *musllinux* cp36-* cp37-* cp38-* cp313-manylinux_aarch64
CIBW_BUILD: "${{ matrix.python }}-*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
CIBW_SKIP: "*musllinux*"
CIBW_BUILD_VERBOSITY: 1
CIBW_ARCHS_LINUX: auto64 aarch64
CIBW_ARCHS_MACOS: auto64
CIBW_ARCHS_WINDOWS: auto64
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_ARCHS_MACOS: arm64
CIBW_ARCHS_WINDOWS: AMD64
CIBW_BEFORE_BUILD: git submodule update --init --recursive
CIBW_BEFORE_TEST: pip install -e .[dev]
CIBW_TEST_COMMAND_WINDOWS: ruff check {project}/pelutils && pytest {project}/tests
CIBW_TEST_COMMAND_MACOS: ruff check {project}/pelutils && pytest {project}/tests
CIBW_TEST_COMMAND_LINUX: ruff check {project}/pelutils && timeout 150s pytest {project}/tests || true
# Install the CPU version of torch before installing the rest of the package
# This prevents it from installing the full CUDA version of torch and associated dependencies (default on Linux)
# This massively speeds up the installation process and requires much less disk space
CIBW_BEFORE_TEST: pip install torch --index-url https://download.pytorch.org/whl/cpu && pip install .[dev]
CIBW_TEST_COMMAND: ruff check {project}/pelutils && pytest {project}/tests

# v4 is currently the newest, but there is some breaking change with it that causes the run to fail
# https://github.com/actions/upload-artifact/issues/478
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
name: wheels-${{ matrix.os }}-${{ matrix.python }}
path: ./wheelhouse/*.whl

make_sdist:
name: Make source dist
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/checkout@v4
with:
submodules: true

Expand All @@ -66,16 +70,21 @@ jobs:

upload_all:
needs: [ build_wheels, make_sdist ]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
# Upload to PyPI when pushing new version tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
pattern: '*'
path: dist
merge-multiple: true

- name: List files to distribute
run: ls -R dist/
shell: bash

- uses: pypa/gh-action-pypi-publish@v1.12.3
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Set up PyPi dependencies and install package
run: |
pip install --upgrade setuptools wheel
pip install numpy
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install -e .[dev]

- name: Lint
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# History

## 3.6.0 - Minor breaking change

- Added `reset_profiles` method to `TickTock`.
- Added `do_at_interval` for triggering events at intervals.
- Added `disable` option to `TickTock.profile`.
- Updated libraries for running tests and distribution wheels.
This has no direct impact but it has forced the rename `UnitTestCollection.test_path` -> `UnitTestCollection.get_test_path` to prevent `pytest` complaining.
- Wheels are no longer provided for x86 MAC but are for Apple Silicon.
- Wheels are now actually provided again (whoops).

## 3.5.0

- Added support and pre-built wheels for Python 3.13.
Expand Down
31 changes: 9 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# pelutils

[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pytest](https://github.com/peleiden/pelutils/actions/workflows/pytest.yml/badge.svg?branch=master)](https://github.com/peleiden/pelutils/actions/workflows/pytest.yml)
[![Coverage Status](https://coveralls.io/repos/github/peleiden/pelutils/badge.svg?branch=master)](https://coveralls.io/github/peleiden/pelutils?branch=master)
[![PyPi](https://img.shields.io/pypi/v/pelutils.svg)](https://pypi.org/project/pelutils/)

The Swiss army knife of Python projects.

Expand Down Expand Up @@ -38,17 +40,11 @@ seconds_used = TT.tock()

# Profile a for loop
for i in range(100):
TT.profile("Repeated code")
<some task>
TT.profile("Subtask")
<some subtask>
TT.end_profile()
TT.end_profile()
print(TT) # Prints a table view of profiled code sections

# Alternative syntax using with statement
with TT.profile("The best task"):
with TT.profile("Repeated code"):
<some task>
with TT.profile("Subtask"):
<some subtask>
print(TT) # Print a table view of profiled code sections

# When using multiprocessing, it can be useful to simulate multiple hits of the same profile
with mp.Pool() as p, TT.profile("Processing 100 items on multiple threads", hits=100):
Expand All @@ -59,21 +55,12 @@ with TT.profile("Adding 1 to a", hits=100):
for _ in range(100):
a += 1

# Examples so far use a global TickTock instance, which is convenient,
# but it can also be desirable to use for multiple different timers, e.g.
tt1 = TickTock()
tt2 = TickTock()
t1_interval = 1 # Do task 1 every second
t2_interval = 2 # Do task 2 every other second
tt1.tick()
tt2.tick()
# To use the TickTock instance as a timer to trigger events, do
while True:
if tt1.tock() > t1_interval:
if TT.do_at_interval(60, "task1"): # Do task 1 every 60 seconds
<task 1>
tt1.tick()
if tt2.tock() > t2_interval:
if TT.do_at_interval(30, "task2"): # Do task 2 every 30 seconds
<task 2>
tt2.tick()
time.sleep(0.01)
```

Expand Down
2 changes: 1 addition & 1 deletion pelutils/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Do not put anything else in this file
__version__ = "3.5.0"
__version__ = "3.6.0"
3 changes: 2 additions & 1 deletion pelutils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __enter__(self):
return self._pool

def __exit__(self, *_):
assert self._pool is not None
self._pool.close()
self._pool.join()
self._pool = None
Expand Down Expand Up @@ -92,7 +93,7 @@ def ignore_absentee(_, __, exc_inf): # noqa: D102
raise except_instance

@classmethod
def test_path(cls, path: str) -> str:
def get_test_path(cls, path: str) -> str:
"""Return a path inside the test directory.

`path` would often just be a filename which can be written to and is automatically cleaned up after the test.
Expand Down
Loading