Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠 Fix tox configuration #446

Merged
merged 8 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pre_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Tox
run: pip install tox
- name: Code quality checks
run: tox -e black,isort,flake8,pylint,mypy,pydocstyle,notebooks
run: tox -e pre-commit
- name: Coverage
run: |
export ANOMALIB_DATASET_PATH=/media/data1/datasets/
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.3.0
hooks:
# list of supported hooks: https://pre-commit.com/hooks.html
- id: trailing-whitespace
Expand All @@ -12,28 +12,28 @@ repos:

# python code formatting
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
args: [--line-length, "120"]

# python import sorting
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]

# yaml formatting
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.3.0
rev: v2.7.1
hooks:
- id: prettier
types: [yaml]

# python code analysis
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
rev: 4.0.1
hooks:
- id: flake8
args: [--config=tox.ini]
Expand All @@ -51,7 +51,7 @@ repos:

# python static type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v0.910"
rev: "v0.971"
hooks:
- id: mypy
args: [--config-file=tox.ini]
Expand All @@ -71,7 +71,7 @@ repos:

# notebooks.
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.1
rev: 1.4.0
hooks:
- id: nbqa-black
- id: nbqa-isort
Expand Down
2 changes: 1 addition & 1 deletion anomalib/models/components/base/dynamic_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_tensor_attribute(self, attribute_name: str) -> Tensor:
Returns:
Tensor: Tensor attribute
"""
attribute = self.__getattr__(attribute_name)
attribute = getattr(self, attribute_name)
if isinstance(attribute, Tensor):
return attribute

Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mypy
nbqa
pytest
pylint
samet-akcay marked this conversation as resolved.
Show resolved Hide resolved
pre-commit>=2.15.0
pre-commit
setuptools
tox>=3.24.3
types-PyYAML
Expand Down
4 changes: 4 additions & 0 deletions tools/hpo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""HPO Tools."""

# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
3 changes: 2 additions & 1 deletion tools/hpo/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
from omegaconf import DictConfig, ListConfig, OmegaConf
from pytorch_lightning import seed_everything
from pytorch_lightning.loggers import WandbLogger
from utils import flatten_hpo_params

import wandb
from anomalib.config import get_configurable_parameters, update_input_size_config
from anomalib.data import get_datamodule
from anomalib.models import get_model
from anomalib.utils.sweep import flatten_sweep_params, set_in_nested_config

from .utils import flatten_hpo_params


class WandbSweep:
"""wandb sweep.
Expand Down
68 changes: 4 additions & 64 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,14 @@
isolated_build = True
skip_missing_interpreters = true
envlist =
black
isort
flake8
pylint
mypy
pydocstyle
pre-commit
pre_merge
nightly

[testenv:black]
[testenv:pre-commit]
basepython = python3
deps = black==22.3.0
commands = black --check --diff anomalib -l 120

[testenv:isort]
basepython = python3
deps = isort==5.10.1
commands = isort --check-only --df anomalib --profile=black

[testenv:flake8]
skip_install = true
basepython = python3
deps =
flake8
mccabe
commands = flake8 anomalib --exclude=anomalib/models/components/freia


[testenv:pylint]
skip_install = true
basepython = python3
deps =
pylint<2.14
-r{toxinidir}/requirements/base.txt
commands = pylint anomalib --rcfile=tox.ini --ignore=anomalib/models/components/freia/

[testenv:mypy]
basepython = python3
passenv = ftp_proxy
HTTP_PROXY
HTTPS_PROXY
deps =
mypy
-r{toxinidir}/requirements/base.txt
commands =
python -m mypy --install-types --non-interactive anomalib --config-file tox.ini
python -m mypy --install-types --non-interactive tools/train.py --config-file tox.ini
python -m mypy --install-types --non-interactive tools/test.py --config-file tox.ini


[testenv:pydocstyle]
basepython = python3
deps =
pydocstyle
commands = pydocstyle anomalib --config=tox.ini

[testenv:notebooks]
basepython = python3
deps =
-r{toxinidir}/requirements/dev.txt
commands =
nbqa black notebooks --nbqa-diff
nbqa isort notebooks --nbqa-diff
nbqa flake8 notebooks
nbqa pylint notebooks --disable=C0103,C0114,C0116,R0801,W0106
nbqa mdformat notebooks --nbqa-md --nbqa-diff

deps = pre-commit
commands = pre-commit run --all-files

[testenv:pre_merge]
basepython = python3
Expand Down Expand Up @@ -121,7 +62,6 @@ disable = duplicate-code,
arguments-differ,
fixme,
import-error,
no-self-use,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
Expand Down