darthdeus/bopt

View on GitHub
bopt/cli/exp.py

Summary

Maintainability
C
1 day
Test Coverage

Function run has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

def run(args) -> None:
    # TODO: acquire in the same with?
    with handle_cd_revertible(args.dir):
        with acquire_lock():
            experiment = Experiment.deserialize()
Severity: Minor
Found in bopt/cli/exp.py - About 5 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

Avoid deeply nested control flow statements.
Open

                    if sample.result is not None:
                        print(sample.result)

Severity: Major
Found in bopt/cli/exp.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if best_res is None or (sample.result and sample.result > best_res):
                                best_res = sample.result
                                best_sample = sample
                        except ValueError:
    Severity: Major
    Found in bopt/cli/exp.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for h, v in best_sample.hyperparam_values.mapping.items():
                              if isinstance(v, float):
                                  v = round(v, 2)
                              run_str += " --{}={}".format(h.name, v)
      
      
      Severity: Major
      Found in bopt/cli/exp.py - About 45 mins to fix

        TODO found
        Open

        # TODO: get rid of psutil?
        Severity: Minor
        Found in bopt/cli/exp.py by fixme

        TODO found
        Open

            # TODO: acquire in the same with?
        Severity: Minor
        Found in bopt/cli/exp.py by fixme

        TODO found
        Open

                            # TODO fix this on osx, shared={mem.shared}"
        Severity: Minor
        Found in bopt/cli/exp.py by fixme

        TODO found
        Open

                                # TODO: cleanup checks
        Severity: Minor
        Found in bopt/cli/exp.py by fixme

        There are no issues that match your filters.

        Category
        Status