From 58f80bf974a2a67aa400604c8392d889780ff1ff Mon Sep 17 00:00:00 2001 From: Ravi Kalia Date: Thu, 10 Apr 2025 14:07:51 -0600 Subject: [PATCH 1/5] Update formatting to include all Python files in project --- .github/workflows/ci.yml | 6 +++--- Makefile | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eacd1fb..5efcc7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,16 +25,16 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install -r requirements.txt pip install -e . - pip install pytest pytest-cov black isort - name: Check formatting with black run: | - black --check anomaly_detection/ tests/ + black --check . - name: Check import sorting with isort run: | - isort --check-only anomaly_detection/ tests/ + isort --check-only . - name: Run tests with coverage run: | diff --git a/Makefile b/Makefile index df7d754..6559499 100644 --- a/Makefile +++ b/Makefile @@ -8,18 +8,18 @@ test: pytest tests/ --cov=anomaly_detection --cov-report=term-missing -v lint: - black --check anomaly_detection/ tests/ - isort --check-only anomaly_detection/ tests/ + black --check . + isort --check-only . format: - black anomaly_detection/ tests/ - isort anomaly_detection/ tests/ + black . + isort . check-format: - black --check anomaly_detection/ tests/ + black --check . check-imports: - isort --check-only anomaly_detection/ tests/ + isort --check-only . clean: find . -type d -name "__pycache__" -exec rm -r {} + From f1063baaaac86b6fe508b2fc27eaeba13aebd85d Mon Sep 17 00:00:00 2001 From: Ravi Kalia Date: Thu, 10 Apr 2025 14:08:53 -0600 Subject: [PATCH 2/5] Reorder requirements.txt alphabetically --- requirements.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index 559cc38..49e170d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,13 @@ -numpy>=1.21.0 -pandas>=1.3.0 -scikit-learn>=0.24.2 +black>=21.7b0 boto3>=1.26.0 fastapi>=0.68.0 -uvicorn>=0.15.0 +flake8>=3.9.2 +httpx>=0.24.0 +isort>=5.9.3 +numpy>=1.21.0 +pandas>=1.3.0 python-dotenv>=0.19.0 pytest>=6.2.5 pytest-cov>=2.12.1 -black>=21.7b0 -isort>=5.9.3 -flake8>=3.9.2 -httpx>=0.24.0 \ No newline at end of file +scikit-learn>=0.24.2 +uvicorn>=0.15.0 \ No newline at end of file From fa18468ad4314dbeafca1387507f11ea08a08452 Mon Sep 17 00:00:00 2001 From: Ravi Kalia Date: Thu, 10 Apr 2025 14:11:20 -0600 Subject: [PATCH 3/5] Add pre-commit hooks and fix formatting --- .pre-commit-config.yaml | 27 +++++++++++++++++++++++++++ Makefile | 9 ++++++--- requirements.txt | 3 ++- setup.py | 4 ++-- 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0c5eaa0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + + - repo: https://github.com/psf/black + rev: 24.1.1 + hooks: + - id: black + language_version: python3.9 + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--profile", "black"] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: no-commit-to-branch + args: [--branch, main] diff --git a/Makefile b/Makefile index 6559499..7b36b7a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ -.PHONY: install test lint format check-format check-imports clean +.PHONY: install test lint format check-format check-imports clean setup-pre-commit install: pip install -e . - pip install pytest pytest-cov black isort + pip install pytest pytest-cov black isort pre-commit + +setup-pre-commit: + pre-commit install test: pytest tests/ --cov=anomaly_detection --cov-report=term-missing -v @@ -32,4 +35,4 @@ clean: find . -type d -name ".pytest_cache" -exec rm -r {} + find . -type d -name ".coverage" -exec rm -r {} + find . -type d -name "htmlcov" -exec rm -r {} + - find . -type f -name "coverage.xml" -delete \ No newline at end of file + find . -type f -name "coverage.xml" -delete diff --git a/requirements.txt b/requirements.txt index 49e170d..4d18005 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,8 +6,9 @@ httpx>=0.24.0 isort>=5.9.3 numpy>=1.21.0 pandas>=1.3.0 +pre-commit>=3.6.0 python-dotenv>=0.19.0 pytest>=6.2.5 pytest-cov>=2.12.1 scikit-learn>=0.24.2 -uvicorn>=0.15.0 \ No newline at end of file +uvicorn>=0.15.0 diff --git a/setup.py b/setup.py index 4e797d4..b35522b 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup setup( name="anomaly_detection", @@ -16,4 +16,4 @@ "pytest-cov>=2.12.0", ], python_requires=">=3.8", -) \ No newline at end of file +) From 2ffefd27d3889e1ac0e8762a4efa96cef6beeb32 Mon Sep 17 00:00:00 2001 From: Ravi Kalia Date: Thu, 10 Apr 2025 14:13:34 -0600 Subject: [PATCH 4/5] Add Codecov token to CI workflow --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5efcc7e..66eb950 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,3 +45,4 @@ jobs: with: file: ./coverage.xml fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} From d99ca219d985b4a6632407460a69b542d9c19999 Mon Sep 17 00:00:00 2001 From: Ravi Kalia Date: Thu, 10 Apr 2025 14:15:06 -0600 Subject: [PATCH 5/5] Remove Codecov configuration from CI workflow --- .github/workflows/ci.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66eb950..84e7ab6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,11 +38,4 @@ jobs: - name: Run tests with coverage run: | - pytest tests/ --cov=anomaly_detection --cov-report=xml -v - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - file: ./coverage.xml - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} + pytest tests/ --cov=anomaly_detection -v