Skip to content

Commit

Permalink
Fix error in init town (#8)
Browse files Browse the repository at this point in the history
* Add files via upload

* Add files via upload

* Add files via upload

* Test whether more relaxed mypy could reduce captured error in init-town

* sync template

* support research_town

* fix codespell bug

* fix formatting

* test pytest

* fix mypy errors

* try to pass pytest

* try to pass pytest

* pass all pre-commit

* pass all pre-commit

* pass all pre-commit

* fix isort bug

* fix isort bug

* fix mypy types

* fix ruff

* delete install mypy things

* fix isort

* fix isort

* update poetry dependency

* add torch support

* add isort support

* add transformers

* fix pytest error

* fix pytest error

* solve pytest warning

* solve pytest

---------

Co-authored-by: ft2023 <[email protected]>
Co-authored-by: Haofei Yu <[email protected]>
  • Loading branch information
3 people authored May 9, 2024
1 parent c3fd5c3 commit 0ddc19f
Show file tree
Hide file tree
Showing 22 changed files with 1,830 additions and 295 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: codespell

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

jobs:
codespell:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codespell==2.2.6 tomli==2.0.1
- name: Spelling check with codespell
run: |
codespell --toml pyproject.toml
31 changes: 31 additions & 0 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: isort

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

jobs:
isort:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install isort==5.13.2
- name: Run isort
run: |
isort . --check-only
22 changes: 16 additions & 6 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
name: Mypy
on: [push]
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

jobs:
Static-Type-Checking:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.11.2
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
Expand All @@ -21,4 +31,4 @@ jobs:
run: |
# Run this mypy instance against our main package.
poetry run pip install types-protobuf==4.24.0.4
poetry run mypy --strict .
poetry run mypy --config-file pyproject.toml .
12 changes: 8 additions & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ on:
jobs:
pre-commit:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.11.2
python-version: ${{ matrix.python-version }}
31 changes: 31 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ruff

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ruff:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff==0.1.5
- name: Analysing the code with ruff
run: |
ruff check .
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: Pytest
on: [push]
on:
pull_request:
push:
branches: [main]

jobs:
Pytest:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.11.2
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
Expand Down
34 changes: 11 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
repos:
- repo: local
hooks:
- id: poetry-update
name: Poetry Update
entry: poetry update
language: system
# Optional: specify types or files to trigger this hook
# files: pyproject.toml
# Always run this hook (not recommended for update; shown for illustrative purposes):
always_run: true
# Optional: prevent commit if the lock file changes
stages: [pre-commit]
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
Expand All @@ -24,16 +11,17 @@ repos:
hooks:
- id: prettier
types_or: [html]
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", --line-length=72]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5 # Ruff version
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1 # Use the latest isort version
hooks:
- id: isort # This will sort imports automatically
- repo: https://github.com/kynan/nbstripout
rev: 0.6.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# research-town
# research-town
Loading

0 comments on commit 0ddc19f

Please sign in to comment.