Skip to content

Commit

Permalink
Resolve some flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sungmanc committed Dec 29, 2022
1 parent 2b77d44 commit 6e86819
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
name: "flake8"
files: '^(otx|tests)/.*\.py'
args: ["--config", ".flake8", "--max-complexity", "20"]
exclude: "^(.*/protobuf|tests/ote_cli)"
exclude: "^(.*/protobuf|tests/ote_cli)|otx/mpa|otx/recipes"

# yaml formatting
- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
1 change: 0 additions & 1 deletion otx/mpa/cls/explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import torch
from mmcls.datasets import build_dataloader, build_dataset
from mmcls.models import build_classifier
from mmcv.parallel import MMDataParallel
from mmcv.runner import load_checkpoint, wrap_fp16_model

from otx.mpa.cls.stage import ClsStage
Expand Down
2 changes: 1 addition & 1 deletion otx/mpa/cls/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.onnx
from mmcls.datasets.pipelines import Compose
from mmcls.models import build_classifier
from mmcv.runner import load_checkpoint, wrap_fp16_model
from mmcv.runner import load_checkpoint

from otx.mpa.registry import STAGES
from otx.mpa.utils import mo_wrapper
Expand Down
1 change: 1 addition & 0 deletions otx/mpa/cls/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def configure_model(cfg, training, **kwargs):

# checking task incremental model configurations

# noqa: C901
@staticmethod
def configure_task(cfg, training, model_meta=None, **kwargs):
"""Configure for Task Adaptation Task"""
Expand Down
1 change: 1 addition & 0 deletions otx/mpa/cls/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

@STAGES.register_module()
class ClsTrainer(ClsStage):
# noqa: C901
def run(self, model_cfg, model_ckpt, data_cfg, **kwargs):
"""Run training stage"""
self._init_logger()
Expand Down
1 change: 1 addition & 0 deletions otx/mpa/det/inferrer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def default(self, obj):
print(json_dump)
"""

# noqa: C901
def infer(self, cfg, eval=False, dump_features=False, dump_saliency_map=False):
samples_per_gpu = cfg.data.test.pop("samples_per_gpu", 1)
if samples_per_gpu > 1:
Expand Down
2 changes: 0 additions & 2 deletions otx/mpa/det/semisl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

from . import inferrer, trainer
2 changes: 0 additions & 2 deletions otx/mpa/det/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
from otx.mpa.registry import STAGES
from otx.mpa.utils.logger import get_logger

from .stage import DetectionStage

# TODO[JAEGUK]: Remove import detection_tasks
# from detection_tasks.apis.detection.config_utils import cluster_anchors

Expand Down
1 change: 0 additions & 1 deletion otx/mpa/modules/datasets/seg_incr_voc_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from mmseg.datasets import DATASETS, CustomDataset

from otx.mpa.modules.utils.task_adapt import map_class_names
from otx.mpa.utils import logger


@DATASETS.register_module()
Expand Down
1 change: 0 additions & 1 deletion otx/mpa/modules/hooks/model_ema_v2_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import torch
import torch.nn as nn
from mmcv.parallel import is_module_wrapper
from mmcv.runner import HOOKS, Hook

from otx.mpa.utils.logger import get_logger
Expand Down
3 changes: 2 additions & 1 deletion otx/mpa/modules/ov/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def get_nodes_by_types(self, types: List[str]) -> List[Operation]:

def bfs(
self, node: Operation, reverse: bool = False, depth_limit: Optional[int] = None
) -> Generator[Union[Tuple[Operation, Operation], Tuple[Operation, Tuple[Operation]]], None, None,]:
) -> Generator[Union[Tuple[Operation, Operation], Tuple[Operation, Tuple[Operation]]], None, None]:
if reverse:
for s, t in nx.bfs_edges(self, node, reverse=True, depth_limit=depth_limit):
yield (t, s)
Expand Down Expand Up @@ -406,6 +406,7 @@ def get_nodes_by_type_pattern(self, pattern: List[str], start_node: Optional[Ope
start_nodes = [found[-1] for found in founds]
return founds

# noqa: C901
def _freeze_normalize_nodes(self):
invariant_types = ["Transpose", "Convert"]

Expand Down
2 changes: 0 additions & 2 deletions otx/mpa/modules/ov/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@
# pass
# else:
# from . import mmseg

from .ov_model import OVModel
1 change: 0 additions & 1 deletion otx/mpa/seg/inferrer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
#

import os
import os.path as osp
from contextlib import nullcontext

Expand Down

0 comments on commit 6e86819

Please sign in to comment.