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..87a1a0b5cd 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 }} @@ -21,10 +21,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - pip install ".[arrow]" \ + pip install ".[arrow,torch,shell]" \ -r requirements/requirements-test.txt \ - -r requirements/requirements-extras-m-competitions.txt \ - -r requirements/requirements-pytorch.txt + -r requirements/requirements-extras-m-competitions.txt pip install --no-deps -r requirements/requirements-extras-cpflows.txt - name: Test with pytest run: | 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/requirements/requirements-extras-shell.txt b/requirements/requirements-extras-shell.txt index 4a740fb6b4..9d71394cd0 100644 --- a/requirements/requirements-extras-shell.txt +++ b/requirements/requirements-extras-shell.txt @@ -1,2 +1,2 @@ -flask~=2.0 -waitress~=2.1.2 +flask~=3.0 +waitress~=3.0.1 diff --git a/src/gluonts/dataset/repository/_ercot.py b/src/gluonts/dataset/repository/_ercot.py index d013a09c9f..7e144d988e 100644 --- a/src/gluonts/dataset/repository/_ercot.py +++ b/src/gluonts/dataset/repository/_ercot.py @@ -26,7 +26,7 @@ def generate_ercot_dataset(dataset_path: Path, dataset_writer: DatasetWriter): df.ffill(inplace=True) regions = [col for col in df.columns if col not in ["ds", "y"]] - freq = "1H" + freq = "1h" prediction_length = 24 start = pd.Period(df["ds"][0], freq=freq) diff --git a/src/gluonts/dataset/repository/_gp_copula_2019.py b/src/gluonts/dataset/repository/_gp_copula_2019.py index 88c6becea2..41d5da9ba6 100644 --- a/src/gluonts/dataset/repository/_gp_copula_2019.py +++ b/src/gluonts/dataset/repository/_gp_copula_2019.py @@ -63,7 +63,7 @@ class GPCopulaDataset(NamedTuple): # original dataset can be found at https://archive.ics.uci.edu/ml/datasets/ElectricityLoadDiagrams20112014# num_series=370, prediction_length=24, - freq="H", + freq="h", rolling_evaluations=7, max_target_dim=None, ), @@ -73,7 +73,7 @@ class GPCopulaDataset(NamedTuple): # note there are 963 in the original dataset from https://archive.ics.uci.edu/ml/datasets/PEMS-SF num_series=963, prediction_length=24, - freq="H", + freq="h", rolling_evaluations=7, max_target_dim=None, ), @@ -82,7 +82,7 @@ class GPCopulaDataset(NamedTuple): url=root + "solar_nips.tar.gz", num_series=137, prediction_length=24, - freq="H", + freq="h", rolling_evaluations=7, max_target_dim=None, ), diff --git a/src/gluonts/dataset/repository/_lstnet.py b/src/gluonts/dataset/repository/_lstnet.py index e933666c77..0253cffd95 100644 --- a/src/gluonts/dataset/repository/_lstnet.py +++ b/src/gluonts/dataset/repository/_lstnet.py @@ -91,7 +91,7 @@ class LstnetDataset(NamedTuple): prediction_length=24, rolling_evaluations=7, start_date="2012-01-01", - freq="1H", + freq="1h", agg_freq=None, ), "traffic": LstnetDataset( @@ -105,7 +105,7 @@ class LstnetDataset(NamedTuple): prediction_length=24, rolling_evaluations=7, start_date="2015-01-01", - freq="H", + freq="h", agg_freq=None, ), "solar-energy": LstnetDataset( @@ -117,7 +117,7 @@ class LstnetDataset(NamedTuple): rolling_evaluations=7, start_date="2006-01-01", freq="10min", - agg_freq="1H", + agg_freq="1h", ), } diff --git a/src/gluonts/dataset/repository/_tsf_datasets.py b/src/gluonts/dataset/repository/_tsf_datasets.py index ba073cdf4c..b6ff0340b2 100644 --- a/src/gluonts/dataset/repository/_tsf_datasets.py +++ b/src/gluonts/dataset/repository/_tsf_datasets.py @@ -278,11 +278,15 @@ def generate_forecasting_dataset( def default_prediction_length_from_frequency(freq: str) -> int: prediction_length_map = { "T": 60, + "min": 60, "H": 48, + "h": 48, "D": 30, "W-SUN": 8, "M": 12, + "ME": 12, "Y": 4, + "YE": 4, } try: freq = to_offset(freq).name diff --git a/src/gluonts/dataset/repository/_tsf_reader.py b/src/gluonts/dataset/repository/_tsf_reader.py index 45386864a7..ca87bb27f3 100644 --- a/src/gluonts/dataset/repository/_tsf_reader.py +++ b/src/gluonts/dataset/repository/_tsf_reader.py @@ -49,10 +49,10 @@ def frequency_converter(freq: str): BASE_FREQ_TO_PANDAS_OFFSET: Dict[str, str] = { "seconds": "S", - "minutely": "T", - "minutes": "T", - "hourly": "H", - "hours": "H", + "minutely": "min", + "minutes": "min", + "hourly": "h", + "hours": "h", "daily": "D", "days": "D", "weekly": "W", diff --git a/src/gluonts/dataset/repository/_uber_tlc.py b/src/gluonts/dataset/repository/_uber_tlc.py index 73aabd0701..26a086db43 100644 --- a/src/gluonts/dataset/repository/_uber_tlc.py +++ b/src/gluonts/dataset/repository/_uber_tlc.py @@ -28,7 +28,7 @@ def generate_uber_dataset( prediction_length: int, dataset_writer: DatasetWriter, ): - subsets = {"daily": "1D", "hourly": "1H"} + subsets = {"daily": "1D", "hourly": "1h"} assert ( uber_freq.lower() in subsets ), f"invalid uber_freq='{uber_freq}'. Allowed values: {subsets.keys()}" 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: diff --git a/test/dataset/test_tsf_reader.py b/test/dataset/test_tsf_reader.py index 2261d7ebfc..686b3f4d2c 100644 --- a/test/dataset/test_tsf_reader.py +++ b/test/dataset/test_tsf_reader.py @@ -20,10 +20,10 @@ "input_freq_str, output_freq_str", [ ("30_seconds", "30S"), - ("minutely", "T"), - ("10_minutes", "10T"), - ("hourly", "H"), - ("half_hourly", "0.5H"), + ("minutely", "min"), + ("10_minutes", "10min"), + ("hourly", "h"), + ("half_hourly", "0.5h"), ("daily", "D"), ("7_days", "7D"), ("weekly", "W"),