toodef/neural-pipeline

View on GitHub
neural_pipeline/gridsearch_train.py

Summary

Maintainability
A
1 hr
Test Coverage

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

    Line too long (88 > 79 characters)
    Open

        def add_init_monitor_clbk(self, init_monitor_clbk: callable) -> 'GridSearchTrainer':
    Severity: Minor
    Found in neural_pipeline/gridsearch_train.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (137 > 79 characters)
    Open

                    cur_state = {'canceled': True, 'params': comparable_train_config.get_params(), 'metric_val': metric_aggregator.get_val()}
    Severity: Minor
    Found in neural_pipeline/gridsearch_train.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (80 > 79 characters)
    Open

                if cur_best_metric is None or cur_best_metric < state['metric_val']:
    Severity: Minor
    Found in neural_pipeline/gridsearch_train.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (84 > 79 characters)
    Open

                    self._process_vals = lambda: self._calc_around_min(int(method[:12]))
    Severity: Minor
    Found in neural_pipeline/gridsearch_train.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (109 > 79 characters)
    Open

                    trainer = Trainer(comparable_train_config.get_train_config(), self._fsm, device=self._device)
    Severity: Minor
    Found in neural_pipeline/gridsearch_train.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (139 > 79 characters)
    Open

                    raise NotImplementedError("Methods for process metric must be 'min' or 'calc_around_N' where N is integer positive number")
    Severity: Minor
    Found in neural_pipeline/gridsearch_train.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (110 > 79 characters)
    Open

                    metric_aggregator = self.MetricValAggregator(comparable_train_config.get_metric_for_compare())
    Severity: Minor
    Found in neural_pipeline/gridsearch_train.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (133 > 79 characters)
    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 by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    There are no issues that match your filters.

    Category
    Status