From bb31530f2bd2c94385e389e5900ac2dfdebeff6b Mon Sep 17 00:00:00 2001 From: Lorenzo Stella Date: Tue, 5 Nov 2024 11:55:29 +0100 Subject: [PATCH] Drop Python 3.8 from workflows, run on 3.11 (#3228) *Issue #, if available:* Python 3.8 reached EOL, and some packages are not distributed for it in their latest versions. *Description of changes:* - update github workflows to run on Python (up to) 3.11 - fix tests and testutils that would break on 3.11 - delete some unused workflows - update sphinx version used in the docs build workflow By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. **Please tag this pr with at least one of these labels to make our release process faster:** BREAKING, new feature, bug fix, other change, dev setup --- .github/workflows/docs.yml | 5 +-- .github/workflows/doctests.yaml | 5 +-- .github/workflows/lints.yml | 2 + .github/workflows/mxnet_nightly.yml | 39 ------------------ .github/workflows/pypi.yml | 5 +-- .github/workflows/style_type_checks.yml | 2 + .../workflows/test_release_unix_nightly.yml | 39 ------------------ .../workflows/test_release_win32_nightly.yml | 40 ------------------- .github/workflows/tests-nixtla.yaml | 5 +-- .github/workflows/tests-nursery.yml | 5 +-- .github/workflows/tests-prophet.yaml | 5 +-- .github/workflows/tests-r.yml | 5 +-- .github/workflows/tests-torch.yml | 2 +- .github/workflows/tests-xgboost.yaml | 2 +- .github/workflows/tests.yml | 5 +-- requirements/requirements-docs.txt | 2 +- src/gluonts/testutil/shell.py | 4 +- test/conftest.py | 2 +- test/core/test_serde_dataclass.py | 7 ++-- 19 files changed, 29 insertions(+), 152 deletions(-) delete mode 100644 .github/workflows/mxnet_nightly.yml delete mode 100644 .github/workflows/test_release_unix_nightly.yml delete mode 100644 .github/workflows/test_release_win32_nightly.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 668c07bd4c..ad0c66919a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -20,10 +20,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.11 - name: Install dependencies run: | diff --git a/.github/workflows/doctests.yaml b/.github/workflows/doctests.yaml index d29af1cf29..afe2580a27 100644 --- a/.github/workflows/doctests.yaml +++ b/.github/workflows/doctests.yaml @@ -8,15 +8,14 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: ['3.9'] + python-version: ['3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install other dependencies diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml index 0931abe329..9a8ac1effd 100644 --- a/.github/workflows/lints.yml +++ b/.github/workflows/lints.yml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 + with: + python-version: '3.11' - name: Install tools run: pip install "ruff==0.2.2" "docformatter[tomli]==1.5.0" - name: Ruff (Flake8) diff --git a/.github/workflows/mxnet_nightly.yml b/.github/workflows/mxnet_nightly.yml deleted file mode 100644 index 75f29f4f29..0000000000 --- a/.github/workflows/mxnet_nightly.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: MXNet nightly - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - test-mxnet-nightly: - - strategy: - max-parallel: 4 - fail-fast: false - matrix: - python-version: ['3.8'] - platform: [ubuntu-latest, windows-latest] - - runs-on: ${{ matrix.platform }} - - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install pip==20.2 - pip install --pre "mxnet<2" -f https://dist.mxnet.io/python - pip install "torch==1.10.0" "pytorch-lightning~=1.5" -f https://download.pytorch.org/whl/cpu/torch_stable.html - pip install -e ".[shell]" \ - -r requirements/requirements-test.txt \ - -r requirements/requirements-extras-sagemaker-sdk.txt \ - -r requirements/requirements-extras-m-competitions.txt \ - -r requirements/requirements-rotbaum.txt \ - -r requirements/requirements-extras-anomaly-evaluation.txt \ - -r requirements/requirements-extras-autogluon.txt - - name: Test with pytest - run: | - pytest -m 'not (gpu or serial)' --cov=gluonts --cov-report=term --cov-report xml test diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index d2ca008f29..25ff90fe1c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -12,10 +12,9 @@ jobs: - uses: actions/checkout@v4 - name: Get tags run: git fetch --tags origin - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.11' - name: Install dependencies run: | python -m pip install -U pip diff --git a/.github/workflows/style_type_checks.yml b/.github/workflows/style_type_checks.yml index 48c2178edc..271ca39ff0 100644 --- a/.github/workflows/style_type_checks.yml +++ b/.github/workflows/style_type_checks.yml @@ -10,6 +10,8 @@ jobs: - uses: actions/checkout@v3 - uses: extractions/setup-just@v1 - uses: actions/setup-python@v4 + with: + python-version: '3.11' - name: Install dependencies run: | pip install . diff --git a/.github/workflows/test_release_unix_nightly.yml b/.github/workflows/test_release_unix_nightly.yml deleted file mode 100644 index f058fafcaa..0000000000 --- a/.github/workflows/test_release_unix_nightly.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Test latest release nightly Ubuntu - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - test-stable-ubuntu: - - strategy: - max-parallel: 4 - fail-fast: false - matrix: - python-version: ['3.8'] - - runs-on: ubuntu-latest - steps: - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Clone and install dependencies - run: | - git clone https://github.com/awslabs/gluonts --branch $(curl https://api.github.com/repos/awslabs/gluonts/releases/latest | grep tag_name | cut -d : -f 2,3 | tr -d \"\ | tr -d \,\ ) - cd gluon-ts - pip install pip==20.2 - pip install "mxnet~=1.8.0" "torch==1.10.0" "pytorch-lightning~=1.5" \ - -f https://download.pytorch.org/whl/cpu/torch_stable.html - pip install -e ".[shell]" \ - -r requirements/requirements-test.txt \ - -r requirements/requirements-extras-sagemaker-sdk.txt \ - -r requirements/requirements-extras-m-competitions.txt \ - -r requirements/requirements-rotbaum.txt \ - -r requirements/requirements-extras-anomaly-evaluation.txt \ - -r requirements/requirements-extras-autogluon.txt - - name: Test with pytest - run: | - cd gluon-ts - pytest -m 'not (gpu or serial)' --cov=gluonts --cov-report=term --cov-report xml test diff --git a/.github/workflows/test_release_win32_nightly.yml b/.github/workflows/test_release_win32_nightly.yml deleted file mode 100644 index b9cda3fb92..0000000000 --- a/.github/workflows/test_release_win32_nightly.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Test latest release nightly Windows - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - test-stable-windows: - - strategy: - max-parallel: 4 - fail-fast: false - matrix: - python-version: ['3.8'] - - runs-on: windows-latest - steps: - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Clone and install dependencies - run: | - $tmp=(Invoke-WebRequest -Uri https://api.github.com/repos/awslabs/gluonts/releases/latest).Content | ConvertFrom-Json | Select-Object tag_name - $tmp=$tmp.psobject.properties.value.trim() - git clone https://github.com/awslabs/gluonts --branch $tmp - cd gluon-ts - pip install "mxnet~=1.7.0" torch "pytorch-lightning~=1.5" - pip install -e ".[shell]" \ - -r requirements/requirements-test.txt \ - -r requirements/requirements-extras-sagemaker-sdk.txt \ - -r requirements/requirements-extras-m-competitions.txt \ - -r requirements/requirements-rotbaum.txt \ - -r requirements/requirements-extras-anomaly-evaluation.txt \ - -r requirements/requirements-extras-autogluon.txt - shell: powershell - - name: Test with pytest - run: | - cd gluon-ts - pytest -m 'not (gpu or serial)' --cov=gluonts --cov-report=term --cov-report xml test diff --git a/.github/workflows/tests-nixtla.yaml b/.github/workflows/tests-nixtla.yaml index 86aefed138..8c35fd75b6 100644 --- a/.github/workflows/tests-nixtla.yaml +++ b/.github/workflows/tests-nixtla.yaml @@ -8,15 +8,14 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: ['3.8'] + python-version: ['3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install other dependencies diff --git a/.github/workflows/tests-nursery.yml b/.github/workflows/tests-nursery.yml index 5bca25ec1c..60423bccb9 100644 --- a/.github/workflows/tests-nursery.yml +++ b/.github/workflows/tests-nursery.yml @@ -8,7 +8,7 @@ jobs: max-parallel: 1 fail-fast: false matrix: - python-version: ['3.8'] + python-version: ['3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} @@ -17,8 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install MXNet (Linux) diff --git a/.github/workflows/tests-prophet.yaml b/.github/workflows/tests-prophet.yaml index c1d3bdc586..f5533255f6 100644 --- a/.github/workflows/tests-prophet.yaml +++ b/.github/workflows/tests-prophet.yaml @@ -8,15 +8,14 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: ['3.8'] + python-version: ['3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install other dependencies diff --git a/.github/workflows/tests-r.yml b/.github/workflows/tests-r.yml index 52c8ab6206..f0df985db2 100644 --- a/.github/workflows/tests-r.yml +++ b/.github/workflows/tests-r.yml @@ -8,7 +8,7 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: ['3.9'] + python-version: ['3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} @@ -32,8 +32,7 @@ jobs: libxml2-dev \ libcurl4-openssl-dev Rscript -e 'install.packages(c("forecast", "nnfor", "hts"), repos="https://cloud.r-project.org")' - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies diff --git a/.github/workflows/tests-torch.yml b/.github/workflows/tests-torch.yml index fde0bf221f..431ff937db 100644 --- a/.github/workflows/tests-torch.yml +++ b/.github/workflows/tests-torch.yml @@ -8,7 +8,7 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.9', '3.10', '3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/tests-xgboost.yaml b/.github/workflows/tests-xgboost.yaml index 022b766cf6..fa0dca686c 100644 --- a/.github/workflows/tests-xgboost.yaml +++ b/.github/workflows/tests-xgboost.yaml @@ -8,7 +8,7 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7119f0d83d..e5ba432a34 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,15 +8,14 @@ jobs: max-parallel: 4 fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.9', '3.10', '3.11'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install other dependencies diff --git a/requirements/requirements-docs.txt b/requirements/requirements-docs.txt index 645e7632c3..382421d85a 100644 --- a/requirements/requirements-docs.txt +++ b/requirements/requirements-docs.txt @@ -6,7 +6,7 @@ notedown lxml~=5.1.0 pytest-runner~=2.11 recommonmark -sphinx~=4.0 +sphinx~=5.0 docutils<=0.16 optuna~=2.10 furo==2022.6.4.1 diff --git a/src/gluonts/testutil/shell.py b/src/gluonts/testutil/shell.py index 5e1815db6f..c723ae6712 100644 --- a/src/gluonts/testutil/shell.py +++ b/src/gluonts/testutil/shell.py @@ -21,7 +21,7 @@ import typing import waitress from contextlib import closing, contextmanager -from dataclasses import dataclass +from dataclasses import dataclass, field from multiprocessing.context import ForkContext from pathlib import Path from typing import Any, ContextManager, Dict, Iterable, List, Optional, Type @@ -119,7 +119,7 @@ def free_port() -> int: class Server: env: ServeEnv forecaster_type: Optional[Type[Predictor]] - settings: Settings = Settings() + settings: Settings = field(default_factory=Settings) def run(self): flask_app = make_flask_app( diff --git a/test/conftest.py b/test/conftest.py index b624259a15..8ec8649909 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -30,7 +30,7 @@ try: import mxnet as mx -except ImportError: +except (ImportError, OSError): mx = None try: diff --git a/test/core/test_serde_dataclass.py b/test/core/test_serde_dataclass.py index 324e33c746..f602699711 100644 --- a/test/core/test_serde_dataclass.py +++ b/test/core/test_serde_dataclass.py @@ -20,14 +20,13 @@ @serde.dataclass class Estimator: prediction_length: int - context_length: int = serde.OrElse( - lambda prediction_length: prediction_length * 2 - ) + context_length: int = serde.EVENTUAL use_feat_static_cat: bool = True cardinality: List[int] = serde.EVENTUAL - def __eventually__(self, cardinality): + def __eventually__(self, context_length, cardinality): + context_length.set_default(self.prediction_length * 2) if not self.use_feat_static_cat: cardinality.set([1]) else: