Skip to content

Commit

Permalink
upgraded versions for testing and added numba
Browse files Browse the repository at this point in the history
- added numba to the test / all dependencies
- all tests are now run with the ["all"] installation
- all additional tests (tutorials, codecov, without numba) are run on python 3.11
- for python 3.12, add setuptools as test dependency (not handled in imports test anymore)
  • Loading branch information
dlohmeier committed Aug 27, 2024
1 parent b865134 commit 03a8bce
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 45 deletions.
37 changes: 21 additions & 16 deletions .github/workflows/run_tests_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,27 @@ jobs:
python -m pip install --upgrade pip
python -m pip install pytest pytest-split
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install .
python -m pip install .["all"]
shell: bash
- name: List all installed packages
run: |
python -m pip list
- name: Test with pytest
if: ${{ matrix.python-version != '3.9' }}
if: ${{ matrix.python-version != '3.11' }}
run: |
python -m pytest
- name: Test without numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip uninstall numba
python -m pytest -n=auto
- name: Test with pytest and Codecov
if: ${{ matrix.python-version == '3.9' }}
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install pytest-cov
python -m pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.9' }}
if: ${{ matrix.python-version == '3.11' }}
uses: codecov/codecov-action@v1
with:
verbose: true
Expand Down Expand Up @@ -76,21 +81,16 @@ jobs:
run: |
python -m pip list
- name: Test with pytest
if: ${{ matrix.python-version != '3.9' }}
if: ${{ matrix.python-version != '3.11' }}
run: |
python -m pytest
- name: Test with numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install numba
python -m pytest -n=auto
- name: Test with pytest and Codecov
if: ${{ matrix.python-version == '3.9' }}
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install pytest-cov
python -m pytest -n=auto --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.9' }}
if: ${{ matrix.python-version == '3.11' }}
uses: codecov/codecov-action@v4
with:
verbose: true
Expand All @@ -104,12 +104,17 @@ jobs:
'pandapipes/networks/network_files/**'
'**.yml'
'**.rst'
- name: Test without numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip uninstall numba
python -m pytest -n=auto
linting:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.10']
python-version: ['3.11']
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -161,17 +166,17 @@ jobs:
- name: Test with pytest
run: |
python -m pytest --nbmake -n=auto "./tutorials"
- name: Test with numba
- name: Test without numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install numba
python -m pip uninstall numba
python -m pytest --nbmake -n=auto "./tutorials"
docs_check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
python-version: [ '3.11' ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/run_tests_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,23 @@ jobs:
run: |
python -m pip list
- name: Test with pytest
if: ${{ matrix.python-version != '3.9' }}
if: ${{ matrix.python-version != '3.11' }}
run: |
python -m pytest
- name: Test with numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install numba
python -m pytest -n=auto
- name: Test with pytest, Codecov and Coverage
if: ${{ matrix.python-version == '3.9' }}
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install pytest-cov
python -m pytest --nbmake -n=auto --cov=./ --cov-report=xml
cp ./coverage.xml ./codecov_coverage.xml
- name: Upload coverage to Codacy
if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}}
if: ${{ matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'}}
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage.xml
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.9' }}
if: ${{ matrix.python-version == '3.11' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -70,6 +65,11 @@ jobs:
'pandapipes/networks/network_files/**'
'**.yml'
'**.rst'
- name: Test without numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip uninstall numba
python -m pytest -n=auto
relying:
Expand All @@ -95,8 +95,13 @@ jobs:
run: |
python -m pip list
- name: Test with pytest
if: ${{ matrix.python-version != '3.9' }}
# if: ${{ matrix.python-version != '3.11' }}
run: |
python -m pytest -n=auto
- name: Test without numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip uninstall numba
python -m pytest -n=auto
tutorial_tests:
Expand Down Expand Up @@ -124,18 +129,18 @@ jobs:
- name: Test with pytest
run: |
python -m pytest --nbmake -n=auto "./tutorials"
- name: Test with numba
- name: Test without numba
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install numba
python -m pip uninstall numba
python -m pytest --nbmake -n=auto "./tutorials"
docs_check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
python-version: [ '3.11' ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ Changelog = "https://github.com/e2nIEE/pandapipes/blob/develop/CHANGELOG.rst"
[project.optional-dependencies]
docs = ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "sphinx-pyproject"]
plotting = ["plotly", "igraph"]
test = ["pytest", "pytest-xdist", "nbmake"]
test = ["pytest", "pytest-xdist", "nbmake", "numba", "setuptools; python_version >= '3.12'"]
all = [
"numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex",
"plotly", "igraph", "pytest", "pytest-xdist", "nbmake"
"plotly", "igraph", "pytest", "pytest-xdist", "nbmake", "numba",
"setuptools; python_version >= '3.12'"
]

[tool.setuptools.packages.find]
Expand Down
16 changes: 2 additions & 14 deletions src/pandapipes/test/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@
SETUPTOOLS_AVAILABLE = False


@pytest.mark.skipif(not SETUPTOOLS_AVAILABLE, reason="setuptools not available")
def test_import_packages():
if SETUPTOOLS_AVAILABLE:
all_packages = find_packages(pp_dir)
else:
all_packages = []
for root, dirs, files in os.walk(pp_dir):
for file in files:
if file != "__init__.py":
continue
path = os.path.relpath(root, pp_dir)
if path == ".":
continue
pck = path.replace(os.sep, ".")
all_packages.append(pck)

all_packages = find_packages(pp_dir)
for pck in all_packages:
spec = importlib.util.find_spec(os.path.split(pp_dir)[-1] + "." + pck)
new_module = importlib.util.module_from_spec(spec)
Expand Down

0 comments on commit 03a8bce

Please sign in to comment.