IlyaGusev/rulm

View on GitHub
self_instruct/src/train.py

Summary

Maintainability
B
6 hrs
Test Coverage

Function train has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def train(
    config_file: str,
    train_file: str,
    val_file: str,
    output_dir: str,
Severity: Minor
Found in self_instruct/src/train.py - About 2 hrs to fix

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

    def train(
        config_file: str,
        train_file: str,
        val_file: str,
        output_dir: str,
    Severity: Minor
    Found in self_instruct/src/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 train has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def train(
    Severity: Major
    Found in self_instruct/src/train.py - About 1 hr to fix

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

          def _save_checkpoint(self, model, trial, metrics=None):
              print("Running custom _save_checkpoint")
              checkpoint_folder = f"{PREFIX_CHECKPOINT_DIR}-{self.state.global_step}"
              run_dir = self._get_output_dir(trial=trial)
              output_dir = os.path.join(run_dir, checkpoint_folder)
      Severity: Minor
      Found in self_instruct/src/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 custom_prepare_model_for_int8_training has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def custom_prepare_model_for_int8_training(
          model,
          output_embedding_layer_name="lm_head",
          layer_norm_names=["layer_norm"]
      ):
      Severity: Minor
      Found in self_instruct/src/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

      There are no issues that match your filters.

      Category
      Status