diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1984fcf3..73b66d33 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,7 +26,6 @@ jobs: pip install -U pip pip install -U setuptools pip install -r requirements.txt - pip install -r requirements-test.txt - python -m pip install -U --editable . + python -m pip install -U --editable ".[dev]" - name: Test with pytest - run: pytest -vs tests/ --cov orbit/ + run: python -m pytest tests/ diff --git a/MANIFEST.in b/MANIFEST.in index bf21e12f..d71a7df8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,18 +1,12 @@ include LICENSE include README.md +include pyproject.toml include *.txt include requirements.txt include requirements-test.txt include orbit/stan/*.stan include orbit/stylelib/*.mplstyle -prune orbit/stan_compiled -prune orbit/stan/dlt -prune orbit/stan/ets -prune orbit/stan/ktrlite -prune orbit/stan/lgt -prune orbit/stan/*.hpp - recursive-include tests * recursive-exclude * __pycache__ recursive-exclude * *.py[co] diff --git a/docs/tutorials/regression_penalty.ipynb b/docs/tutorials/regression_penalty.ipynb index 0168e900..124700da 100644 --- a/docs/tutorials/regression_penalty.ipynb +++ b/docs/tutorials/regression_penalty.ipynb @@ -22,23 +22,14 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2022-04-28T21:49:43.395926Z", "start_time": "2022-04-28T21:49:40.870237Z" } }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/towinazure/opt/miniconda3/envs/orbit39/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n" - ] - } - ], + "outputs": [], "source": [ "%matplotlib inline\n", "\n", @@ -54,22 +45,14 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2022-04-28T21:49:43.400898Z", "start_time": "2022-04-28T21:49:43.398300Z" } }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1.1.4.2\n" - ] - } - ], + "outputs": [], "source": [ "print(orbit.__version__)" ] diff --git a/orbit/__init__.py b/orbit/__init__.py index 22236417..fd9e0ddc 100644 --- a/orbit/__init__.py +++ b/orbit/__init__.py @@ -1,2 +1,8 @@ -name = "orbit" -__version__ = "1.1.4.2" +from pathlib import Path + +about = {} +here = Path(__file__).parent.resolve() + +with open(here / "__version__.py", "r") as f: + exec(f.read(), about) +__version__ = about["__version__"] diff --git a/orbit/__version__.py b/orbit/__version__.py new file mode 100644 index 00000000..28fdf7aa --- /dev/null +++ b/orbit/__version__.py @@ -0,0 +1 @@ +__version__ = "1.1.4.3" diff --git a/pyproject.toml b/pyproject.toml index e2171448..fe2c91f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,11 +24,16 @@ readme = "README.md" requires-python = ">=3.7" dependencies = [ "cmdstanpy>=1.0.4", - "numpy>=1.15.4", - "matplotlib>=2.0.0", - "pandas>=1.0.4", + "numpy>=1.18", + "pandas>=1.0.3", "tqdm>=4.36.1", "importlib_resources", + "matplotlib>=3.3.2", + "scipy>=1.4.1", + "torch>=1.11.0", + "seaborn>=0.10.0", + "pyro-ppl>=1.4.0", + "arviz", ] license = {text = "Apache License 2.0"} classifiers = [ @@ -39,4 +44,11 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", +] +[project.optional-dependencies] +dev = [ + "setuptools>=64", + "wheel", + "pytest", + "black", ] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 3e5df996..8c2c0bda 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,4 @@ statsmodels>=0.11.1 arviz cmdstanpy>=1.0.4 setuptools>=42 +importlib_resources \ No newline at end of file diff --git a/setup.py b/setup.py index 169ea173..57a6a03f 100644 --- a/setup.py +++ b/setup.py @@ -41,17 +41,17 @@ def requirements(filename="requirements.txt"): return f.readlines() -class PyTestCommand(test_command): - def finalize_options(self): - test_command.finalize_options(self) - self.test_args = ["-v"] # test args - self.test_suite = True +# class PyTestCommand(test_command): +# def finalize_options(self): +# test_command.finalize_options(self) +# self.test_args = ["-v"] # test args +# self.test_suite = True - def run_tests(self): - import pytest +# def run_tests(self): +# import pytest - errcode = pytest.main(self.test_args) - sys.exit(errcode) +# errcode = pytest.main(self.test_args) +# sys.exit(errcode) def build_stan_model(target_dir): @@ -148,8 +148,7 @@ def run(self): target_dir = os.path.join(self.build_lib, MODEL_TARGET_DIR) self.mkpath(target_dir) - print("Not a dry run, run with build, target_dir:") - print("building with target_dir: {}".format(target_dir)) + print("Not a dry run, run with build, target_dir: {}".format(target_dir)) build_stan_model(target_dir) @@ -182,8 +181,7 @@ def run(self): target_dir = os.path.join(self.project_dir, MODEL_TARGET_DIR) self.mkpath(target_dir) - print("Not a dry run, run with editable, target_dir:") - print("building with target_dir: {}".format(target_dir)) + print("Not a dry run, run with editable, target_dir: {}".format(target_dir)) build_stan_model(target_dir) @@ -200,7 +198,16 @@ def get_tag(self): return "py3", "none", plat +about = {} +here = Path(__file__).parent.resolve() +with open(here / "orbit" / "__version__.py", "r") as f: + exec(f.read(), about) + + setup( + version=about["__version__"], + packages=find_packages(), + name="orbit-ml", author="Edwin Ng, Zhishi Wang, Steve Yang, Yifeng Wu, Jing Pan", author_email="edwinnglabs@gmail.com", description=DESCRIPTION, @@ -211,23 +218,16 @@ def get_tag(self): cmdclass={ "build_ext": BuildExtCommand, "build_py": BuildPyCommand, + "editable_wheel": EditableWheel, + "bdist_wheel": BDistWheelABINone, # "develop": DevelopCommand, - "test": PyTestCommand, + # "test": PyTestCommand, }, test_suite="orbit.tests", - license="Apache License 2.0", long_description=read_long_description(), long_description_content_type="text/markdown", - name="orbit-ml", - packages=find_packages(), url="https://orbit-ml.readthedocs.io/en/stable/", # version=VERSION, # being maintained by source module ext_modules=[Extension("orbit.stan_compiled", [])], zip_safe=False, - classifiers=[ - "Development Status :: 3 - Alpha", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - ], ) diff --git a/tests/conftest.py b/tests/conftest.py index 6543ecaa..06873b31 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ import pytest import pandas as pd import numpy as np -import pkg_resources +import importlib_resources from copy import deepcopy from orbit.utils.simulation import make_trend, make_seasonality, make_regression @@ -9,16 +9,14 @@ @pytest.fixture def iclaims_training_data(): - test_file = pkg_resources.resource_filename( - "tests", "resources/iclaims.example.csv" - ) + test_file = importlib_resources.files("tests") / "resources/iclaims.example.csv" df = pd.read_csv(test_file, parse_dates=["week"]) return df @pytest.fixture def m3_monthly_data(): - test_file = pkg_resources.resource_filename("tests", "resources/m3-monthly.csv") + test_file = importlib_resources.files("tests") / "resources/m3-monthly.csv" df = pd.read_csv(test_file, parse_dates=["date"]) return df @@ -497,9 +495,7 @@ def ca_hourly_electricity_data(): Sources: https://github.com/pratha19/Hourly_Energy_Consumption_Prediction """ - test_file = pkg_resources.resource_filename( - "tests", "resources/hourly1418CA_2018.csv" - ) + test_file = importlib_resources.files("tests") / "resources/hourly1418CA_2018.csv" df = pd.read_csv( test_file, parse_dates=["Dates", "Date"],