From 5055582d58423b8af3560720e20ca573f406084d Mon Sep 17 00:00:00 2001 From: Patrick Austin Date: Mon, 19 Jun 2023 12:38:19 +0000 Subject: [PATCH 01/13] Upload test coverage to codecov --- .coveragerc | 4 ++++ .github/workflows/test.yml | 7 +++++-- README.md | 3 +++ requirements-dev.txt | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..fe5977e --- /dev/null +++ b/.coveragerc @@ -0,0 +1,4 @@ +[run] +branch = True +source = muspinsim +omit = muspinsim/tests/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5066304..78df2c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -105,6 +105,9 @@ jobs: - name: Install package env: MUSPINSIM_WITH_OPENMP: 1 - run: pip install . + run: pip install -e . - name: Test with pytest - run: pytest --pyargs muspinsim + run: pytest --cov --cov-report xml --pyargs muspinsim + - name: Upload to Codecov + if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v3 diff --git a/README.md b/README.md index c5308b9..0ef819a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://github.com/muon-spectroscopy-computational-project/muspinsim/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/muon-spectroscopy-computational-project/muspinsim/actions/workflows/test.yml) +[![Codecov](https://codecov.io/gh/muon-spectroscopy-computational-project/muspinsim/branch/main/graph/badge.svg)](https://codecov.io/gh/muon-spectroscopy-computational-project/muspinsim) + # muspinsim MuSpinSim is a Python software meant to simulate muon spectroscopy experiments. In particular, it simulates the spin dynamics of a system of a muon plus other spins, namely electrons and atomic nuclei. It can simulate various common experimental setups and account for hyperfine, dipolar and quadrupolar couplings. It is also able to fit its simulations diff --git a/requirements-dev.txt b/requirements-dev.txt index 48ee14c..c4f21bc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -33,6 +33,7 @@ pycodestyle==2.10.0 pyflakes==3.0.1 pyparsing==3.0.9 pytest==7.2.1 +pytest-cov==4.1.0 python-dateutil==2.8.2 PyYAML==6.0 qutip==4.7.1 From 3749f8d98db4de9cf421c84077774de6f5dad635 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 13:50:45 +0100 Subject: [PATCH 02/13] Remove -e from pip install for Mac --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 78df2c3..bceef00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -105,7 +105,7 @@ jobs: - name: Install package env: MUSPINSIM_WITH_OPENMP: 1 - run: pip install -e . + run: pip install . - name: Test with pytest run: pytest --cov --cov-report xml --pyargs muspinsim - name: Upload to Codecov From e9bb546b85b33e2d6860e898a8834860ee8d476c Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 15:47:07 +0100 Subject: [PATCH 03/13] [debug] Add brew install libomp for macOS --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bceef00..55033d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,13 +99,14 @@ jobs: if [ "$RUNNER_OS" == 'macOS' ]; then echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" + brew install libomp fi shell: bash - name: Install package env: MUSPINSIM_WITH_OPENMP: 1 - run: pip install . + run: pip install -e . - name: Test with pytest run: pytest --cov --cov-report xml --pyargs muspinsim - name: Upload to Codecov From 7ac28c3d25a85a556778ec13dfb1d39298a92d52 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:01:32 +0100 Subject: [PATCH 04/13] [debug] try macOS latest for OMP tests --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55033d1..2c8d1d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,7 +75,7 @@ jobs: # macOS-11 pinned here due to usage of $(brew --prefix llvm@15) # macOS-12 will become macOS-latest in the near future but # is currently still unstable - os: [ubuntu-latest, macOS-11, windows-latest] + os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v3 @@ -99,7 +99,8 @@ jobs: if [ "$RUNNER_OS" == 'macOS' ]; then echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" - brew install libomp + brew info libomp + printenv LD_LIBRARY_PATH fi shell: bash From a8a56513589b58bb030f1fb6f12adb49dda211ce Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:11:10 +0100 Subject: [PATCH 05/13] [debug] export LDFLAGS and CPPFLAGS --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c8d1d3..1b4b1a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -100,7 +100,10 @@ jobs: echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - printenv LD_LIBRARY_PATH + echo "$LD_LIBRARY_PATH" + export LDFLAGS="-L/usr/local/opt/libomp/lib" + export CPPFLAGS="-I/usr/local/opt/libomp/include" + #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/ fi shell: bash From bf0c909559f3e82d13294010cff1b2f1622afdc8 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:21:43 +0100 Subject: [PATCH 06/13] [debug] brew link libomp --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b4b1a4..30d1024 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -100,7 +100,8 @@ jobs: echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - echo "$LD_LIBRARY_PATH" + brew link libomp + echo $LD_LIBRARY_PATH export LDFLAGS="-L/usr/local/opt/libomp/lib" export CPPFLAGS="-I/usr/local/opt/libomp/include" #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/ From 783efa185ccd93b819ad76ae58a8077e0f939632 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:34:12 +0100 Subject: [PATCH 07/13] [debug] brew link libomp --force --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30d1024..eb9ca1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -100,8 +100,12 @@ jobs: echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - brew link libomp + ls /usr/local/Cellar/libomp/16.0.5 + ls /usr/local/opt + brew link libomp --force echo $LD_LIBRARY_PATH + echo $LDFLAGS + echo $CPPFLAGS export LDFLAGS="-L/usr/local/opt/libomp/lib" export CPPFLAGS="-I/usr/local/opt/libomp/include" #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/ From f4915ed48ef66b6dae803907fea74c0ce994e923 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:47:55 +0100 Subject: [PATCH 08/13] [debug] remove -e, macOS 11 --- .github/workflows/test.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb9ca1d..80cdd1f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: fail-fast: false matrix: python-version: ["3.8", "3.10"] - os: [ubuntu-latest, macOS-latest, windows-latest] + os: [ubuntu-latest, macOS-11, windows-latest] steps: - uses: actions/checkout@v3 @@ -100,22 +100,33 @@ jobs: echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - ls /usr/local/Cellar/libomp/16.0.5 - ls /usr/local/opt + tree /usr/local/Cellar/libomp/16.0.5 + ls -l /usr/local/opt/libomp brew link libomp --force + ls -l /usr/local/opt/libomp echo $LD_LIBRARY_PATH echo $LDFLAGS echo $CPPFLAGS export LDFLAGS="-L/usr/local/opt/libomp/lib" export CPPFLAGS="-I/usr/local/opt/libomp/include" #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/ + echo $LD_LIBRARY_PATH + echo $LDFLAGS + echo $CPPFLAGS fi shell: bash - - name: Install package + - name: Install package with -e env: MUSPINSIM_WITH_OPENMP: 1 + if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' run: pip install -e . + - name: Install package + env: + MUSPINSIM_WITH_OPENMP: 1 + if: matrix.python-version != '3.10' || matrix.os != 'ubuntu-latest' + run: pip install . + - name: Test with pytest run: pytest --cov --cov-report xml --pyargs muspinsim - name: Upload to Codecov From eaa1726b72d597ea98e7e776a350f6f1de658a36 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:54:13 +0100 Subject: [PATCH 09/13] [debug] export LD_LIBRARY_PATH --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80cdd1f..1790376 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -100,7 +100,7 @@ jobs: echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - tree /usr/local/Cellar/libomp/16.0.5 + ls -l /usr/local/Cellar/libomp/16.0.5 ls -l /usr/local/opt/libomp brew link libomp --force ls -l /usr/local/opt/libomp @@ -109,7 +109,7 @@ jobs: echo $CPPFLAGS export LDFLAGS="-L/usr/local/opt/libomp/lib" export CPPFLAGS="-I/usr/local/opt/libomp/include" - #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/ + export LD_LIBRARY_PATH="-L/usr/local/opt/libomp/lib" echo $LD_LIBRARY_PATH echo $LDFLAGS echo $CPPFLAGS From 90d8a5fc567974919372d816827b55e1cfcdee46 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:12:38 +0100 Subject: [PATCH 10/13] [debug] change ls debugging --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1790376..2462d7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -100,7 +100,7 @@ jobs: echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - ls -l /usr/local/Cellar/libomp/16.0.5 + ls -l /usr/local/Cellar/libomp ls -l /usr/local/opt/libomp brew link libomp --force ls -l /usr/local/opt/libomp From aa6eede586146826f82739bbc3bf406b50620dcb Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:25:35 +0100 Subject: [PATCH 11/13] [debug] export LIBRARY_PATH --- .github/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2462d7c..d74efc8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: fail-fast: false matrix: python-version: ["3.8", "3.10"] - os: [ubuntu-latest, macOS-11, windows-latest] + os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v3 @@ -75,7 +75,7 @@ jobs: # macOS-11 pinned here due to usage of $(brew --prefix llvm@15) # macOS-12 will become macOS-latest in the near future but # is currently still unstable - os: [ubuntu-latest, macOS-latest, windows-latest] + os: [ubuntu-latest, macOS-11, windows-latest] steps: - uses: actions/checkout@v3 @@ -100,19 +100,22 @@ jobs: echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - ls -l /usr/local/Cellar/libomp + ls -l /usr/local/Cellar/libomp/16.0.5/* ls -l /usr/local/opt/libomp brew link libomp --force ls -l /usr/local/opt/libomp echo $LD_LIBRARY_PATH echo $LDFLAGS echo $CPPFLAGS + echo $LIBRARY_PATH export LDFLAGS="-L/usr/local/opt/libomp/lib" export CPPFLAGS="-I/usr/local/opt/libomp/include" export LD_LIBRARY_PATH="-L/usr/local/opt/libomp/lib" + export LD_LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/libomp/lib" echo $LD_LIBRARY_PATH echo $LDFLAGS echo $CPPFLAGS + echo $LIBRARY_PATH fi shell: bash From 3a0db3c2d27bbd0c7cf6cbe365743f9936678b28 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:37:17 +0100 Subject: [PATCH 12/13] [debug] write variables to GH env file --- .github/workflows/test.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d74efc8..b3b6b1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -108,14 +108,18 @@ jobs: echo $LDFLAGS echo $CPPFLAGS echo $LIBRARY_PATH - export LDFLAGS="-L/usr/local/opt/libomp/lib" - export CPPFLAGS="-I/usr/local/opt/libomp/include" - export LD_LIBRARY_PATH="-L/usr/local/opt/libomp/lib" - export LD_LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/libomp/lib" - echo $LD_LIBRARY_PATH - echo $LDFLAGS - echo $CPPFLAGS - echo $LIBRARY_PATH + echo "LD_LIBRARY_PATH=-L/usr/local/opt/libomp/lib" >> "$GITHUB_ENV" + echo "LDFLAGS=-L/usr/local/opt/libomp/lib" >> "$GITHUB_ENV" + echo "CPPFLAGS=-I/usr/local/opt/libomp/include" >> "$GITHUB_ENV" + echo "LIBRARY_PATH=/usr/local/opt/libomp/lib" >> "$GITHUB_ENV" + #export LDFLAGS="-L/usr/local/opt/libomp/lib" + #export CPPFLAGS="-I/usr/local/opt/libomp/include" + #export LD_LIBRARY_PATH="-L/usr/local/opt/libomp/lib" + #export LD_LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/libomp/lib" + #echo $LD_LIBRARY_PATH + #echo $LDFLAGS + #echo $CPPFLAGS + #echo $LIBRARY_PATH fi shell: bash From 71f0bd0a065c036bb4a9c7add9c8b2826bb7e0a9 Mon Sep 17 00:00:00 2001 From: patrick-austin <61705287+patrick-austin@users.noreply.github.com> Date: Tue, 20 Jun 2023 09:40:14 +0100 Subject: [PATCH 13/13] [debug] remove logging statements --- .github/workflows/test.yml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3b6b1c..4a428da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,32 +94,16 @@ jobs: # Default compiler on macOS doesn't support OpenMP, so force the usage # of homebrew's llvm see # https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md + # Even when installed, clang++ may not be able to find the OMP library when installed + # To resolve this, export the environment variables suggested by brew to $GITHUB_ENV - name: Add optional environment variables run: | if [ "$RUNNER_OS" == 'macOS' ]; then echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" brew info libomp - ls -l /usr/local/Cellar/libomp/16.0.5/* - ls -l /usr/local/opt/libomp - brew link libomp --force - ls -l /usr/local/opt/libomp - echo $LD_LIBRARY_PATH - echo $LDFLAGS - echo $CPPFLAGS - echo $LIBRARY_PATH - echo "LD_LIBRARY_PATH=-L/usr/local/opt/libomp/lib" >> "$GITHUB_ENV" echo "LDFLAGS=-L/usr/local/opt/libomp/lib" >> "$GITHUB_ENV" echo "CPPFLAGS=-I/usr/local/opt/libomp/include" >> "$GITHUB_ENV" - echo "LIBRARY_PATH=/usr/local/opt/libomp/lib" >> "$GITHUB_ENV" - #export LDFLAGS="-L/usr/local/opt/libomp/lib" - #export CPPFLAGS="-I/usr/local/opt/libomp/include" - #export LD_LIBRARY_PATH="-L/usr/local/opt/libomp/lib" - #export LD_LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/libomp/lib" - #echo $LD_LIBRARY_PATH - #echo $LDFLAGS - #echo $CPPFLAGS - #echo $LIBRARY_PATH fi shell: bash