toodef/neural-pipeline

View on GitHub

Showing 18 of 300 total issues

File train_config.py has 434 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from abc import ABCMeta, abstractmethod

from torch import Tensor
from torch.optim import Optimizer
from torch.nn import Module
Severity: Minor
Found in neural_pipeline/train_config/train_config.py - About 6 hrs to fix

    Function _update_metrics has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def _update_metrics(self, metrics: [AbstractMetric], metrics_groups: [MetricsGroup]) -> None:
            """
            Update console
    
            :param metrics: metrics
    Severity: Minor
    Found in neural_pipeline/builtin/monitors/tensorboard.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File train.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    The main module for training process
    """
    import json
    import os
    Severity: Minor
    Found in neural_pipeline/train.py - About 2 hrs to fix

      File fsm.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      This module contains all classes, that work with file structure
      
      * :class:`FileStructManager` provide all modules registration
      * :class:`CheckpointsManager` provide checkpoints management
      Severity: Minor
      Found in neural_pipeline/utils/fsm.py - About 2 hrs to fix

        Function train has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def train(self) -> None:
                """
                Run training process
                """
                if len(self._train_config.stages()) < 1:
        Severity: Minor
        Found in neural_pipeline/train.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function load_weights has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_weights(self, weights_file: str = None) -> None:
                """
                Load weight from checkpoint
                """
                if weights_file is not None:
        Severity: Minor
        Found in neural_pipeline/data_processor/model.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function register_dir has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def register_dir(self, obj: FolderRegistrable, check_name_registered: bool = False, check_dir_registered: bool = True) -> None:
                """
                Register directory in file structure
        
                :param obj: object to registration
        Severity: Minor
        Found in neural_pipeline/utils/fsm.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _process_metric has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _process_metric(self, cur_metric, parent_tag: str = None):
                if isinstance(cur_metric, MetricsGroup):
                    for m in cur_metric.metrics():
                        names = self._compile_names(parent_tag, [cur_metric.name(), m.name()])
                        plot = self._cur_plot(names)
        Severity: Minor
        Found in neural_pipeline/builtin/monitors/mpl.py - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _process_metric has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _process_metric(self, cur_metric, parent_tag: str = None) -> None:
                """
                Internal method for processing metrics or metrics groups
        
                :param cur_metric: :class:`AbstractMetric` or :class:`MetricsGroup` object
        Severity: Minor
        Found in neural_pipeline/monitoring.py - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _cur_storage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _cur_storage(self, names: [str]) -> [] or {}:
                """
                Get current substorage by path of names
                :param names: list on names (path to target substorage)
                :return: substorage
        Severity: Minor
        Found in neural_pipeline/monitoring.py - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _save_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _save_state(self, ckpts_manager: CheckpointsManager, best_ckpts_manager: CheckpointsManager or None,
                            cur_best_state: float or None, epoch_idx: int) -> float or None:
                """
                Internal method used for save states after epoch end
        
        
        Severity: Minor
        Found in neural_pipeline/train.py - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, fsm: FileStructManager, is_continue: bool, network_name: str = None):
                super().__init__()
                self.__writer = None
                self.__txt_log_file = None
        
        
        Severity: Minor
        Found in neural_pipeline/builtin/monitors/tensorboard.py - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _save_state has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _save_state(self, ckpts_manager: CheckpointsManager, best_ckpts_manager: CheckpointsManager or None,
        Severity: Minor
        Found in neural_pipeline/train.py - About 35 mins to fix

          Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, train_configs: [ComparableTrainConfig], workdir: str, device: torch.device = None, is_continue: bool = False):
          Severity: Minor
          Found in neural_pipeline/gridsearch_train.py - About 35 mins to fix

            Function train has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def train(self):
                    if os.path.exists(self._workdir) or not os.path.isdir(self._workdir):
                        os.makedirs(self._workdir)
            
                    with open(self.__state_file_path(), 'w') as file:
            Severity: Minor
            Found in neural_pipeline/gridsearch_train.py - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Avoid too many return statements within this function.
            Open

                        return encoder.layer4
            Severity: Major
            Found in neural_pipeline/builtin/models/albunet.py - About 30 mins to fix

              Function update_metrics has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update_metrics(self, metrics: {}) -> None:
                      for metric in metrics['metrics']:
                          self._process_metric(metric)
              
                      for metrics_group in metrics['groups']:
              Severity: Minor
              Found in neural_pipeline/builtin/monitors/mpl.py - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function update_metrics has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update_metrics(self, metrics: {}) -> None:
                      for metric in metrics['metrics']:
                          self._process_metric(metric)
              
                      for metrics_group in metrics['groups']:
              Severity: Minor
              Found in neural_pipeline/monitoring.py - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Severity
              Category
              Status
              Source
              Language