IlyaGusev/rulm

View on GitHub

Showing 260 of 260 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if tokenizer.eos_token_id in bad_ids:
        candidates = (
            model_config.eos_token_id,
            guessed_eos_token_id,
            tokenizer.bos_token_id
Severity: Major
Found in self_instruct/src/util/dl.py and 1 other location - About 2 hrs to fix
self_instruct/src/util/dl.py on lines 47..55

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 58.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            w.write(json.dumps({
                "title": record.title,
                "text": text,
                "url": record.url,
                "timestamp": int(datetime.timestamp(record.date)),
Severity: Major
Found in data_processing/create_ru_news.py and 1 other location - About 2 hrs to fix
data_processing/create_ru_news.py on lines 112..117

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 57.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function main has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def main(
    output_path,
    news_output_path
):
    output_archive = PlainArchive(output_path)
Severity: Minor
Found in data_processing/save_mc4.py - About 2 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            w.write(json.dumps({
                "title": record.title,
                "text": text,
                "url": record.url,
                "timestamp": int(datetime.timestamp(record.timestamp)),
Severity: Major
Found in data_processing/create_ru_news.py and 1 other location - About 2 hrs to fix
data_processing/create_ru_news.py on lines 177..182

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 57.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File create_stackoverflow.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Based on https://github.com/EleutherAI/stackexchange-dataset/blob/master/pairer.py

import argparse
import os
import re
Severity: Minor
Found in data_processing/create_stackoverflow.py - About 2 hrs to fix

    Function fetch_tagengo has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def fetch_tagengo():
        mapping = {
            "gpt": "bot",
            "human": "user"
        }
    Severity: Minor
    Found in self_instruct/src/data_processing/fetch_tagengo.py - About 2 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

    Function translate_state_dict_key has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def translate_state_dict_key(k):  # noqa: C901
        k = k.replace('base_model.model.', '')
        if k == 'model.embed_tokens.weight':
            return 'tok_embeddings.weight'
        elif k == 'model.norm.weight':
    Severity: Minor
    Found in self_instruct/src/tools/convert_to_native.py - About 2 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 create_chat_set.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import json
    import sys
    import re
    import random
    from itertools import tee
    Severity: Minor
    Found in self_instruct/src/data_processing/create_chat_set.py - About 2 hrs to fix

      Function infer_saiga_vllm has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def infer_saiga_vllm(
          model_name: str,
          input_path: str,
          output_path: str,
          temperature: float = 0.6,
      Severity: Minor
      Found in self_instruct/src/infer_saiga_vllm.py - About 2 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

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

      if __name__ == "__main__":
          parser = argparse.ArgumentParser()
          parser.add_argument("output_path", type=str)
          args = parser.parse_args()
          main(**vars(args))
      Severity: Major
      Found in data_processing/convert_pikabu.py and 2 other locations - About 2 hrs to fix
      data_processing/convert_mc4.py on lines 86..90
      data_processing/hf_to_instruct.py on lines 172..176

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 52.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

      if __name__ == "__main__":
          parser = argparse.ArgumentParser()
          parser.add_argument("output_path", type=str)
          args = parser.parse_args()
          main(**vars(args))
      Severity: Major
      Found in data_processing/convert_mc4.py and 2 other locations - About 2 hrs to fix
      data_processing/convert_pikabu.py on lines 151..155
      data_processing/hf_to_instruct.py on lines 172..176

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 52.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

      if __name__ == '__main__':
          parser = argparse.ArgumentParser()
          parser.add_argument("output_path", type=str)
          args = parser.parse_args()
          main(**vars(args))
      Severity: Major
      Found in data_processing/hf_to_instruct.py and 2 other locations - About 2 hrs to fix
      data_processing/convert_mc4.py on lines 86..90
      data_processing/convert_pikabu.py on lines 151..155

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 52.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function infer has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def infer(
          model_name: str,
          input_path: str,
          output_path: str,
          n_ctx: int = 2000,
      Severity: Minor
      Found in self_instruct/src/infer_saiga_llamacpp.py - About 2 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

      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 main has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def main(train_path, val_path):
            random.seed(42)
        
            instruct_records = []
            for row in tqdm(load_dataset("lksy/ru_instruct_gpt4", split="train")):
        Severity: Minor
        Found in self_instruct/src/data_processing/create_chat_set.py - About 2 hrs to fix

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          def main(output_path):
              with open(output_path, "w") as w:
                  for record in fetch_tagengo():
                      w.write(json.dumps(record, ensure_ascii=False) + "\n")
          Severity: Major
          Found in self_instruct/src/data_processing/fetch_wildchat.py and 1 other location - About 2 hrs to fix
          self_instruct/src/data_processing/fetch_tagengo.py on lines 50..53

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          def main(output_path):
              with open(output_path, "w") as w:
                  for record in fetch_tagengo():
                      w.write(json.dumps(record, ensure_ascii=False) + "\n")
          Severity: Major
          Found in self_instruct/src/data_processing/fetch_tagengo.py and 1 other location - About 2 hrs to fix
          self_instruct/src/data_processing/fetch_wildchat.py on lines 43..46

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          def fetch_tagengo():
              for row in chain(
                  load_dataset("allenai/WildChat", split="train")
              ):
                  language = row["language"]
          Severity: Minor
          Found in self_instruct/src/data_processing/fetch_wildchat.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 parse_section has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_section(self, section):
                  # sectionType
                  # https://github.com/gribuser/fb2/blob/master/FictionBook.xsd#L396
                  title = section.find("./fb:title", NS)
                  title_str = self.parse_content(title) if title is not None else None
          Severity: Minor
          Found in data_processing/parse_fb2.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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          for row in load_dataset("its5Q/habr_qna", split="train"):
              if random.random() < 0.025:
                  seeds.append({
                      "seed": row["title"],
                      "source": "habr_qna"
          Severity: Major
          Found in self_instruct/src/data_processing/fetch_chat_seeds.py and 2 other locations - About 1 hr to fix
          self_instruct/src/data_processing/fetch_chat_seeds.py on lines 16..20
          self_instruct/src/data_processing/fetch_chat_seeds.py on lines 30..34

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language