Skip to content

Commit

Permalink
Merge branch 'main' into typo-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fkiraly committed Oct 3, 2024
2 parents 7a5aa0d + fdf8a7f commit 066e7c8
Show file tree
Hide file tree
Showing 17 changed files with 251 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Lint

on:
push:
branches: [master]
branches: [main]
pull_request:
branches: [master]
branches: [main]

jobs:
pre-commit-hooks:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Test

on:
push:
branches: [master]
branches: [main]
pull_request:
branches: [master]
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
Expand Down Expand Up @@ -137,15 +137,15 @@ jobs:
shell: bash
steps:
- name: Check out Git repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
Expand All @@ -162,7 +162,7 @@ jobs:
run: make html --debug --jobs 2 SPHINXOPTS="-W"

- name: Upload built docs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: docs-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}
path: docs/build/html/
Expand Down
12 changes: 9 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ sphinx:
formats:
- htmlzip

# Optionally set the version of Python and requirements required to build your docs
build:
os: ubuntu-22.04
tools:
python: "3.12"

python:
version: 3.11
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- docs
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## v1.1.1

Hotfix for accidental package name change in `pyproject.toml`.

The package name is now corrected to `pytorch-forecasting`.


## v1.1.0

Maintenance update widening compatibility ranges and consolidating dependencies:
Expand Down
8 changes: 4 additions & 4 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ _PyTorch Forecasting_ is a PyTorch-based package for forecasting with state-of-t

