Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[MNT] rewrite GHA test workflow based on pip #1593

Merged
merged 20 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 14 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@ on:
pull_request:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pytest:
name: Run pytest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13] # add windows-2019 when poetry allows installation with `-f` flag
python-version: ["3.8", "3.9", "3.10"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -37,39 +42,17 @@ jobs:
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: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -

- name: Set poetry path variable
run: echo "/Users/runner/.local/bin" >> $GITHUB_PATH

- name: Configure poetry
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv

- name: Upgrade pip
run: poetry run python -m pip install pip -U

- name: Install dependencies
run: poetry install -E "github-actions graph"
shell: bash
run: |
pip install ".[dev,github-actions,graph,mqf2]"

# - name: Install pytorch geometric dependencies
# shell: bash
# run: poetry run pip install pyg_lib torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-2.0.0+cpu.html
- name: Show dependencies
run: python -m pip list

- name: Run pytest
run: poetry run pytest tests
shell: bash
run: python -m pytest tests

- name: Statistics
run: |
Expand Down
123 changes: 51 additions & 72 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ exclude = '''
isort = 1
black = 1

[tool.poetry]
[project]
name = "pytorch_forecasting"
readme = "README.md" # Markdown files are supported
version = "0.0.0" # is being replaced automatically
version = "1.0.0" # is being replaced automatically

authors = ["Jan Beitner"]
authors = [
{name = "Jan Beitner"},
]
requires-python = ">=3.8,<3.11"
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
Expand All @@ -48,76 +51,52 @@ classifiers = [
"License :: OSI Approved :: MIT License",
]
description = "Forecasting timeseries with PyTorch - dataloaders, normalizers, metrics and models"
repository = "https://github.com/jdb78/pytorch-forecasting"
documentation = "https://pytorch-forecasting.readthedocs.io"
homepage = "https://pytorch-forecasting.readthedocs.io"

[tool.poetry.dependencies]
python = ">=3.8,<3.11"

torch = "^2.0.0,!=2.0.1"
lightning = "^2.0.0"
optuna = "^3.1.0"
optuna-integration="*"
scipy = "^1.8"
pandas = ">=1.3.0,<=3.0.0"
pyarrow = "*"
scikit-learn = "^1.2"
matplotlib = "*"
tensorboard = "^2.12.1"
cpflows = "^0.1.2"
statsmodels = "*"

pytest-github-actions-annotate-failures = { version = "*", optional = true }
networkx = { version = "^3.0.0", optional = true }
fastapi = ">=0.80"
pytorch-optimizer = "^2.5.1"

[tool.poetry.group.dev.dependencies]
pydocstyle = "^6.1.1"
# checks and make tools
pre-commit = "^3.2.0"

invoke = "*"
flake8 = "*"
mypy = "*"
pylint = "*"
isort = "*"

# pytest
pytest = "*"
pytest-xdist = "*"
pytest-cov = "*"
pytest-sugar = "*"
coverage = "*"
pyarrow = "*"

# jupyter notebook
ipykernel = "*"
black = { version = "*", allow-prereleases = true, extras = ["jupyter"] }
dependencies = [
"numpy<2.0.0",
"torch >=2.0.0,!=2.0.1,<3.0.0",
"lightning >=2.0.0,<3.0.0",
"optuna >=3.1.0,<3.3.0",
"scipy >=1.8,<2.0",
"pandas >=1.3.0,<3.0.0",
"scikit-learn >=1.2,<2.0",
"matplotlib",
"statsmodels",
"pytorch-optimizer >=2.5.1,<3.0.0",
]

# documentatation
sphinx = "*"
pydata-sphinx-theme = "*"
nbsphinx = "*"
# pandoc = "*" # todo: bring back later when install works again
recommonmark = "*"
ipywidgets = "^8.0.1"
pytest-dotenv = "^0.5.2"
tensorboard = "^2.12.1"
pandoc = "^2.3"
[project.optional-dependencies]

dev = [
"pydocstyle >=6.1.1,<7.0.0",
# checks and make tools
"pre-commit >=3.2.0,<4.0.0",
"invoke",
"flake8",
"mypy",
"pylint",
"isort",
# pytest
"pytest",
"pytest-xdist",
"pytest-cov",
"pytest-sugar",
"coverage",
"pyarrow",
# jupyter notebook
"ipykernel",
"black[extras]",
# documentatation
"sphinx",
"pydata-sphinx-theme",
"nbsphinx",
"recommonmark",
"ipywidgets>=8.0.1,<9.0.0",
"pytest-dotenv>=0.5.2,<1.0.0",
"tensorboard>=2.12.1,<3.0.0",
"pandoc>=2.3,<3.0.0",
]

[tool.poetry.extras] # extras
github-actions = ["pytest-github-actions-annotate-failures"]
graph = ["networkx"]

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
dirty = false
style = "semver" # semantic versioning

[build-system] # make the package pip installable
requires = ["poetry-core>=1.0.7", "poetry-dynamic-versioning>=0.13.1"]
build-backend = "poetry_dynamic_versioning.backend"
mqf2 = ["cpflows"]
1 change: 1 addition & 0 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_aggregation_metric(decoder_lengths, y):
assert torch.isclose(res, (y.mean(0) - y_pred.mean(0)).abs().mean())


@pytest.mark.xfail(reason="failing, to be fixed, bug #1614")
def test_none_reduction():
pred = torch.rand(20, 10)
target = torch.rand(20, 10)
Expand Down
Loading