Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

feat: 436 create a json file that integrates the dictionaries from and #438

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a42e1cd
Added combine
nvollroth Apr 11, 2022
a50e008
Some changes in the combine methode
lukarade Apr 11, 2022
b2cccf5
Comments + Tests
nvollroth Apr 11, 2022
59dbb35
style: apply automatic fixes of linters
nvollroth Apr 11, 2022
f1b1034
Added JSON test file
nvollroth Apr 11, 2022
85f11a1
Merge branch '436-create-a-json-file-that-integrates-the-dictionaries…
nvollroth Apr 11, 2022
81681cd
style: apply automatic fixes of linters
nvollroth Apr 11, 2022
0b35412
Changed directory in test
nvollroth Apr 11, 2022
de6bd46
Merge branch '436-create-a-json-file-that-integrates-the-dictionaries…
nvollroth Apr 11, 2022
9a6ff3b
Funktionalität extrahiert
nvollroth Apr 12, 2022
cc7a152
style: apply automatic fixes of linters
nvollroth Apr 12, 2022
d4a09fe
output path variable correction in combine file
Apr 15, 2022
1dbab86
Important comment in combine
Apr 15, 2022
3671dd3
style: apply automatic fixes of linters
DavidTen1 Apr 15, 2022
dfca7d3
Documentation in the combine files
Apr 16, 2022
d0d17e4
style: apply automatic fixes of linters
DavidTen1 Apr 16, 2022
73c4ea2
Merge branch 'main' into 436-create-a-json-file-that-integrates-the-d…
GideonKoenig Apr 17, 2022
109905a
Datei gelöscht + Kommentare angepasst
nvollroth Apr 19, 2022
07a658b
style: apply automatic fixes of linters
nvollroth Apr 19, 2022
6b5a74d
Typisierung hinzugefügt
lukarade Apr 20, 2022
662685f
style: apply automatic fixes of linters
lukarade Apr 20, 2022
254fa15
Test import korrigiert
lukarade Apr 20, 2022
6b5a4f2
Merge branch '436-create-a-json-file-that-integrates-the-dictionaries…
lukarade Apr 20, 2022
956ff32
Merge branch 'main' into 436-create-a-json-file-that-integrates-the-d…
GideonKoenig Apr 21, 2022
974923f
style: apply automatic fixes of linters
GideonKoenig Apr 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
nvollroth marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import argparse
import json

# 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
Aclrian marked this conversation as resolved.
Show resolved Hide resolved


def write_json(output_path, constant_path, unused_path):
# Platzhalter für echte Funktion
# unused_dict = find_unused(unused_path)

unused_dict = {
"sklearn/sklearn.__check_build/raise_build_error": {
"target": "sklearn/sklearn.__check_build/raise_build_error"
}
}
# Platzhalter für echte Funktion
# 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",
},
}
GideonKoenig marked this conversation as resolved.
Show resolved Hide resolved
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
# @params:
# unused_dict : Dictionary der unused annotations
# constant_dict : Dictionary der constant annotations


def combine_dictionaries(unused_dict, constant_dict):
result_dict = {
"unused": unused_dict,
"constant": constant_dict,
}
return result_dict


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()

write_json(args.outputPath, args.constantPath, args.unusedPath)
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import json
import os

import package_parser.commands.generate_annotations.combine as comb
import pytest

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": None,
},
"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),
],
)
def test_combine_dictionaries(test_unused, test_constant, expected):
eval_dict = comb.combine_dictionaries(test_unused, test_constant)
assert eval_dict == expected