From 60b1d6b7c3ff99dcd90bc1ed2a81011f7f4c9b56 Mon Sep 17 00:00:00 2001 From: Konstantin Sering Date: Thu, 25 Apr 2024 19:07:25 +0200 Subject: [PATCH] fixes python version 3.12 (#250) * fixes #249 * fixes upper boundary for the python version and makes all dependencies open to new versions * fixes github action for testing and configuring poetry * add setuptools as dependencies as this mitigates the missing distutils package in python 3.12 * restricts Jinja2 version to non-vulnarable one * change minimal python version to 3.9 * fixes doctest outputs to be compliant to improved xarray output * small fix to README.rst * make codecov working again --- .github/workflows/draft-pdf.yml | 2 +- .github/workflows/python-publish.yml | 12 +++--- .github/workflows/python-test-publish.yml | 10 ++--- .github/workflows/python-test.yml | 41 ++++++-------------- README.rst | 3 -- docs/source/examples.rst | 40 ++++++++++---------- pyproject.toml | 46 ++++++++++++----------- 7 files changed, 67 insertions(+), 87 deletions(-) diff --git a/.github/workflows/draft-pdf.yml b/.github/workflows/draft-pdf.yml index 6172957..f496924 100644 --- a/.github/workflows/draft-pdf.yml +++ b/.github/workflows/draft-pdf.yml @@ -11,7 +11,7 @@ jobs: name: Paper Draft steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build draft PDF uses: openjournals/openjournals-draft-action@master with: diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index d526d3c..bc34aad 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,4 +1,4 @@ -name: Build and upload releases +name: Build and upload releases (sdist only) on: release: @@ -10,21 +10,21 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ['3.11'] + python-version: ['3.12'] # os: [ubuntu-latest, macOS-latest, windows-latest] # python-version: ['3.8', '3.9', '3.10', '3.11'] - poetry-version: [1.6] + poetry-version: ['1.8'] fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Run image - uses: abatilo/actions-poetry@v2.1.3 + uses: abatilo/actions-poetry@v2 with: poetry-version: ${{ matrix.poetry-version }} - name: Install package diff --git a/.github/workflows/python-test-publish.yml b/.github/workflows/python-test-publish.yml index aa8d71c..9d456bb 100644 --- a/.github/workflows/python-test-publish.yml +++ b/.github/workflows/python-test-publish.yml @@ -11,19 +11,19 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - python-version: ['3.8', '3.9', '3.10', '3.11'] - poetry-version: [1.2] + python-version: ['3.9', '3.10', '3.11', '3.12'] + poetry-version: ['1.8'] fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Run image - uses: abatilo/actions-poetry@v2.1.3 + uses: abatilo/actions-poetry@v2 with: poetry-version: ${{ matrix.poetry-version }} - name: Configure test PyPI diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 1f5c501..a963ce7 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -14,46 +14,27 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - python-version: ['3.8', '3.11'] - poetry-version: [1.1.13] + python-version: ['3.9', '3.12'] + poetry-version: ["1.8"] fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") + - name: Display Python version + run: python -c "import sys; print('-'.join(str(v) for v in sys.version_info))" - name: Setup poetry - uses: abatilo/actions-poetry@v2.1.3 + uses: abatilo/actions-poetry@v2 with: poetry-version: ${{ matrix.poetry-version }} - - name: Update PATH - if: ${{ runner.os != 'Windows' }} - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Update Path for Windows - if: ${{ runner.os == 'Windows' }} - run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH - - - name: Configure poetry - run: poetry config virtualenvs.in-project true - - - name: Set up cache - uses: actions/cache@v3 - id: cache - with: - path: .venv - key: venv-cache-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} - - - name: Install dependencies + - name: Install dependencies and pyndl run: poetry install - name: Run linux tests @@ -62,11 +43,11 @@ jobs: - name: Run tests on other distributions (skip linux-only tests) if: ${{ runner.os != 'Linux' }} - run: poetry run pytest --no-linux + run: poetry run pytest --no-linux --cov=pyndl --cov-report=xml --disable-pytest-warnings - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: - file: ./coverage.xml flags: unittests + token: ${{ secrets.CODECOV_TOKEN }} env_vars: OS,PYTHON diff --git a/README.rst b/README.rst index 7b7e0d8..8070fce 100644 --- a/README.rst +++ b/README.rst @@ -8,9 +8,6 @@ Pyndl - Naive Discriminative Learning in Python .. image:: https://codecov.io/gh/quantling/pyndl/branch/main/graph/badge.svg?token=2GWUXRA9PD :target: https://codecov.io/gh/quantling/pyndl -.. image:: https://img.shields.io/lgtm/grade/python/g/quantling/pyndl.svg?logo=lgtm&logoWidth=18 - :target: https://lgtm.com/projects/g/quantling/pyndl/context:python - .. image:: https://img.shields.io/pypi/pyversions/pyndl.svg :target: https://pypi.python.org/pypi/pyndl/ diff --git a/docs/source/examples.rst b/docs/source/examples.rst index a382a77..26aab4a 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -126,7 +126,7 @@ Let's start: >>> weights = ndl.ndl(events='docs/data/lexample.tab.gz', alpha=0.1, ... betas=(0.1, 0.1), method='threading') >>> weights # doctest: +ELLIPSIS - + ... ... ``weights`` is an ``xarray.DataArray`` of dimension ``len(outcomes)``, @@ -139,21 +139,21 @@ methods .. code-block:: python >>> weights[1, 5] # doctest: +ELLIPSIS - + ... ... >>> weights.loc[{'outcomes': 'plural', 'cues': 's#'}] # doctest: +ELLIPSIS - + ... array(0.076988...) Coordinates: - outcomes >> weights.loc['plural'].loc['s#'] # doctest: +ELLIPSIS - + ... array(0.076988...) Coordinates: - outcomes >> weights2 = ndl.ndl(events='docs/data/lexample.tab.gz', alpha=0.1, ... betas=(0.1, 0.1), method='threading', weights=weights) >>> weights2 # doctest: +ELLIPSIS - + ... array([[ 0.24... ... ...]]) Coordinates: - * outcomes (outcomes) >> weights # doctest: +ELLIPSIS - + ... ... @@ -449,27 +449,27 @@ gets apparent. ... 'cue_vector_dimensions': ['dim1', 'dim2', 'dim3']}] >>> weights_ndl = weights_ndl.loc[{'outcomes': ['A', 'B', 'C', 'D'], 'cues': ['a', 'b', 'c']}] >>> print(weights_wh) # doctest: +ELLIPSIS - + ... array([[0.06706..., 0. , 0. ], [0. , 0.03940..., 0. ], [0.0094... , 0. , 0.03940...], [0.01 , 0. , 0. ]]) Coordinates: - * outcome_vector_dimensions (outcome_vector_dimensions) >> print(weights_ndl) # doctest: +ELLIPSIS - + ... array([[0.06706..., 0. , 0. ], [0. , 0.03940..., 0. ], [0.0094... , 0. , 0.03940...], [0.01 , 0. , 0. ]]) Coordinates: - * outcomes (outcomes)