From a42e1cdc326df4ca6762ab5c16166191e0171f3f Mon Sep 17 00:00:00 2001 From: nvollroth <100927440+nvollroth@users.noreply.github.com> Date: Mon, 11 Apr 2022 17:32:04 +0200 Subject: [PATCH 01/20] Added combine Added functionality to merge dictionaries and output to a JSON file --- .../commands/generate_annotations/combine.py | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 package-parser/package_parser/commands/generate_annotations/combine.py diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py new file mode 100644 index 000000000..1793a698b --- /dev/null +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -0,0 +1,64 @@ +import argparse +import json + + +def combine(output, constant_path, unused_path): + + # unused_dict = find_unused(unused_path) + + unused_dict = { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } + } + # constant_dict = find_constant(constant_path) + + constant_dict = { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": True + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla" + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": None + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3" + } + } + + with open(f"{output}\\annotations.json", "w") as file: + json.dump( + { + "unused": unused_dict, + "constant": constant_dict, + }, + file, + indent=2, + ) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(prog='combine') + + parser.add_argument('outputPath', metavar='output-filepath', type=str, + help='paste the location of the output file in here ') + + parser.add_argument('constantPath', metavar='input-filepath', type=str, + help='paste the location of the "constant" file in here ') + + parser.add_argument('unusedPath', metavar='input-filepath', type=str, + help='paste the location of the "unused" file in here ') + + args = parser.parse_args() + + combine(args.outputPath, args.constantPath, args.unusedPath) From a50e0087b1668c95b06a00ba0c084296b4aff04e Mon Sep 17 00:00:00 2001 From: lukarade <84092952+lukarade@users.noreply.github.com> Date: Mon, 11 Apr 2022 19:59:05 +0200 Subject: [PATCH 02/20] Some changes in the combine methode added test for create_file methode --- .../commands/generate_annotations/__init__.py | 0 .../generate_annotations/annotations.json | 29 ++++++++ .../commands/generate_annotations/combine.py | 3 + .../commands/generate_annotations/__init__.py | 0 .../generate_annotations/test_combine.py | 72 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 package-parser/package_parser/commands/generate_annotations/__init__.py create mode 100644 package-parser/package_parser/commands/generate_annotations/annotations.json create mode 100644 package-parser/tests/commands/generate_annotations/__init__.py create mode 100644 package-parser/tests/commands/generate_annotations/test_combine.py diff --git a/package-parser/package_parser/commands/generate_annotations/__init__.py b/package-parser/package_parser/commands/generate_annotations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/package-parser/package_parser/commands/generate_annotations/annotations.json b/package-parser/package_parser/commands/generate_annotations/annotations.json new file mode 100644 index 000000000..1e3f0d181 --- /dev/null +++ b/package-parser/package_parser/commands/generate_annotations/annotations.json @@ -0,0 +1,29 @@ +{ + "unused": { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } + }, + "constant": { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": true + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla" + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": null + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3" + } + } +} \ No newline at end of file diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 1793a698b..f017ee57f 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -35,7 +35,10 @@ def combine(output, constant_path, unused_path): "defaultValue": "3" } } + create_file(output, unused_dict, constant_dict) + +def create_file(output, unused_dict, constant_dict): with open(f"{output}\\annotations.json", "w") as file: json.dump( { diff --git a/package-parser/tests/commands/generate_annotations/__init__.py b/package-parser/tests/commands/generate_annotations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py new file mode 100644 index 000000000..f7dad8857 --- /dev/null +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -0,0 +1,72 @@ +import pytest +import json + +from package_parser.commands.generate_annotations import create_file + +test_unused_dict = { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } +} + +test_constant_dict = { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": True + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla" + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": None + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3" + } +} + +test_combined_dict = { + "unused": { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } + }, + "constant": { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": true + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla" + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": null + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3" + } + } +} + + +@pytest.mark.parametrize("test_unused, test_combined, expected", [(test_unused_dict, test_constant_dict, test_combined_dict),],) +def test_create_annotations(test_unused, test_constant, expected): + create_file("tests/commands/generate_annotations", test_unused, test_constant) + with open("tests/commands/generate_annotations/annotations.json", "r") as file: + eval_dict = json.load(file) + + assert eval_dict == expected From b2cccf563bf4b661e259dc2241a0ea6f1718852c Mon Sep 17 00:00:00 2001 From: nvollroth <100927440+nvollroth@users.noreply.github.com> Date: Mon, 11 Apr 2022 20:31:36 +0200 Subject: [PATCH 03/20] Comments + Tests Added comments to the code and tested the test --- .../commands/generate_annotations/combine.py | 13 +++++++++++++ .../commands/generate_annotations/test_combine.py | 12 ++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index f017ee57f..6f64bd70a 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -1,9 +1,15 @@ import argparse import json +# Funktion zum kombinieren der constant und unused anotations +# @params: +# output : Dateipfad für Output JSON +# constant_path : Dateipfad zur Constant Annotation File +# unused_path : Dateipfad zur Unused Annotation File def combine(output, constant_path, unused_path): + # Platzhalter für echte Funktion # unused_dict = find_unused(unused_path) unused_dict = { @@ -11,6 +17,7 @@ def combine(output, constant_path, unused_path): "target": "sklearn/sklearn.__check_build/raise_build_error" } } + # Platzhalter für echte Funktion # constant_dict = find_constant(constant_path) constant_dict = { @@ -38,6 +45,12 @@ def combine(output, constant_path, unused_path): create_file(output, unused_dict, constant_dict) +# Funktion, die die Dictionarys kombiniert und daraus eine JSON-FILE generiert +# @params: +# output : Dateipfad der JSON-File +# unused_dict : Dictionary der unused annotations +# constant_dict : Dictionary der constant annotations + def create_file(output, unused_dict, constant_dict): with open(f"{output}\\annotations.json", "w") as file: json.dump( diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index f7dad8857..5310d47d5 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -1,7 +1,7 @@ import pytest import json -from package_parser.commands.generate_annotations import create_file +import package_parser.commands.generate_annotations.combine as comb test_unused_dict = { "sklearn/sklearn.__check_build/raise_build_error": { @@ -42,7 +42,7 @@ "sklearn/sklearn._config/config_context/assume_finite": { "target": "sklearn/sklearn._config/config_context/assume_finite", "defaultType": "boolean", - "defaultValue": true + "defaultValue": True }, "sklearn/sklearn._config/config_context/working_memory": { "target": "sklearn/sklearn._config/config_context/working_memory", @@ -52,7 +52,7 @@ "sklearn/sklearn._config/config_context/print_changed_only": { "target": "sklearn/sklearn._config/config_context/print_changed_only", "defaultType": "none", - "defaultValue": null + "defaultValue": None }, "sklearn/sklearn._config/config_context/display": { "target": "sklearn/sklearn._config/config_context/display", @@ -63,10 +63,10 @@ } -@pytest.mark.parametrize("test_unused, test_combined, expected", [(test_unused_dict, test_constant_dict, test_combined_dict),],) +@pytest.mark.parametrize("test_unused, test_constant, expected", [(test_unused_dict, test_constant_dict, test_combined_dict),],) def test_create_annotations(test_unused, test_constant, expected): - create_file("tests/commands/generate_annotations", test_unused, test_constant) - with open("tests/commands/generate_annotations/annotations.json", "r") as file: + comb.create_file(".", test_unused, test_constant) + with open("./annotations.json", "r") as file: eval_dict = json.load(file) assert eval_dict == expected From 59dbb3525ca589e1873e47b36ac73de4c3ecd482 Mon Sep 17 00:00:00 2001 From: nvollroth Date: Mon, 11 Apr 2022 18:42:06 +0000 Subject: [PATCH 04/20] style: apply automatic fixes of linters --- .../generate_annotations/annotations.json | 52 +++++++------- .../commands/generate_annotations/combine.py | 40 +++++++---- .../generate_annotations/test_combine.py | 69 ++++++++++--------- 3 files changed, 90 insertions(+), 71 deletions(-) diff --git a/package-parser/package_parser/commands/generate_annotations/annotations.json b/package-parser/package_parser/commands/generate_annotations/annotations.json index 1e3f0d181..5e53ce458 100644 --- a/package-parser/package_parser/commands/generate_annotations/annotations.json +++ b/package-parser/package_parser/commands/generate_annotations/annotations.json @@ -1,29 +1,29 @@ { - "unused": { - "sklearn/sklearn.__check_build/raise_build_error": { - "target": "sklearn/sklearn.__check_build/raise_build_error" - } - }, - "constant": { - "sklearn/sklearn._config/config_context/assume_finite": { - "target": "sklearn/sklearn._config/config_context/assume_finite", - "defaultType": "boolean", - "defaultValue": true - }, - "sklearn/sklearn._config/config_context/working_memory": { - "target": "sklearn/sklearn._config/config_context/working_memory", - "defaultType": "string", - "defaultValue": "bla" - }, - "sklearn/sklearn._config/config_context/print_changed_only": { - "target": "sklearn/sklearn._config/config_context/print_changed_only", - "defaultType": "none", - "defaultValue": null + "unused": { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } }, - "sklearn/sklearn._config/config_context/display": { - "target": "sklearn/sklearn._config/config_context/display", - "defaultType": "number", - "defaultValue": "3" + "constant": { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": true + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla" + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": null + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3" + } } - } -} \ No newline at end of file +} diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 6f64bd70a..f6c764a14 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -7,6 +7,7 @@ # constant_path : Dateipfad zur Constant Annotation File # unused_path : Dateipfad zur Unused Annotation File + def combine(output, constant_path, unused_path): # Platzhalter für echte Funktion @@ -24,23 +25,23 @@ def combine(output, constant_path, unused_path): "sklearn/sklearn._config/config_context/assume_finite": { "target": "sklearn/sklearn._config/config_context/assume_finite", "defaultType": "boolean", - "defaultValue": True + "defaultValue": True, }, "sklearn/sklearn._config/config_context/working_memory": { "target": "sklearn/sklearn._config/config_context/working_memory", "defaultType": "string", - "defaultValue": "bla" + "defaultValue": "bla", }, "sklearn/sklearn._config/config_context/print_changed_only": { "target": "sklearn/sklearn._config/config_context/print_changed_only", "defaultType": "none", - "defaultValue": None + "defaultValue": None, }, "sklearn/sklearn._config/config_context/display": { "target": "sklearn/sklearn._config/config_context/display", "defaultType": "number", - "defaultValue": "3" - } + "defaultValue": "3", + }, } create_file(output, unused_dict, constant_dict) @@ -51,6 +52,7 @@ def combine(output, constant_path, unused_path): # unused_dict : Dictionary der unused annotations # constant_dict : Dictionary der constant annotations + def create_file(output, unused_dict, constant_dict): with open(f"{output}\\annotations.json", "w") as file: json.dump( @@ -63,17 +65,29 @@ def create_file(output, unused_dict, constant_dict): ) -if __name__ == '__main__': - parser = argparse.ArgumentParser(prog='combine') +if __name__ == "__main__": + parser = argparse.ArgumentParser(prog="combine") - parser.add_argument('outputPath', metavar='output-filepath', type=str, - help='paste the location of the output file in here ') + parser.add_argument( + "outputPath", + metavar="output-filepath", + type=str, + help="paste the location of the output file in here ", + ) - parser.add_argument('constantPath', metavar='input-filepath', type=str, - help='paste the location of the "constant" file in here ') + parser.add_argument( + "constantPath", + metavar="input-filepath", + type=str, + help='paste the location of the "constant" file in here ', + ) - parser.add_argument('unusedPath', metavar='input-filepath', type=str, - help='paste the location of the "unused" file in here ') + parser.add_argument( + "unusedPath", + metavar="input-filepath", + type=str, + help='paste the location of the "unused" file in here ', + ) args = parser.parse_args() diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index 5310d47d5..e79310ba0 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -1,7 +1,7 @@ -import pytest import json import package_parser.commands.generate_annotations.combine as comb +import pytest test_unused_dict = { "sklearn/sklearn.__check_build/raise_build_error": { @@ -13,57 +13,62 @@ "sklearn/sklearn._config/config_context/assume_finite": { "target": "sklearn/sklearn._config/config_context/assume_finite", "defaultType": "boolean", - "defaultValue": True + "defaultValue": True, }, "sklearn/sklearn._config/config_context/working_memory": { "target": "sklearn/sklearn._config/config_context/working_memory", "defaultType": "string", - "defaultValue": "bla" + "defaultValue": "bla", }, "sklearn/sklearn._config/config_context/print_changed_only": { "target": "sklearn/sklearn._config/config_context/print_changed_only", "defaultType": "none", - "defaultValue": None + "defaultValue": None, }, "sklearn/sklearn._config/config_context/display": { "target": "sklearn/sklearn._config/config_context/display", "defaultType": "number", - "defaultValue": "3" - } + "defaultValue": "3", + }, } test_combined_dict = { - "unused": { - "sklearn/sklearn.__check_build/raise_build_error": { - "target": "sklearn/sklearn.__check_build/raise_build_error" - } - }, - "constant": { - "sklearn/sklearn._config/config_context/assume_finite": { - "target": "sklearn/sklearn._config/config_context/assume_finite", - "defaultType": "boolean", - "defaultValue": True - }, - "sklearn/sklearn._config/config_context/working_memory": { - "target": "sklearn/sklearn._config/config_context/working_memory", - "defaultType": "string", - "defaultValue": "bla" + "unused": { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } }, - "sklearn/sklearn._config/config_context/print_changed_only": { - "target": "sklearn/sklearn._config/config_context/print_changed_only", - "defaultType": "none", - "defaultValue": None + "constant": { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": True, + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla", + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": None, + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3", + }, }, - "sklearn/sklearn._config/config_context/display": { - "target": "sklearn/sklearn._config/config_context/display", - "defaultType": "number", - "defaultValue": "3" - } - } } -@pytest.mark.parametrize("test_unused, test_constant, expected", [(test_unused_dict, test_constant_dict, test_combined_dict),],) +@pytest.mark.parametrize( + "test_unused, test_constant, expected", + [ + (test_unused_dict, test_constant_dict, test_combined_dict), + ], +) def test_create_annotations(test_unused, test_constant, expected): comb.create_file(".", test_unused, test_constant) with open("./annotations.json", "r") as file: From f1b10341a098524ef230db4366a3db6b3a8e272e Mon Sep 17 00:00:00 2001 From: nvollroth <100927440+nvollroth@users.noreply.github.com> Date: Mon, 11 Apr 2022 20:50:08 +0200 Subject: [PATCH 05/20] Added JSON test file Erzeugte Test JSON File --- .../generate_annotations/annotations.json | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 package-parser/tests/commands/generate_annotations/annotations.json diff --git a/package-parser/tests/commands/generate_annotations/annotations.json b/package-parser/tests/commands/generate_annotations/annotations.json new file mode 100644 index 000000000..1e3f0d181 --- /dev/null +++ b/package-parser/tests/commands/generate_annotations/annotations.json @@ -0,0 +1,29 @@ +{ + "unused": { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } + }, + "constant": { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": true + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla" + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": null + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3" + } + } +} \ No newline at end of file From 81681cd43d2726c6afe344788fbe5f5a7b4e1d7d Mon Sep 17 00:00:00 2001 From: nvollroth Date: Mon, 11 Apr 2022 18:54:39 +0000 Subject: [PATCH 06/20] style: apply automatic fixes of linters --- .../generate_annotations/annotations.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/package-parser/tests/commands/generate_annotations/annotations.json b/package-parser/tests/commands/generate_annotations/annotations.json index 1e3f0d181..5e53ce458 100644 --- a/package-parser/tests/commands/generate_annotations/annotations.json +++ b/package-parser/tests/commands/generate_annotations/annotations.json @@ -1,29 +1,29 @@ { - "unused": { - "sklearn/sklearn.__check_build/raise_build_error": { - "target": "sklearn/sklearn.__check_build/raise_build_error" - } - }, - "constant": { - "sklearn/sklearn._config/config_context/assume_finite": { - "target": "sklearn/sklearn._config/config_context/assume_finite", - "defaultType": "boolean", - "defaultValue": true - }, - "sklearn/sklearn._config/config_context/working_memory": { - "target": "sklearn/sklearn._config/config_context/working_memory", - "defaultType": "string", - "defaultValue": "bla" - }, - "sklearn/sklearn._config/config_context/print_changed_only": { - "target": "sklearn/sklearn._config/config_context/print_changed_only", - "defaultType": "none", - "defaultValue": null + "unused": { + "sklearn/sklearn.__check_build/raise_build_error": { + "target": "sklearn/sklearn.__check_build/raise_build_error" + } }, - "sklearn/sklearn._config/config_context/display": { - "target": "sklearn/sklearn._config/config_context/display", - "defaultType": "number", - "defaultValue": "3" + "constant": { + "sklearn/sklearn._config/config_context/assume_finite": { + "target": "sklearn/sklearn._config/config_context/assume_finite", + "defaultType": "boolean", + "defaultValue": true + }, + "sklearn/sklearn._config/config_context/working_memory": { + "target": "sklearn/sklearn._config/config_context/working_memory", + "defaultType": "string", + "defaultValue": "bla" + }, + "sklearn/sklearn._config/config_context/print_changed_only": { + "target": "sklearn/sklearn._config/config_context/print_changed_only", + "defaultType": "none", + "defaultValue": null + }, + "sklearn/sklearn._config/config_context/display": { + "target": "sklearn/sklearn._config/config_context/display", + "defaultType": "number", + "defaultValue": "3" + } } - } -} \ No newline at end of file +} From 0b35412171fe045351d5dcb8e0ee2cf1511a5b45 Mon Sep 17 00:00:00 2001 From: nvollroth <100927440+nvollroth@users.noreply.github.com> Date: Mon, 11 Apr 2022 21:11:08 +0200 Subject: [PATCH 07/20] Changed directory in test --- .../tests/commands/generate_annotations/test_combine.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index e79310ba0..4dff7e8a7 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -1,4 +1,5 @@ import json +import os import package_parser.commands.generate_annotations.combine as comb import pytest @@ -70,8 +71,8 @@ ], ) def test_create_annotations(test_unused, test_constant, expected): - comb.create_file(".", test_unused, test_constant) - with open("./annotations.json", "r") as file: + comb.create_file(os.getcwd(), test_unused, test_constant) + with open(os.getcwd() + "/annotations.json", "r") as file: eval_dict = json.load(file) assert eval_dict == expected From 9a6ff3b3d3558727409e3ea8cad2ab008deb9642 Mon Sep 17 00:00:00 2001 From: nvollroth <100927440+nvollroth@users.noreply.github.com> Date: Tue, 12 Apr 2022 16:28:16 +0200 Subject: [PATCH 08/20] =?UTF-8?q?Funktionalit=C3=A4t=20extrahiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Funktionalität extrahiert + Test angepasst --- .../commands/generate_annotations/combine.py | 32 ++++++++----------- .../generate_annotations/test_combine.py | 9 ++---- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index f6c764a14..112a347c5 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -1,15 +1,14 @@ import argparse import json -# Funktion zum kombinieren der constant und unused anotations +# Funktion zum kombinieren der constant und unused anotations und zur Erzeugung einer JSON - File # @params: # output : Dateipfad für Output JSON # constant_path : Dateipfad zur Constant Annotation File # unused_path : Dateipfad zur Unused Annotation File -def combine(output, constant_path, unused_path): - +def write_json(output_path, constant_path, unused_path): # Platzhalter für echte Funktion # unused_dict = find_unused(unused_path) @@ -43,26 +42,23 @@ def combine(output, constant_path, unused_path): "defaultValue": "3", }, } - create_file(output, unused_dict, constant_dict) + result_dict = combine_dictionaries(unused_dict, constant_dict) + + with open(f"{output}\\annotations.json", "w") as file: + json.dump(result_dict, file, indent=2,) -# Funktion, die die Dictionarys kombiniert und daraus eine JSON-FILE generiert +# Funktion, die die Dictionarys kombiniert # @params: -# output : Dateipfad der JSON-File # unused_dict : Dictionary der unused annotations # constant_dict : Dictionary der constant annotations - -def create_file(output, unused_dict, constant_dict): - with open(f"{output}\\annotations.json", "w") as file: - json.dump( - { - "unused": unused_dict, - "constant": constant_dict, - }, - file, - indent=2, - ) +def combine_dictionaries(unused_dict, constant_dict): + result_dict = { + "unused": unused_dict, + "constant": constant_dict, + } + return result_dict if __name__ == "__main__": @@ -91,4 +87,4 @@ def create_file(output, unused_dict, constant_dict): args = parser.parse_args() - combine(args.outputPath, args.constantPath, args.unusedPath) + write_json(args.outputPath, args.constantPath, args.unusedPath) diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index 4dff7e8a7..6d53d4c1f 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -70,9 +70,6 @@ (test_unused_dict, test_constant_dict, test_combined_dict), ], ) -def test_create_annotations(test_unused, test_constant, expected): - comb.create_file(os.getcwd(), test_unused, test_constant) - with open(os.getcwd() + "/annotations.json", "r") as file: - eval_dict = json.load(file) - - assert eval_dict == expected +def test_combine_dictionaries(test_unused, test_constant, expected): + eval_dict = comb.combine_dictionaries(test_unused, test_constant) + assert eval_dict == expected From cc7a152104d90bae31e223aa3c6e7ac06c91b808 Mon Sep 17 00:00:00 2001 From: nvollroth Date: Tue, 12 Apr 2022 14:31:25 +0000 Subject: [PATCH 09/20] style: apply automatic fixes of linters --- .../commands/generate_annotations/combine.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 112a347c5..006237787 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -45,7 +45,11 @@ def write_json(output_path, constant_path, unused_path): result_dict = combine_dictionaries(unused_dict, constant_dict) with open(f"{output}\\annotations.json", "w") as file: - json.dump(result_dict, file, indent=2,) + json.dump( + result_dict, + file, + indent=2, + ) # Funktion, die die Dictionarys kombiniert @@ -53,6 +57,7 @@ def write_json(output_path, constant_path, unused_path): # unused_dict : Dictionary der unused annotations # constant_dict : Dictionary der constant annotations + def combine_dictionaries(unused_dict, constant_dict): result_dict = { "unused": unused_dict, From d4a09feb730ac4568efb400e469c9229d83b486f Mon Sep 17 00:00:00 2001 From: David Tentser Date: Fri, 15 Apr 2022 13:41:45 +0200 Subject: [PATCH 10/20] output path variable correction in combine file --- .../package_parser/commands/generate_annotations/combine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 006237787..9d388cc09 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -44,7 +44,7 @@ def write_json(output_path, constant_path, unused_path): } result_dict = combine_dictionaries(unused_dict, constant_dict) - with open(f"{output}\\annotations.json", "w") as file: + with open(f"{output_path}\\annotations.json", "w") as file: json.dump( result_dict, file, From 1dbab86f1274f6984213c6e632585e0dfe49a20b Mon Sep 17 00:00:00 2001 From: David Tentser Date: Fri, 15 Apr 2022 14:04:03 +0200 Subject: [PATCH 11/20] Important comment in combine --- .../package_parser/commands/generate_annotations/combine.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 9d388cc09..d13cc8dcf 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -43,7 +43,10 @@ def write_json(output_path, constant_path, unused_path): }, } result_dict = combine_dictionaries(unused_dict, constant_dict) - + ''' + result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction) + Those 2 functions have each to return the different dictionaries, comming soon. + ''' with open(f"{output_path}\\annotations.json", "w") as file: json.dump( result_dict, From 3671dd358d47fb2cc04942a2d1e0a7f80c7ffb26 Mon Sep 17 00:00:00 2001 From: DavidTen1 Date: Fri, 15 Apr 2022 12:07:13 +0000 Subject: [PATCH 12/20] style: apply automatic fixes of linters --- .../package_parser/commands/generate_annotations/combine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index d13cc8dcf..e2607e15d 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -43,10 +43,10 @@ def write_json(output_path, constant_path, unused_path): }, } result_dict = combine_dictionaries(unused_dict, constant_dict) - ''' + """ result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction) Those 2 functions have each to return the different dictionaries, comming soon. - ''' + """ with open(f"{output_path}\\annotations.json", "w") as file: json.dump( result_dict, From dfca7d3a986449841b2b5344a75c64a2302a16c0 Mon Sep 17 00:00:00 2001 From: David Tentser Date: Sat, 16 Apr 2022 14:28:02 +0200 Subject: [PATCH 13/20] Documentation in the combine files --- .../commands/generate_annotations/combine.py | 40 +++++++++++++------ .../generate_annotations/test_combine.py | 7 ++++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index e2607e15d..52b5b013a 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -3,12 +3,21 @@ # Funktion zum kombinieren der constant und unused anotations und zur Erzeugung einer JSON - File # @params: -# output : Dateipfad für Output JSON -# constant_path : Dateipfad zur Constant Annotation File -# unused_path : Dateipfad zur Unused Annotation File +# output : Dateipfad für Output JSON aus beiden Dictionaries +# constant_path : Dateipfad zur Constant Annotation File, die eine Constant Dictionary enthält +# unused_path : Dateipfad zur Unused Annotation File, die eine Unused Dictionary enthält + + def write_json(output_path, constant_path, unused_path): + ''' + Dient zum Mergen von Unused-Dictionary und Constant-Dictionary in ein Json + + :param output_path: Dateipfad für Output-JSON aus beiden Dictionaries(Unused und Constant) + :param constant_path: Dateipfad zur Constant Annotation File, die eine Constant Dictionary enthält + :param unused_path: Dateipfad zur Unused Annotation File, die eine Unused Dictionary enthält + ''' # Platzhalter für echte Funktion # unused_dict = find_unused(unused_path) @@ -43,10 +52,11 @@ def write_json(output_path, constant_path, unused_path): }, } result_dict = combine_dictionaries(unused_dict, constant_dict) - """ - result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction) - Those 2 functions have each to return the different dictionaries, comming soon. - """ + + #result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction) + #als 2 Parameter können die Rückgabewerte der Funktionen, die die jw. gefragten Dictionaries sind + #eingesetzt werden; derzeit in Bearbeitung + with open(f"{output_path}\\annotations.json", "w") as file: json.dump( result_dict, @@ -60,8 +70,12 @@ def write_json(output_path, constant_path, unused_path): # unused_dict : Dictionary der unused annotations # constant_dict : Dictionary der constant annotations - def combine_dictionaries(unused_dict, constant_dict): + ''' + Funktion, die die Dictionaries kombiniert + :param unused_dict : Dictionary der unused annotations + :param constant_dict : Dictionary der constant annotations + ''' result_dict = { "unused": unused_dict, "constant": constant_dict, @@ -78,21 +92,23 @@ def combine_dictionaries(unused_dict, constant_dict): type=str, help="paste the location of the output file in here ", ) - + # Argument 1: outputPath parser.add_argument( "constantPath", metavar="input-filepath", type=str, help='paste the location of the "constant" file in here ', ) - + # Argument 2: inputPath(Pfad einer Constant-Datei) parser.add_argument( "unusedPath", metavar="input-filepath", type=str, help='paste the location of the "unused" file in here ', ) + # Argument 3: inputPath(Pfad einer Unused-Datei) + args = parser.parse_args() #Argumente werden auf Nutzen als Parameter vorbereitet + write_json(args.outputPath, args.constantPath, args.unusedPath) - args = parser.parse_args() + #Erzeuge kombinierte JSON-Datei jw. aus der Constant- und der Unused-Dictionary - write_json(args.outputPath, args.constantPath, args.unusedPath) diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index 6d53d4c1f..616a97a89 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -71,5 +71,12 @@ ], ) def test_combine_dictionaries(test_unused, test_constant, expected): + ''' + Funktion, die feststellt ob die kombinierte JSON-Datei gleich der gefragten JSON-Datei ist oder nicht + :param test_unused: Unused Dictionary als Parameter + :param test_constant: Constant Dictionary als Parameter + :param expected: gemergte JSON-Datei aus den 2 Dictionaries, die entsteht + ''' + eval_dict = comb.combine_dictionaries(test_unused, test_constant) assert eval_dict == expected From d0d17e4e508345b5b74ec4cffad776d8055c92bd Mon Sep 17 00:00:00 2001 From: DavidTen1 Date: Sat, 16 Apr 2022 12:31:21 +0000 Subject: [PATCH 14/20] style: apply automatic fixes of linters --- .../commands/generate_annotations/combine.py | 22 +++++++++---------- .../generate_annotations/test_combine.py | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 52b5b013a..9ec41ada8 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -8,16 +8,14 @@ # unused_path : Dateipfad zur Unused Annotation File, die eine Unused Dictionary enthält - - def write_json(output_path, constant_path, unused_path): - ''' + """ Dient zum Mergen von Unused-Dictionary und Constant-Dictionary in ein Json :param output_path: Dateipfad für Output-JSON aus beiden Dictionaries(Unused und Constant) :param constant_path: Dateipfad zur Constant Annotation File, die eine Constant Dictionary enthält :param unused_path: Dateipfad zur Unused Annotation File, die eine Unused Dictionary enthält - ''' + """ # Platzhalter für echte Funktion # unused_dict = find_unused(unused_path) @@ -53,9 +51,9 @@ def write_json(output_path, constant_path, unused_path): } result_dict = combine_dictionaries(unused_dict, constant_dict) - #result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction) - #als 2 Parameter können die Rückgabewerte der Funktionen, die die jw. gefragten Dictionaries sind - #eingesetzt werden; derzeit in Bearbeitung + # result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction) + # als 2 Parameter können die Rückgabewerte der Funktionen, die die jw. gefragten Dictionaries sind + # eingesetzt werden; derzeit in Bearbeitung with open(f"{output_path}\\annotations.json", "w") as file: json.dump( @@ -70,12 +68,13 @@ def write_json(output_path, constant_path, unused_path): # unused_dict : Dictionary der unused annotations # constant_dict : Dictionary der constant annotations + def combine_dictionaries(unused_dict, constant_dict): - ''' + """ Funktion, die die Dictionaries kombiniert :param unused_dict : Dictionary der unused annotations :param constant_dict : Dictionary der constant annotations - ''' + """ result_dict = { "unused": unused_dict, "constant": constant_dict, @@ -107,8 +106,7 @@ def combine_dictionaries(unused_dict, constant_dict): help='paste the location of the "unused" file in here ', ) # Argument 3: inputPath(Pfad einer Unused-Datei) - args = parser.parse_args() #Argumente werden auf Nutzen als Parameter vorbereitet + args = parser.parse_args() # Argumente werden auf Nutzen als Parameter vorbereitet write_json(args.outputPath, args.constantPath, args.unusedPath) - #Erzeuge kombinierte JSON-Datei jw. aus der Constant- und der Unused-Dictionary - + # Erzeuge kombinierte JSON-Datei jw. aus der Constant- und der Unused-Dictionary diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index 616a97a89..2236fe2d5 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -71,12 +71,12 @@ ], ) def test_combine_dictionaries(test_unused, test_constant, expected): - ''' + """ Funktion, die feststellt ob die kombinierte JSON-Datei gleich der gefragten JSON-Datei ist oder nicht :param test_unused: Unused Dictionary als Parameter :param test_constant: Constant Dictionary als Parameter :param expected: gemergte JSON-Datei aus den 2 Dictionaries, die entsteht - ''' + """ eval_dict = comb.combine_dictionaries(test_unused, test_constant) assert eval_dict == expected From 109905a7c5b2adb82445ddfce1ca50da890db82e Mon Sep 17 00:00:00 2001 From: nvollroth <100927440+nvollroth@users.noreply.github.com> Date: Tue, 19 Apr 2022 12:53:09 +0200 Subject: [PATCH 15/20] =?UTF-8?q?Datei=20gel=C3=B6scht=20+=20Kommentare=20?= =?UTF-8?q?angepasst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die Datei annotations.json wurde gelöscht und Kommentare in combine.py wurden angepasst --- .../generate_annotations/annotations.json | 29 ------------------- .../commands/generate_annotations/combine.py | 23 +++++++-------- 2 files changed, 10 insertions(+), 42 deletions(-) delete mode 100644 package-parser/package_parser/commands/generate_annotations/annotations.json diff --git a/package-parser/package_parser/commands/generate_annotations/annotations.json b/package-parser/package_parser/commands/generate_annotations/annotations.json deleted file mode 100644 index 5e53ce458..000000000 --- a/package-parser/package_parser/commands/generate_annotations/annotations.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "unused": { - "sklearn/sklearn.__check_build/raise_build_error": { - "target": "sklearn/sklearn.__check_build/raise_build_error" - } - }, - "constant": { - "sklearn/sklearn._config/config_context/assume_finite": { - "target": "sklearn/sklearn._config/config_context/assume_finite", - "defaultType": "boolean", - "defaultValue": true - }, - "sklearn/sklearn._config/config_context/working_memory": { - "target": "sklearn/sklearn._config/config_context/working_memory", - "defaultType": "string", - "defaultValue": "bla" - }, - "sklearn/sklearn._config/config_context/print_changed_only": { - "target": "sklearn/sklearn._config/config_context/print_changed_only", - "defaultType": "none", - "defaultValue": null - }, - "sklearn/sklearn._config/config_context/display": { - "target": "sklearn/sklearn._config/config_context/display", - "defaultType": "number", - "defaultValue": "3" - } - } -} diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 9ec41ada8..531a2aaae 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -1,16 +1,14 @@ import argparse import json +import os + -# Funktion zum kombinieren der constant und unused anotations und zur Erzeugung einer JSON - File -# @params: -# output : Dateipfad für Output JSON aus beiden Dictionaries -# constant_path : Dateipfad zur Constant Annotation File, die eine Constant Dictionary enthält -# unused_path : Dateipfad zur Unused Annotation File, die eine Unused Dictionary enthält def write_json(output_path, constant_path, unused_path): """ - Dient zum Mergen von Unused-Dictionary und Constant-Dictionary in ein Json + Dient zum Mergen von Unused-Dictionary und Constant-Dictionary und anschließende Erzeugen einer JSON - File, + die das erzeugte Dictionary beinhaltet. :param output_path: Dateipfad für Output-JSON aus beiden Dictionaries(Unused und Constant) :param constant_path: Dateipfad zur Constant Annotation File, die eine Constant Dictionary enthält @@ -55,7 +53,8 @@ def write_json(output_path, constant_path, unused_path): # als 2 Parameter können die Rückgabewerte der Funktionen, die die jw. gefragten Dictionaries sind # eingesetzt werden; derzeit in Bearbeitung - with open(f"{output_path}\\annotations.json", "w") as file: + with open(os.path.join(output_path, "annotations.json"), "w") as file: + #with open(f"{output_path}\\annotations.json", "w") as file: json.dump( result_dict, file, @@ -63,18 +62,16 @@ def write_json(output_path, constant_path, unused_path): ) -# Funktion, die die Dictionarys kombiniert -# @params: -# unused_dict : Dictionary der unused annotations -# constant_dict : Dictionary der constant annotations def combine_dictionaries(unused_dict, constant_dict): """ - Funktion, die die Dictionaries kombiniert - :param unused_dict : Dictionary der unused annotations + Funktion, die die Dictionaries kombiniert + :param unused_dict : Dictionary der unused annotations :param constant_dict : Dictionary der constant annotations + :return result_dict : Kombiniertes Dictionary """ + result_dict = { "unused": unused_dict, "constant": constant_dict, From 07a658bab0020a6b6661d04194477842c93781fc Mon Sep 17 00:00:00 2001 From: nvollroth Date: Tue, 19 Apr 2022 10:56:34 +0000 Subject: [PATCH 16/20] style: apply automatic fixes of linters --- .../package_parser/commands/generate_annotations/combine.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/combine.py index 531a2aaae..19cb06ecc 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/combine.py @@ -3,8 +3,6 @@ import os - - def write_json(output_path, constant_path, unused_path): """ Dient zum Mergen von Unused-Dictionary und Constant-Dictionary und anschließende Erzeugen einer JSON - File, @@ -54,7 +52,7 @@ def write_json(output_path, constant_path, unused_path): # eingesetzt werden; derzeit in Bearbeitung with open(os.path.join(output_path, "annotations.json"), "w") as file: - #with open(f"{output_path}\\annotations.json", "w") as file: + # with open(f"{output_path}\\annotations.json", "w") as file: json.dump( result_dict, file, @@ -62,8 +60,6 @@ def write_json(output_path, constant_path, unused_path): ) - - def combine_dictionaries(unused_dict, constant_dict): """ Funktion, die die Dictionaries kombiniert From 6b5a74d0fa1ecebf4519143eb728c46e88fd5f32 Mon Sep 17 00:00:00 2001 From: lukarade <84092952+lukarade@users.noreply.github.com> Date: Wed, 20 Apr 2022 18:21:27 +0200 Subject: [PATCH 17/20] =?UTF-8?q?Typisierung=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Typisierung hinzugefügt, Schnittstelle über __init__ definiert, Kommentare bearbeitet Co-Authored-By: nvollroth <100927440+nvollroth@users.noreply.github.com> --- .../commands/generate_annotations/__init__.py | 1 + .../{combine.py => _combine.py} | 23 ++++++++----------- .../generate_annotations/test_combine.py | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) rename package-parser/package_parser/commands/generate_annotations/{combine.py => _combine.py} (84%) diff --git a/package-parser/package_parser/commands/generate_annotations/__init__.py b/package-parser/package_parser/commands/generate_annotations/__init__.py index e69de29bb..77a33f97b 100644 --- a/package-parser/package_parser/commands/generate_annotations/__init__.py +++ b/package-parser/package_parser/commands/generate_annotations/__init__.py @@ -0,0 +1 @@ +from ._combine import write_json diff --git a/package-parser/package_parser/commands/generate_annotations/combine.py b/package-parser/package_parser/commands/generate_annotations/_combine.py similarity index 84% rename from package-parser/package_parser/commands/generate_annotations/combine.py rename to package-parser/package_parser/commands/generate_annotations/_combine.py index 19cb06ecc..c07b0b105 100644 --- a/package-parser/package_parser/commands/generate_annotations/combine.py +++ b/package-parser/package_parser/commands/generate_annotations/_combine.py @@ -3,7 +3,7 @@ import os -def write_json(output_path, constant_path, unused_path): +def write_json(output_path: str, constant_path: str, unused_path: str) -> None: """ Dient zum Mergen von Unused-Dictionary und Constant-Dictionary und anschließende Erzeugen einer JSON - File, die das erzeugte Dictionary beinhaltet. @@ -15,6 +15,7 @@ def write_json(output_path, constant_path, unused_path): # Platzhalter für echte Funktion # unused_dict = find_unused(unused_path) + # entfernen, wenn Funktion aus Issue 433 fertig unused_dict = { "sklearn/sklearn.__check_build/raise_build_error": { "target": "sklearn/sklearn.__check_build/raise_build_error" @@ -23,6 +24,7 @@ def write_json(output_path, constant_path, unused_path): # Platzhalter für echte Funktion # constant_dict = find_constant(constant_path) + # entfernen, wenn Funktion aus Issue 434 fertig constant_dict = { "sklearn/sklearn._config/config_context/assume_finite": { "target": "sklearn/sklearn._config/config_context/assume_finite", @@ -45,14 +47,9 @@ def write_json(output_path, constant_path, unused_path): "defaultValue": "3", }, } - result_dict = combine_dictionaries(unused_dict, constant_dict) - - # result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction) - # als 2 Parameter können die Rückgabewerte der Funktionen, die die jw. gefragten Dictionaries sind - # eingesetzt werden; derzeit in Bearbeitung + result_dict = __combine_dictionaries(unused_dict, constant_dict) with open(os.path.join(output_path, "annotations.json"), "w") as file: - # with open(f"{output_path}\\annotations.json", "w") as file: json.dump( result_dict, file, @@ -60,7 +57,7 @@ def write_json(output_path, constant_path, unused_path): ) -def combine_dictionaries(unused_dict, constant_dict): +def __combine_dictionaries(unused_dict: dict, constant_dict: dict) -> dict: """ Funktion, die die Dictionaries kombiniert :param unused_dict : Dictionary der unused annotations @@ -75,31 +72,31 @@ def combine_dictionaries(unused_dict, constant_dict): return result_dict +# sollte, sobald final eingebunden wird entfernt werden, da es nicht weiter benötigt wird, dient zZ. nur zur Anschauung if __name__ == "__main__": parser = argparse.ArgumentParser(prog="combine") + # Argument 1: outputPath parser.add_argument( "outputPath", metavar="output-filepath", type=str, help="paste the location of the output file in here ", ) - # Argument 1: outputPath + # Argument 2: inputPath(Pfad einer Constant-Datei) parser.add_argument( "constantPath", metavar="input-filepath", type=str, help='paste the location of the "constant" file in here ', ) - # Argument 2: inputPath(Pfad einer Constant-Datei) + # Argument 3: inputPath(Pfad einer Unused-Datei) parser.add_argument( "unusedPath", metavar="input-filepath", type=str, help='paste the location of the "unused" file in here ', ) - # Argument 3: inputPath(Pfad einer Unused-Datei) + # Erzeuge kombinierte JSON-Datei jeweils aus der Constant- und der Unused-Dictionary args = parser.parse_args() # Argumente werden auf Nutzen als Parameter vorbereitet write_json(args.outputPath, args.constantPath, args.unusedPath) - - # Erzeuge kombinierte JSON-Datei jw. aus der Constant- und der Unused-Dictionary diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index 2236fe2d5..52f38b24d 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -1,7 +1,7 @@ import json import os -import package_parser.commands.generate_annotations.combine as comb +import package_parser.commands.generate_annotations as comb import pytest test_unused_dict = { @@ -78,5 +78,5 @@ def test_combine_dictionaries(test_unused, test_constant, expected): :param expected: gemergte JSON-Datei aus den 2 Dictionaries, die entsteht """ - eval_dict = comb.combine_dictionaries(test_unused, test_constant) + eval_dict = comb.__combine_dictionaries(test_unused, test_constant) assert eval_dict == expected From 662685f6164b6a293df12a6b15b52a22285b526d Mon Sep 17 00:00:00 2001 From: lukarade Date: Wed, 20 Apr 2022 16:25:05 +0000 Subject: [PATCH 18/20] style: apply automatic fixes of linters --- .../package_parser/commands/generate_annotations/_combine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-parser/package_parser/commands/generate_annotations/_combine.py b/package-parser/package_parser/commands/generate_annotations/_combine.py index c07b0b105..cdc40e5b1 100644 --- a/package-parser/package_parser/commands/generate_annotations/_combine.py +++ b/package-parser/package_parser/commands/generate_annotations/_combine.py @@ -3,7 +3,7 @@ import os -def write_json(output_path: str, constant_path: str, unused_path: str) -> None: +def write_json(output_path: str, constant_path: str, unused_path: str) -> None: """ Dient zum Mergen von Unused-Dictionary und Constant-Dictionary und anschließende Erzeugen einer JSON - File, die das erzeugte Dictionary beinhaltet. From 254fa1515baade7de840d46a2cd8158006364366 Mon Sep 17 00:00:00 2001 From: lukarade <84092952+lukarade@users.noreply.github.com> Date: Wed, 20 Apr 2022 18:27:02 +0200 Subject: [PATCH 19/20] Test import korrigiert Test import korrigiert Co-Authored-By: nvollroth <100927440+nvollroth@users.noreply.github.com> --- .../tests/commands/generate_annotations/test_combine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-parser/tests/commands/generate_annotations/test_combine.py b/package-parser/tests/commands/generate_annotations/test_combine.py index 52f38b24d..45c901b0f 100644 --- a/package-parser/tests/commands/generate_annotations/test_combine.py +++ b/package-parser/tests/commands/generate_annotations/test_combine.py @@ -1,7 +1,7 @@ import json import os -import package_parser.commands.generate_annotations as comb +import package_parser.commands.generate_annotations._combine as comb import pytest test_unused_dict = { From 974923fe43972617b3b20cdb011a152ecf2ff0bc Mon Sep 17 00:00:00 2001 From: GideonKoenig Date: Thu, 21 Apr 2022 12:32:33 +0000 Subject: [PATCH 20/20] style: apply automatic fixes of linters --- .../package_parser/commands/generate_annotations/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-parser/package_parser/commands/generate_annotations/__init__.py b/package-parser/package_parser/commands/generate_annotations/__init__.py index a47f406fc..01f2fc13b 100644 --- a/package-parser/package_parser/commands/generate_annotations/__init__.py +++ b/package-parser/package_parser/commands/generate_annotations/__init__.py @@ -1,2 +1,2 @@ from ._combine import write_json -from ._generate_annotations import generate_annotations \ No newline at end of file +from ._generate_annotations import generate_annotations