Skip to content

Commit

Permalink
use pre-commit (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez authored Mar 9, 2024
1 parent 076f863 commit 4e9b721
Show file tree
Hide file tree
Showing 31 changed files with 146 additions and 92 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,6 @@ concurrency:
cancel-in-progress: true

jobs:
nb-sync:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v3

- name: Set up python
uses: actions/setup-python@v4

- name: Install nbdev
run: pip install nbdev

- name: Check if all notebooks are cleaned
run: |
echo "Check we are starting with clean git checkout"
if [ -n "$(git status -uno -s)" ]; then echo "git status is not clean"; false; fi
echo "Trying to strip out notebooks"
nbdev_clean
echo "Check that strip out was unnecessary"
git status -s # display the status to see which nbs need cleaning up
if [ -n "$(git status -uno -s)" ]; then echo -e "!!! Detected unstripped out notebooks\n!!!Remember to run nbdev_install_git_hooks"; false; fi
run-tests:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ jobs:
with:
python-version: 3.8

- name: Install linters
run: pip install mypy ruff
- name: Install dependencies
run: pip install black nbdev pre-commit

- name: mypy
run: mypy neuralforecast/

- name: Ruff
run: ruff neuralforecast/
- name: Run pre-commit
run: pre-commit run --files neuralforecast/*
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/fastai/nbdev
rev: 2.2.10
hooks:
- id: nbdev_clean
- id: nbdev_export
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
args: [--ignore-missing-imports]
7 changes: 1 addition & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Once you have your environment setup, activate it using `conda activate neuralfo
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
Expand All @@ -64,12 +65,6 @@ The library is built using the notebooks contained in the `nbs` folder. If you w
nbdev_export
```

### Linters
This project uses a couple of linters to validate different aspects of the code. Before opening a PR, please make sure that it passes all the linting tasks by following the next steps.

* `mypy neuralforecast/`
* `ruff neuralforecast/`

### Running tests
If you're working on the local interface you can just use `nbdev_test --n_workers 1 --do_print --timing`.

Expand Down
2 changes: 0 additions & 2 deletions nbs/models.tsmixer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"outputs": [],
"source": [
"#| export\n",
"from typing import Optional\n",
"\n",
"import torch\n",
"import torch.nn as nn\n",
"import torch.nn.functional as F\n",
Expand Down
Loading

0 comments on commit 4e9b721

Please sign in to comment.