Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Mueller <johannes.mueller4@de.bosch.com>
  • Loading branch information
johannes-mueller committed Oct 7, 2024
2 parents cd5380d + 5ccbec2 commit 7d2be41
Show file tree
Hide file tree
Showing 30 changed files with 1,002 additions and 273 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/pypi-deploy-odbclient.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build odbclient and upload to PyPI

on:
workflow_dispatch:
release:
types: [published]

Expand All @@ -20,16 +21,17 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
python-version: '3.12'

- name: Install setuptools
run: |
pip install -U setuptools setuptools_scm wheel
- name: Build wheels
run: |
python setup.py bdist_wheel
pip wheel --no-deps -w dist .
- uses: actions/upload-artifact@v4
with:
name: artifact-wheel
path: tools/odbclient/dist/*.whl


Expand All @@ -44,17 +46,18 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
python-version: '3.12'

- name: Install setuptools
run: |
pip install -U setuptools setuptools_scm wheel
pip install -U setuptools setuptools_scm build
- name: Build sdist
run: python setup.py sdist
run: python -m build . --sdist

- uses: actions/upload-artifact@v4
with:
name: artifact-sdist
path: tools/odbclient/dist/*.tar.gz

upload_pypi:
Expand All @@ -64,12 +67,17 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
name: artifact-sdist
path: dist

- uses: actions/download-artifact@v4
with:
name: artifact-wheel
path: dist

- uses: pypa/gh-action-pypi-publish@master
- uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
password: ${{ secrets.upload_pypi }}
#password: ${{ secrets.test_pypi }}
#repository_url: https://test.pypi.org/legacy/
# password: ${{ secrets.test_pypi }}
# repository_url: https://test.pypi.org/legacy/
16 changes: 12 additions & 4 deletions .github/workflows/pypi-deploy-odbserver.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build odbserver and upload to PyPI

on:
workflow_dispatch:
release:
types: [published]

Expand Down Expand Up @@ -30,6 +31,7 @@ jobs:
python setup.py bdist_wheel
- uses: actions/upload-artifact@v4
with:
name: artifact-wheel
path: tools/odbserver/dist/*.whl


Expand All @@ -55,6 +57,7 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: artifact-sdist
path: tools/odbserver/dist/*.tar.gz

upload_pypi:
Expand All @@ -64,12 +67,17 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
name: artifact-sdist
path: dist

- uses: pypa/gh-action-pypi-publish@master
- uses: actions/download-artifact@v4
with:
name: artifact-wheel
path: dist

- uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
password: ${{ secrets.upload_pypi }}
#password: ${{ secrets.test_pypi }}
#repository_url: https://test.pypi.org/legacy/
# password: ${{ secrets.test_pypi }}
# repository_url: https://test.pypi.org/legacy/
55 changes: 29 additions & 26 deletions .github/workflows/pypi-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: Build and upload to PyPI

on:
workflow_dispatch:
release:
types: [published]

env:
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-*
CIBW_BEFORE_BUILD: pip install cython
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
push:
branches: [ci-debug]


jobs:
build_wheels:
Expand All @@ -23,22 +22,16 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'

- name: Install cibuildwheel
run: |
# python -m pip install cibuildwheel
pip install -U setuptools setuptools_scm wheel
- name: Build wheels
run: |
# python -m cibuildwheel --output-dir wheelhouse
python setup.py bdist_wheel
uses: pypa/cibuildwheel@v2.21.1
env:
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-*
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014

- uses: actions/upload-artifact@v4
with:
path: ./dist/*.whl
name: artifact-wheel-${{ matrix.os }}
path: ./wheelhouse/*.whl


build_sdist:
Expand All @@ -52,17 +45,17 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
python-version: '3.12'

- name: Install setuptools
run: |
pip install -U setuptools setuptools_scm wheel
pip install -U setuptools setuptools_scm wheel build
- name: Build sdist
run: python setup.py sdist
run: python -m build . --sdist

- uses: actions/upload-artifact@v4
with:
name: artifact-sdist
path: dist/*.tar.gz

upload_pypi:
Expand All @@ -72,12 +65,22 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
name: artifact-sdist
path: dist

- uses: actions/download-artifact@v4
with:
name: artifact-wheel-windows-latest
path: dist

- uses: actions/download-artifact@v4
with:
name: artifact-wheel-ubuntu-latest
path: dist

- uses: pypa/gh-action-pypi-publish@master
- uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
password: ${{ secrets.upload_pypi }}
#password: ${{ secrets.test_pypi }}
#repository_url: https://test.pypi.org/legacy/
# password: ${{ secrets.test_pypi }}
# repository_url: https://test.pypi.org/legacy/
62 changes: 62 additions & 0 deletions .github/workflows/wheelbuild-benchmark-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build wheels and perform benchmarks

on:
pull_request:
branches: [develop, master]

env:
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* cp312-*
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014

jobs:
build_wheels:
name: Build wheels on for various systems
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest] #, windows-latest]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.12'

- name: Build wheels
run: |
pip wheel --no-deps -w dist .
- uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/

benchmark:
name: Benchmark tests
needs: [build_wheels]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: wheel
path: dist/
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.12'
- name: Install wheel
run: pip install $(ls -1 dist/*.whl)
- name: Install pytest
run: pip install pytest pytest-cov
- name: Generate test signal
run: python benchmarks/generate_time_signal.py
- name: Run benchmarks
run: pytest --no-cov -rP benchmarks
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ coverage_report*
.hypothesis
.mutmut-cache
.python-version
/load_signal.csv
28 changes: 27 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,36 @@ In this file noteworthy changes of new releases of pyLife are documented since

## pylife-2.1.1

## Improvements
### Breaking changes

* Change fracture load levels used for slope `k_1` and scatter `T_N`
estimation. Now only fractures in the `finite_zone` are used for estimation
and not all fractures (in `finite_zone` and `infinite_zone`). Change based on
findings in DIN50100:2022-12. (#80, #101)

(see [this discussion](https://github.com/boschresearch/pylife/discussions/104))

* Rename `FatigueData.fatigue_limit` to `finite_infinite_transition`

* The Bayesian Wöhler analyzer has been shutdown (#74) (see [this
discussion](https://github.com/boschresearch/pylife/discussions/104))


### New features

* Add option to manually set `fatigue_limit` (now renamed) for Woehler curve
estimation. (#73)


### Improvements / bug fixes

* Rainflow counters work with `pd.Series` of all index type (#69)
* Improved documentation
* Fixed confusing load matrix after mean stress transformation (#105)
* Massive performance improvements of three point and four point rainflow
counters.
* The Wöhler analyzer now ignores irrelevant pure runout levels (#100)
* Support numpy>=2.0.0


## pylife-2.1.0
Expand Down
25 changes: 25 additions & 0 deletions benchmarks/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest

import time
import numpy as np


@pytest.fixture
def benchmarker():

def the_benchmarker(rainflow_counter):
load_signal = np.loadtxt('load_signal.csv')

tic = time.perf_counter()

rainflow_counter.process(load_signal)

toc = time.perf_counter()
elapsed = toc - tic

classname = rainflow_counter.__class__.__name__
print(f"Processing {classname} took {elapsed:0.4f} seconds")

return elapsed

return the_benchmarker
22 changes: 22 additions & 0 deletions benchmarks/generate_time_signal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

import numpy as np
import pylife.stress.timesignal as TS

np.random.seed(23424711)

load_signal = TS.TimeSignalGenerator(
10,
{
'number': 50_000,
'amplitude_median': 50.0,
'amplitude_std_dev': 0.5,
'frequency_median': 4,
'frequency_std_dev': 3,
'offset_median': 0,
'offset_std_dev': 0.4,
},
None,
None,
).query(1_000_000)

np.savetxt('load_signal.csv', load_signal)
19 changes: 19 additions & 0 deletions benchmarks/test_rainflow_counters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pylife.stress.rainflow as RF


def test_threepoint(benchmarker):
benchmark_time = 0.05 # seconds
elapsed = benchmarker(RF.ThreePointDetector(recorder=RF.FullRecorder()))

assert (
elapsed < benchmark_time
), f"Benchmark time of {benchmark_time} s not exceeded. Needed {elapsed:0.4f} s."


def test_fourpoint(benchmarker):
benchmark_time = 0.05 # seconds
elapsed = benchmarker(RF.FourPointDetector(recorder=RF.FullRecorder()))

assert (
elapsed < benchmark_time
), f"Benchmark time of {benchmark_time} s not exceeded. Needed {elapsed:0.4f} s."
Loading

0 comments on commit 7d2be41

Please sign in to comment.