Skip to content

Commit 5144b19

Browse files
hf-kkleinKonstantin
andauthored
switch module evaluation_results from attrs+marshmallow to pydantic (breaking) (#680)
* switch module `evaluation_results` from attrs+marshmallow to pydantic (breaking) * wip --------- Co-authored-by: Konstantin <[email protected]>
1 parent c8dbe0c commit 5144b19

File tree

8 files changed

+178
-275
lines changed

8 files changed

+178
-275
lines changed
Lines changed: 97 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,124 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"definitions": {
4-
"AhbExpressionEvaluationResultSchema": {
5-
"additionalProperties": false,
6-
"properties": {
7-
"format_constraint_evaluation_result": {
8-
"$ref": "#/definitions/FormatConstraintEvaluationResultSchema",
9-
"type": "object"
10-
},
11-
"requirement_constraint_evaluation_result": {
12-
"$ref": "#/definitions/RequirementConstraintEvaluationResultSchema",
13-
"type": "object"
14-
},
15-
"requirement_indicator": {
16-
"title": "",
17-
"type": "string"
18-
}
19-
},
20-
"type": "object"
21-
},
22-
"FormatConstraintEvaluationResultSchema": {
23-
"additionalProperties": false,
2+
"$defs": {
3+
"FormatConstraintEvaluationResult": {
4+
"description": "A class for the result of the format constraint evaluation.",
245
"properties": {
256
"error_message": {
26-
"title": "error_message",
27-
"type": ["string", "null"]
7+
"anyOf": [
8+
{
9+
"type": "string"
10+
},
11+
{
12+
"type": "null"
13+
}
14+
],
15+
"default": null,
16+
"title": "Error Message"
2817
},
2918
"format_constraints_fulfilled": {
30-
"title": "format_constraints_fulfilled",
19+
"title": "Format Constraints Fulfilled",
3120
"type": "boolean"
3221
}
3322
},
23+
"required": ["format_constraints_fulfilled"],
24+
"title": "FormatConstraintEvaluationResult",
3425
"type": "object"
3526
},
36-
"RequirementConstraintEvaluationResultSchema": {
37-
"additionalProperties": false,
27+
"ModalMark": {
28+
"description": "A modal mark describes if information are obligatory or not. The German term is \"Merkmal\".\nThe modal marks are defined by the EDI Energy group (see edi-energy.de → Dokumente → Allgemeine Festlegungen).\nThe modal mark stands alone or before a condition expression.\nIt can be the start of several requirement indicator expressions in one AHB expression.",
29+
"enum": ["MUSS", "SOLL", "KANN"],
30+
"title": "ModalMark",
31+
"type": "string"
32+
},
33+
"PrefixOperator": {
34+
"description": "Operator which does not function to combine conditions, but as requirement indicator.\nIt stands alone or in front of a condition expression. Please find detailed descriptions of the operators and their\nusage in the \"Allgemeine Festlegungen\".\nNote that with MaKo2022 introced 2022-04-01 the \"O\" and \"U\" prefix operators will be deprecated.\nRefer to the \"Allgemeine Festlegungen\" valid up to 2022-04-01 for deprecated \"O\" and \"U\".",
35+
"enum": ["X", "O", "U"],
36+
"title": "PrefixOperator",
37+
"type": "string"
38+
},
39+
"RequirementConstraintEvaluationResult": {
40+
"description": "A class for the result of the requirement constraint evaluation.",
3841
"properties": {
3942
"format_constraints_expression": {
40-
"title": "format_constraints_expression",
41-
"type": ["string", "null"]
43+
"anyOf": [
44+
{
45+
"type": "string"
46+
},
47+
{
48+
"type": "null"
49+
}
50+
],
51+
"default": null,
52+
"title": "Format Constraints Expression"
4253
},
4354
"hints": {
44-
"title": "hints",
45-
"type": ["string", "null"]
55+
"anyOf": [
56+
{
57+
"type": "string"
58+
},
59+
{
60+
"type": "null"
61+
}
62+
],
63+
"default": null,
64+
"title": "Hints"
4665
},
4766
"requirement_constraints_fulfilled": {
48-
"title": "requirement_constraints_fulfilled",
49-
"type": "boolean"
67+
"anyOf": [
68+
{
69+
"type": "boolean"
70+
},
71+
{
72+
"type": "null"
73+
}
74+
],
75+
"title": "Requirement Constraints Fulfilled"
5076
},
5177
"requirement_is_conditional": {
52-
"title": "requirement_is_conditional",
53-
"type": "boolean"
78+
"anyOf": [
79+
{
80+
"type": "boolean"
81+
},
82+
{
83+
"type": "null"
84+
}
85+
],
86+
"title": "Requirement Is Conditional"
5487
}
5588
},
89+
"required": [
90+
"requirement_constraints_fulfilled",
91+
"requirement_is_conditional"
92+
],
93+
"title": "RequirementConstraintEvaluationResult",
5694
"type": "object"
5795
}
5896
},
97+
"description": "A class for the result of an ahb expression evaluation.",
5998
"properties": {
60-
"$ref": "#/definitions/AhbExpressionEvaluationResultSchema/properties"
99+
"format_constraint_evaluation_result": {
100+
"$ref": "#/$defs/FormatConstraintEvaluationResult"
101+
},
102+
"requirement_constraint_evaluation_result": {
103+
"$ref": "#/$defs/RequirementConstraintEvaluationResult"
104+
},
105+
"requirement_indicator": {
106+
"anyOf": [
107+
{
108+
"$ref": "#/$defs/PrefixOperator"
109+
},
110+
{
111+
"$ref": "#/$defs/ModalMark"
112+
}
113+
],
114+
"title": "Requirement Indicator"
115+
}
61116
},
62-
"title": "AhbExpressionEvaluationResultSchema",
117+
"required": [
118+
"requirement_indicator",
119+
"requirement_constraint_evaluation_result",
120+
"format_constraint_evaluation_result"
121+
],
122+
"title": "AhbExpressionEvaluationResult",
63123
"type": "object"
64124
}
Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,24 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"definitions": {
4-
"FormatConstraintEvaluationResultSchema": {
5-
"additionalProperties": false,
6-
"properties": {
7-
"error_message": {
8-
"title": "error_message",
9-
"type": ["string", "null"]
2+
"description": "A class for the result of the format constraint evaluation.",
3+
"properties": {
4+
"error_message": {
5+
"anyOf": [
6+
{
7+
"type": "string"
108
},
11-
"format_constraints_fulfilled": {
12-
"title": "format_constraints_fulfilled",
13-
"type": "boolean"
9+
{
10+
"type": "null"
1411
}
15-
},
16-
"type": "object"
12+
],
13+
"default": null,
14+
"title": "Error Message"
1715
},
18-
"RequirementConstraintEvaluationResultSchema": {
19-
"additionalProperties": false,
20-
"properties": {
21-
"format_constraints_expression": {
22-
"title": "format_constraints_expression",
23-
"type": ["string", "null"]
24-
},
25-
"hints": {
26-
"title": "hints",
27-
"type": ["string", "null"]
28-
},
29-
"requirement_constraints_fulfilled": {
30-
"title": "requirement_constraints_fulfilled",
31-
"type": "boolean"
32-
},
33-
"requirement_is_conditional": {
34-
"title": "requirement_is_conditional",
35-
"type": "boolean"
36-
}
37-
},
38-
"type": "object"
16+
"format_constraints_fulfilled": {
17+
"title": "Format Constraints Fulfilled",
18+
"type": "boolean"
3919
}
4020
},
41-
"properties": {
42-
"$ref": "#/definitions/FormatConstraintEvaluationResultSchema/properties"
43-
},
44-
"title": "FormatConstraintEvaluationResultSchema",
21+
"required": ["format_constraints_fulfilled"],
22+
"title": "FormatConstraintEvaluationResult",
4523
"type": "object"
4624
}
Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,57 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"definitions": {
4-
"RequirementConstraintEvaluationResultSchema": {
5-
"additionalProperties": false,
6-
"properties": {
7-
"format_constraints_expression": {
8-
"title": "format_constraints_expression",
9-
"type": ["string", "null"]
2+
"description": "A class for the result of the requirement constraint evaluation.",
3+
"properties": {
4+
"format_constraints_expression": {
5+
"anyOf": [
6+
{
7+
"type": "string"
108
},
11-
"hints": {
12-
"title": "hints",
13-
"type": ["string", "null"]
9+
{
10+
"type": "null"
11+
}
12+
],
13+
"default": null,
14+
"title": "Format Constraints Expression"
15+
},
16+
"hints": {
17+
"anyOf": [
18+
{
19+
"type": "string"
1420
},
15-
"requirement_constraints_fulfilled": {
16-
"title": "requirement_constraints_fulfilled",
21+
{
22+
"type": "null"
23+
}
24+
],
25+
"default": null,
26+
"title": "Hints"
27+
},
28+
"requirement_constraints_fulfilled": {
29+
"anyOf": [
30+
{
1731
"type": "boolean"
1832
},
19-
"requirement_is_conditional": {
20-
"title": "requirement_is_conditional",
33+
{
34+
"type": "null"
35+
}
36+
],
37+
"title": "Requirement Constraints Fulfilled"
38+
},
39+
"requirement_is_conditional": {
40+
"anyOf": [
41+
{
2142
"type": "boolean"
43+
},
44+
{
45+
"type": "null"
2246
}
23-
},
24-
"type": "object"
47+
],
48+
"title": "Requirement Is Conditional"
2549
}
2650
},
27-
"properties": {
28-
"$ref": "#/definitions/RequirementConstraintEvaluationResultSchema/properties"
29-
},
30-
"title": "RequirementConstraintEvaluationResultSchema",
51+
"required": [
52+
"requirement_constraints_fulfilled",
53+
"requirement_is_conditional"
54+
],
55+
"title": "RequirementConstraintEvaluationResult",
3156
"type": "object"
3257
}

json_schemas/TokenSchema.json

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"definitions": {
4-
"AhbExpressionEvaluationResultSchema": {
5-
"additionalProperties": false,
6-
"properties": {
7-
"format_constraint_evaluation_result": {
8-
"$ref": "#/definitions/FormatConstraintEvaluationResultSchema",
9-
"type": "object"
10-
},
11-
"requirement_constraint_evaluation_result": {
12-
"$ref": "#/definitions/RequirementConstraintEvaluationResultSchema",
13-
"type": "object"
14-
},
15-
"requirement_indicator": {
16-
"title": "",
17-
"type": "string"
18-
}
19-
},
20-
"type": "object"
21-
},
22-
"FormatConstraintEvaluationResultSchema": {
23-
"additionalProperties": false,
24-
"properties": {
25-
"error_message": {
26-
"title": "error_message",
27-
"type": ["string", "null"]
28-
},
29-
"format_constraints_fulfilled": {
30-
"title": "format_constraints_fulfilled",
31-
"type": "boolean"
32-
}
33-
},
34-
"type": "object"
35-
},
36-
"RequirementConstraintEvaluationResultSchema": {
37-
"additionalProperties": false,
38-
"properties": {
39-
"format_constraints_expression": {
40-
"title": "format_constraints_expression",
41-
"type": ["string", "null"]
42-
},
43-
"hints": {
44-
"title": "hints",
45-
"type": ["string", "null"]
46-
},
47-
"requirement_constraints_fulfilled": {
48-
"title": "requirement_constraints_fulfilled",
49-
"type": "boolean"
50-
},
51-
"requirement_is_conditional": {
52-
"title": "requirement_is_conditional",
53-
"type": "boolean"
54-
}
55-
},
56-
"type": "object"
57-
},
584
"TokenSchema": {
595
"additionalProperties": false,
606
"properties": {

json_schemas/generate_json_schemas.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
from ahbicht.models.condition_nodes import EvaluatedFormatConstraint
1717
from ahbicht.models.content_evaluation_result import ContentEvaluationResult
1818
from ahbicht.models.evaluation_results import (
19-
AhbExpressionEvaluationResultSchema,
20-
FormatConstraintEvaluationResultSchema,
21-
RequirementConstraintEvaluationResultSchema,
19+
AhbExpressionEvaluationResult,
20+
FormatConstraintEvaluationResult,
21+
RequirementConstraintEvaluationResult,
2222
)
2323
from ahbicht.models.mapping_results import ConditionKeyConditionTextMapping, PackageKeyConditionExpressionMapping
2424

2525
schema_types: list[Type[Schema] | Type[BaseModel]] = [
26-
RequirementConstraintEvaluationResultSchema, # marshmallow
27-
FormatConstraintEvaluationResultSchema, # marshmallow
26+
RequirementConstraintEvaluationResult, # pydantic
27+
FormatConstraintEvaluationResult, # pydantic
2828
EvaluatedFormatConstraint, # pydantic
29-
AhbExpressionEvaluationResultSchema, # marshmallow
29+
AhbExpressionEvaluationResult, # pydantic
3030
ConditionKeyConditionTextMapping, # pydantic
3131
PackageKeyConditionExpressionMapping, # pydantic
3232
TokenSchema, # marshmallow

0 commit comments

Comments
 (0)