| | **[Documentation](https://pytorch-forecasting.readthedocs.io)** · **[Tutorials](https://pytorch-forecasting.readthedocs.io/en/latest/tutorials.html)** · **[Release Notes](https://pytorch-forecasting.readthedocs.io/en/latest/CHANGELOG.html)** |
|---|---|
| **Open Source** | [![MIT](https://img.shields.io/github/license/jdb78/pytorch-forecasting)](https://github.com/jdb78/pytorch-forecasting/blob/master/LICENSE) |
| **Open Source** | [![MIT](https://img.shields.io/github/license/sktime/pytorch-forecasting)](https://github.com/sktime/pytorch-forecasting/blob/master/LICENSE) |
| **Community** | [![!discord](https://img.shields.io/static/v1?logo=discord&label=discord&message=chat&color=lightgreen)](https://discord.com/invite/54ACzaFsn7) [![!slack](https://img.shields.io/static/v1?logo=linkedin&label=LinkedIn&message=news&color=lightblue)](https://www.linkedin.com/company/scikit-time/) |
| **CI/CD** | [![github-actions](https://img.shields.io/github/actions/workflow/status/jdb78/pytorch-forecasting/pypi_release.yml?logo=github)](https://github.com/jdb78/pytorch-forecasting/actions/workflows/pypi_release.yml) [![readthedocs](https://img.shields.io/readthedocs/pytorch-forecasting?logo=readthedocs)](https://pytorch-forecasting.readthedocs.io) [![platform](https://img.shields.io/conda/pn/conda-forge/pytorch-forecasting)](https://github.com/jdb78/pytorch-forecasting) [![Code Coverage][coverage-image]][coverage-url] |
| **CI/CD** | [![github-actions](https://img.shields.io/github/actions/workflow/status/sktime/pytorch-forecasting/pypi_release.yml?logo=github)](https://github.com/sktime/pytorch-forecasting/actions/workflows/pypi_release.yml) [![readthedocs](https://img.shields.io/readthedocs/pytorch-forecasting?logo=readthedocs)](https://pytorch-forecasting.readthedocs.io) [![platform](https://img.shields.io/conda/pn/conda-forge/pytorch-forecasting)](https://github.com/sktime/pytorch-forecasting) [![Code Coverage][coverage-image]][coverage-url] |
| **Code** | [![!pypi](https://img.shields.io/pypi/v/pytorch-forecasting?color=orange)](https://pypi.org/project/pytorch-forecasting/) [![!conda](https://img.shields.io/conda/vn/conda-forge/pytorch-forecasting)](https://anaconda.org/conda-forge/pytorch-forecasting) [![!python-versions](https://img.shields.io/pypi/pyversions/pytorch-forecasting)](https://www.python.org/) [![!black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) |

[coverage-image]: https://codecov.io/gh/jdb78/pytorch-forecasting/branch/master/graph/badge.svg
[coverage-url]: https://codecov.io/github/jdb78/pytorch-forecasting?branch=master
[coverage-image]: https://codecov.io/gh/sktime/pytorch-forecasting/branch/main/graph/badge.svg
[coverage-url]: https://codecov.io/github/sktime/pytorch-forecasting?branch=main

---

Expand Down
2 changes: 1 addition & 1 deletion docs/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ a.nav-link
color: #647db6 !important;
}

a.nav-link[href="https://github.com/jdb78/pytorch-forecasting"]
a.nav-link[href="https://github.com/sktime/pytorch-forecasting"]
{
color: #ee4c2c !important;
}
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# https://www.sphinx-doc.org/en/main/usage/configuration.html

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -141,11 +141,11 @@ def setup(app: Sphinx):

# theme options
html_theme_options = {
"github_url": "https://github.com/jdb78/pytorch-forecasting",
"github_url": "https://github.com/sktime/pytorch-forecasting",
"navbar_end": ["navbar-icon-links.html", "search-field.html"],
"show_nav_level": 2,
"header_links_before_dropdown": 10,
"external_links": [{"name": "GitHub", "url": "https://github.com/jdb78/pytorch-forecasting"}],
"external_links": [{"name": "GitHub", "url": "https://github.com/sktime/pytorch-forecasting"}],
}

html_sidebars = {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PyTorch Forecasting Documentation

.. raw:: html

<a class="github-button" href="https://github.com/jdb78/pytorch-forecasting" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star jdb78/pytorch-forecasting on GitHub">GitHub</a>
<a class="github-button" href="https://github.com/sktime/pytorch-forecasting" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star sktime/pytorch-forecasting on GitHub">GitHub</a>


Our article on `Towards Data Science <https://towardsdatascience.com/introducing-pytorch-forecasting-64de99b9ef46>`_
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Tutorials

.. _tutorials:

The following tutorials can be also found as `notebooks on GitHub <https://github.com/jdb78/pytorch-forecasting/tree/master/docs/source/tutorials>`_.
The following tutorials can be also found as `notebooks on GitHub <https://github.com/sktime/pytorch-forecasting/tree/main/docs/source/tutorials>`_.

.. toctree::
:titlesonly:
Expand Down
15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ isort = 1
black = 1

[project]
name = "pytorch_forecasting"
name = "pytorch-forecasting"
readme = "README.md" # Markdown files are supported
version = "1.1.0" # is being replaced automatically
version = "1.1.1" # is being replaced automatically

authors = [
{name = "Jan Beitner"},
Expand Down Expand Up @@ -133,6 +133,17 @@ dev = [
"pandoc>=2.3,<3.0.0",
]

# docs - dependencies for building the documentation
docs = [
"sphinx>3.2",
"pydata-sphinx-theme",
"nbsphinx",
"pandoc",
"nbconvert",
"recommonmark",
"docutils",
]

github-actions = ["pytest-github-actions-annotate-failures"]

[tool.setuptools.packages.find]
Expand Down
6 changes: 4 additions & 2 deletions pytorch_forecasting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
PyTorch Forecasting package for timeseries forecasting with PyTorch.
"""

__version__ = "1.1.1"

from pytorch_forecasting.data import (
EncoderNormalizer,
GroupNormalizer,
Expand Down Expand Up @@ -59,6 +61,7 @@
to_list,
unpack_sequence,
)
from pytorch_forecasting.utils._maint._show_versions import show_versions

__all__ = [
"TimeSeriesDataSet",
Expand Down Expand Up @@ -109,7 +112,6 @@
"integer_histogram",
"groupby_apply",
"profile",
"show_versions",
"unpack_sequence",
]

__version__ = "1.1.0"
2 changes: 1 addition & 1 deletion pytorch_forecasting/data/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import pandas as pd

BASE_URL = "https://github.com/jdb78/pytorch-forecasting/raw/master/examples/data/"
BASE_URL = "https://github.com/sktime/pytorch-forecasting/raw/main/examples/data/"

DATA_PATH = Path(__file__).parent

Expand Down
Empty file.
142 changes: 142 additions & 0 deletions pytorch_forecasting/utils/_maint/_show_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# License: BSD 3 clause
"""Utility methods to print system info for debugging.
adapted from
:func: `sklearn.show_versions` and `sktime.show_versions`
"""

__all__ = ["show_versions"]

import importlib
import platform
import sys


def _get_sys_info():
"""System information.
Return
------
sys_info : dict
system and Python version information
"""
python = sys.version.replace("\n", " ")

blob = [
("python", python),
("executable", sys.executable),
("machine", platform.platform()),
]

return dict(blob)


# dependencies to print versions of, by default
DEFAULT_DEPS_TO_SHOW = [
"pip",
"pytorch-forecasting",
"torch",
"lightning",
"numpy",
"scipy",
"pandas",
"cpflows",
"matplotlib",
"optuna",
"optuna-integration",
"pytorch_optimizer",
"scikit-learn",
"scikit-base",
"statsmodels",
]


def _get_deps_info(deps=None, source="distributions"):
"""Overview of the installed version of main dependencies.
Parameters
----------
deps : optional, list of strings with package names
if None, behaves as deps = ["sktime"].
source : str, optional one of "distributions" (default) or "import"
source of version information
* "distributions" - uses importlib.distributions. In this case,
strings in deps are assumed to be PEP 440 package strings,
e.g., scikit-learn, not sklearn.
* "import" - uses the __version__ attribute of the module.
In this case, strings in deps are assumed to be import names,
e.g., sklearn, not scikit-learn.
Returns
-------
deps_info: dict
version information on libraries in `deps`
keys are package names, import names if source is "import",
and PEP 440 package strings if source is "distributions";
values are PEP 440 version strings
of the import as present in the current python environment
"""
if deps is None:
deps = ["pytorch-forecasting"]

if source == "distributions":
from pytorch_forecasting.utils._dependencies import _get_installed_packages

KEY_ALIAS = {"sklearn": "scikit-learn", "skbase": "scikit-base"}

pkgs = _get_installed_packages()

deps_info = {}
for modname in deps:
pkg_name = KEY_ALIAS.get(modname, modname)
deps_info[modname] = pkgs.get(pkg_name, None)

return deps_info

def get_version(module):
return getattr(module, "__version__", None)

deps_info = {}

for modname in deps:
try:
if modname in sys.modules:
mod = sys.modules[modname]
else:
mod = importlib.import_module(modname)
except ImportError:
deps_info[modname] = None
else:
ver = get_version(mod)
deps_info[modname] = ver

return deps_info


def show_versions():
"""Print python version, OS version, sktime version, selected dependency versions.
Pretty prints:
* python version of environment
* python executable location
* OS version
* list of import name and version number for selected python dependencies
Developer note:
Python version/executable and OS version are from `_get_sys_info`
Package versions are retrieved by `_get_deps_info`
Selected dependencies are as in the DEFAULT_DEPS_TO_SHOW variable
"""
sys_info = _get_sys_info()
deps_info = _get_deps_info(deps=DEFAULT_DEPS_TO_SHOW)

print("\nSystem:") # noqa: T001, T201
for k, stat in sys_info.items():
print(f"{k:>10}: {stat}") # noqa: T001, T201

print("\nPython dependencies:") # noqa: T001, T201
for k, stat in deps_info.items():
print(f"{k:>13}: {stat}") # noqa: T001, T201
9 changes: 8 additions & 1 deletion pytorch_forecasting/utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,14 @@ def move_to_device(
x on targeted device
"""
if isinstance(device, str):
device = torch.device(device)
if device == "mps":
if hasattr(torch.backends, device):
if torch.backends.mps.is_available() and torch.backends.mps.is_built():
device = torch.device("mps")
else:
device = torch.device("cpu")
else:
device = torch.device(device)
if isinstance(x, dict):
for name in x.keys():
x[name] = move_to_device(x[name], device=device)
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ def test_dataset(test_data):
randomize_length=None,
)
return training


@pytest.fixture(autouse=True)
def disable_mps(monkeypatch):
"""Disable MPS for all tests"""
monkeypatch.setattr("torch._C._mps_is_available", lambda: False)
Loading

0 comments on commit 066e7c8

Please sign in to comment.