From 16a765123142b68d65784e8ff9cc8d8d457ff492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Morales?= Date: Thu, 14 Mar 2024 20:03:01 +0000 Subject: [PATCH] add pre-commit --- .github/workflows/lint.yaml | 25 +++++++++++++++++++++++++ CONTRIBUTING.md | 1 + nbs/docs/tutorials/5_finetuning.ipynb | 4 ---- nixtlats/distributed/timegpt.py | 1 + nixtlats/timegpt.py | 10 +++++++--- setup.py | 2 +- 6 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..945a3831 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,25 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Clone repo + uses: actions/checkout@v2 + + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies + run: pip install black nbdev pre-commit + + - name: Run pre-commit + run: pre-commit run diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b711b693..c2235c59 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,6 +59,7 @@ Please write to `ops@nixtla.io` if you're insterested in contributing to this pr Before doing any changes to the code, please install the git hooks that run automatic scripts during each commit and merge to strip the notebooks of superfluous metadata (and avoid merge conflicts). ``` nbdev_install_hooks +pre-commit install ``` ### Preview Changes diff --git a/nbs/docs/tutorials/5_finetuning.ipynb b/nbs/docs/tutorials/5_finetuning.ipynb index 0ac19fa4..37e35787 100644 --- a/nbs/docs/tutorials/5_finetuning.ipynb +++ b/nbs/docs/tutorials/5_finetuning.ipynb @@ -307,10 +307,6 @@ "display_name": "python3", "language": "python", "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.10.13" } }, "nbformat": 4, diff --git a/nixtlats/distributed/timegpt.py b/nixtlats/distributed/timegpt.py index 0bb94c63..e629f0a1 100644 --- a/nixtlats/distributed/timegpt.py +++ b/nixtlats/distributed/timegpt.py @@ -47,6 +47,7 @@ def _cotransform( # %% ../../nbs/distributed.timegpt.ipynb 4 class _DistributedTimeGPT: + def __init__( self, token: Optional[str] = None, diff --git a/nixtlats/timegpt.py b/nixtlats/timegpt.py index 13c2903d..71f1dcd6 100644 --- a/nixtlats/timegpt.py +++ b/nixtlats/timegpt.py @@ -90,6 +90,7 @@ # %% ../nbs/timegpt.ipynb 6 class _TimeGPTModel: + def __init__( self, client: Nixtla, @@ -575,9 +576,11 @@ def detect_anomalies(self, df: pd.DataFrame): y=y, x=x, freq=self.freq, - level=[self.level] - if (isinstance(self.level, int) or isinstance(self.level, float)) - else [self.level[0]], + level=( + [self.level] + if (isinstance(self.level, int) or isinstance(self.level, float)) + else [self.level[0]] + ), clean_ex_first=self.clean_ex_first, model=self.model, ), @@ -1024,6 +1027,7 @@ def plot( # %% ../nbs/timegpt.ipynb 11 class TimeGPT(_TimeGPT): + def _instantiate_distributed_timegpt(self): from nixtlats.distributed.timegpt import _DistributedTimeGPT diff --git a/setup.py b/setup.py index f7e5aab7..83321f42 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ with open("README.md", "r", encoding="utf8") as fh: long_description = fh.read() -dev = ["black", "nbdev", "plotly", "python-dotenv", "statsforecast", "datasetsforecast"] +dev = ["black", "datasetsforecast", "nbdev", "plotly", "python-dotenv", "statsforecast", "pre-commit"] distributed = ["dask[dataframe]", "fugue[ray]>=0.8.7", "pyspark", "ray[serve-grpc]"] plotting = ["utilsforecast[plotting]>=0.0.5"] date_extras = ["holidays"]