pydpm_xl 0.1.39rc31__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_dpm/__init__.py +1 -1
- py_dpm/api/__init__.py +58 -189
- py_dpm/api/dpm/__init__.py +20 -0
- py_dpm/api/{data_dictionary.py → dpm/data_dictionary.py} +903 -984
- py_dpm/api/dpm/explorer.py +236 -0
- py_dpm/api/dpm/hierarchical_queries.py +142 -0
- py_dpm/api/{migration.py → dpm/migration.py} +16 -19
- py_dpm/api/{operation_scopes.py → dpm/operation_scopes.py} +319 -267
- py_dpm/api/dpm_xl/__init__.py +25 -0
- py_dpm/api/{ast_generator.py → dpm_xl/ast_generator.py} +3 -3
- py_dpm/api/{complete_ast.py → dpm_xl/complete_ast.py} +192 -168
- py_dpm/api/dpm_xl/semantic.py +354 -0
- py_dpm/api/{syntax.py → dpm_xl/syntax.py} +6 -5
- py_dpm/api/explorer.py +4 -0
- py_dpm/api/semantic.py +30 -306
- py_dpm/cli/__init__.py +9 -0
- py_dpm/{client.py → cli/main.py} +8 -8
- py_dpm/dpm/__init__.py +11 -0
- py_dpm/{models.py → dpm/models.py} +112 -88
- py_dpm/dpm/queries/base.py +100 -0
- py_dpm/dpm/queries/basic_objects.py +33 -0
- py_dpm/dpm/queries/explorer_queries.py +352 -0
- py_dpm/dpm/queries/filters.py +139 -0
- py_dpm/dpm/queries/glossary.py +45 -0
- py_dpm/dpm/queries/hierarchical_queries.py +838 -0
- py_dpm/dpm/queries/tables.py +133 -0
- py_dpm/dpm/utils.py +356 -0
- py_dpm/dpm_xl/__init__.py +8 -0
- py_dpm/dpm_xl/ast/__init__.py +14 -0
- py_dpm/{AST/ASTConstructor.py → dpm_xl/ast/constructor.py} +6 -6
- py_dpm/{AST/MLGeneration.py → dpm_xl/ast/ml_generation.py} +137 -87
- py_dpm/{AST/ModuleAnalyzer.py → dpm_xl/ast/module_analyzer.py} +7 -7
- py_dpm/{AST/ModuleDependencies.py → dpm_xl/ast/module_dependencies.py} +56 -41
- py_dpm/{AST/ASTObjects.py → dpm_xl/ast/nodes.py} +1 -1
- py_dpm/{AST/check_operands.py → dpm_xl/ast/operands.py} +16 -13
- py_dpm/{AST/ASTTemplate.py → dpm_xl/ast/template.py} +2 -2
- py_dpm/{AST/WhereClauseChecker.py → dpm_xl/ast/where_clause.py} +2 -2
- py_dpm/dpm_xl/grammar/__init__.py +18 -0
- py_dpm/dpm_xl/operators/__init__.py +19 -0
- py_dpm/{Operators/AggregateOperators.py → dpm_xl/operators/aggregate.py} +7 -7
- py_dpm/{Operators/NumericOperators.py → dpm_xl/operators/arithmetic.py} +6 -6
- py_dpm/{Operators/Operator.py → dpm_xl/operators/base.py} +5 -5
- py_dpm/{Operators/BooleanOperators.py → dpm_xl/operators/boolean.py} +5 -5
- py_dpm/{Operators/ClauseOperators.py → dpm_xl/operators/clause.py} +8 -8
- py_dpm/{Operators/ComparisonOperators.py → dpm_xl/operators/comparison.py} +5 -5
- py_dpm/{Operators/ConditionalOperators.py → dpm_xl/operators/conditional.py} +7 -7
- py_dpm/{Operators/StringOperators.py → dpm_xl/operators/string.py} +5 -5
- py_dpm/{Operators/TimeOperators.py → dpm_xl/operators/time.py} +6 -6
- py_dpm/{semantics/SemanticAnalyzer.py → dpm_xl/semantic_analyzer.py} +168 -68
- py_dpm/{semantics/Symbols.py → dpm_xl/symbols.py} +3 -3
- py_dpm/dpm_xl/types/__init__.py +13 -0
- py_dpm/{DataTypes/TypePromotion.py → dpm_xl/types/promotion.py} +2 -2
- py_dpm/{DataTypes/ScalarTypes.py → dpm_xl/types/scalar.py} +2 -2
- py_dpm/dpm_xl/utils/__init__.py +14 -0
- py_dpm/{data_handlers.py → dpm_xl/utils/data_handlers.py} +2 -2
- py_dpm/{Utils → dpm_xl/utils}/operands_mapping.py +1 -1
- py_dpm/{Utils → dpm_xl/utils}/operator_mapping.py +8 -8
- py_dpm/{OperationScopes/OperationScopeService.py → dpm_xl/utils/scopes_calculator.py} +148 -58
- py_dpm/{Utils/ast_serialization.py → dpm_xl/utils/serialization.py} +2 -2
- py_dpm/dpm_xl/validation/__init__.py +12 -0
- py_dpm/{Utils/ValidationsGenerationUtils.py → dpm_xl/validation/generation_utils.py} +2 -3
- py_dpm/{ValidationsGeneration/PropertiesConstraintsProcessor.py → dpm_xl/validation/property_constraints.py} +56 -21
- py_dpm/{ValidationsGeneration/auxiliary_functions.py → dpm_xl/validation/utils.py} +2 -2
- py_dpm/{ValidationsGeneration/VariantsProcessor.py → dpm_xl/validation/variants.py} +149 -55
- py_dpm/exceptions/__init__.py +23 -0
- py_dpm/{Exceptions → exceptions}/exceptions.py +7 -2
- pydpm_xl-0.2.0.dist-info/METADATA +278 -0
- pydpm_xl-0.2.0.dist-info/RECORD +88 -0
- pydpm_xl-0.2.0.dist-info/entry_points.txt +2 -0
- py_dpm/Exceptions/__init__.py +0 -0
- py_dpm/OperationScopes/__init__.py +0 -0
- py_dpm/Operators/__init__.py +0 -0
- py_dpm/Utils/__init__.py +0 -0
- py_dpm/Utils/utils.py +0 -2
- py_dpm/ValidationsGeneration/Utils.py +0 -364
- py_dpm/ValidationsGeneration/__init__.py +0 -0
- py_dpm/api/data_dictionary_validation.py +0 -614
- py_dpm/db_utils.py +0 -221
- py_dpm/grammar/__init__.py +0 -0
- py_dpm/grammar/dist/__init__.py +0 -0
- py_dpm/grammar/dpm_xlLexer.g4 +0 -437
- py_dpm/grammar/dpm_xlParser.g4 +0 -263
- py_dpm/semantics/DAG/DAGAnalyzer.py +0 -158
- py_dpm/semantics/DAG/__init__.py +0 -0
- py_dpm/semantics/__init__.py +0 -0
- py_dpm/views/data_types.sql +0 -12
- py_dpm/views/datapoints.sql +0 -65
- py_dpm/views/hierarchy_operand_reference.sql +0 -11
- py_dpm/views/hierarchy_preconditions.sql +0 -13
- py_dpm/views/hierarchy_variables.sql +0 -26
- py_dpm/views/hierarchy_variables_context.sql +0 -14
- py_dpm/views/key_components.sql +0 -18
- py_dpm/views/module_from_table.sql +0 -11
- py_dpm/views/open_keys.sql +0 -13
- py_dpm/views/operation_info.sql +0 -27
- py_dpm/views/operation_list.sql +0 -18
- py_dpm/views/operations_versions_from_module_version.sql +0 -30
- py_dpm/views/precondition_info.sql +0 -17
- py_dpm/views/report_type_operand_reference_info.sql +0 -18
- py_dpm/views/subcategory_info.sql +0 -17
- py_dpm/views/table_info.sql +0 -19
- pydpm_xl-0.1.39rc31.dist-info/METADATA +0 -53
- pydpm_xl-0.1.39rc31.dist-info/RECORD +0 -96
- pydpm_xl-0.1.39rc31.dist-info/entry_points.txt +0 -2
- /py_dpm/{AST → cli/commands}/__init__.py +0 -0
- /py_dpm/{migration.py → dpm/migration.py} +0 -0
- /py_dpm/{AST/ASTVisitor.py → dpm_xl/ast/visitor.py} +0 -0
- /py_dpm/{DataTypes → dpm_xl/grammar/generated}/__init__.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlLexer.interp +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlLexer.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlLexer.tokens +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParser.interp +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParser.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParser.tokens +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParserListener.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParserVisitor.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/listeners.py +0 -0
- /py_dpm/{DataTypes/TimeClasses.py → dpm_xl/types/time.py} +0 -0
- /py_dpm/{Utils → dpm_xl/utils}/tokens.py +0 -0
- /py_dpm/{Exceptions → exceptions}/messages.py +0 -0
- {pydpm_xl-0.1.39rc31.dist-info → pydpm_xl-0.2.0.dist-info}/WHEEL +0 -0
- {pydpm_xl-0.1.39rc31.dist-info → pydpm_xl-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {pydpm_xl-0.1.39rc31.dist-info → pydpm_xl-0.2.0.dist-info}/top_level.txt +0 -0
py_dpm/grammar/dpm_xlParser.g4
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
parser grammar dpm_xlParser;
|
|
2
|
-
|
|
3
|
-
options { tokenVocab=dpm_xlLexer ;}
|
|
4
|
-
|
|
5
|
-
// Added rule for expr management and EOF
|
|
6
|
-
start:
|
|
7
|
-
statement ((EOL statements) | EOL?) EOF
|
|
8
|
-
;
|
|
9
|
-
|
|
10
|
-
statements:
|
|
11
|
-
(statement EOL)+
|
|
12
|
-
;
|
|
13
|
-
|
|
14
|
-
statement:
|
|
15
|
-
expressionWithoutAssignment #exprWithoutAssignment
|
|
16
|
-
| temporaryAssignmentExpression #assignmentExpr
|
|
17
|
-
;
|
|
18
|
-
|
|
19
|
-
persistentExpression:
|
|
20
|
-
persistentAssignmentExpression
|
|
21
|
-
| expressionWithoutAssignment
|
|
22
|
-
;
|
|
23
|
-
|
|
24
|
-
expressionWithoutAssignment:
|
|
25
|
-
expression #exprWithoutPartialSelection
|
|
26
|
-
| WITH partialSelection
|
|
27
|
-
(SQUARE_BRACKET_LEFT WHERE expression SQUARE_BRACKET_RIGHT)?
|
|
28
|
-
COLON expression #exprWithSelection
|
|
29
|
-
;
|
|
30
|
-
|
|
31
|
-
partialSelection:
|
|
32
|
-
CURLY_BRACKET_LEFT cellRef CURLY_BRACKET_RIGHT #partialSelect
|
|
33
|
-
;
|
|
34
|
-
|
|
35
|
-
temporaryAssignmentExpression:
|
|
36
|
-
temporaryIdentifier ASSIGN persistentExpression
|
|
37
|
-
;
|
|
38
|
-
|
|
39
|
-
persistentAssignmentExpression:
|
|
40
|
-
varID PERSISTENT_ASSIGN expressionWithoutAssignment
|
|
41
|
-
;
|
|
42
|
-
|
|
43
|
-
expression:
|
|
44
|
-
LPAREN expression RPAREN #parExpr
|
|
45
|
-
| functions #funcExpr
|
|
46
|
-
| expression SQUARE_BRACKET_LEFT clauseOperators SQUARE_BRACKET_RIGHT #clauseExpr
|
|
47
|
-
| op=(PLUS|MINUS) expression #unaryExpr
|
|
48
|
-
| op=NOT LPAREN expression RPAREN #notExpr
|
|
49
|
-
| left=expression op=(MULT|DIV) right=expression #numericExpr
|
|
50
|
-
| left=expression op=(PLUS|MINUS) right=expression #numericExpr
|
|
51
|
-
| left=expression op=CONCAT right=expression #concatExpr
|
|
52
|
-
| left=expression op=comparisonOperators right=expression #compExpr
|
|
53
|
-
| left=expression op=IN setOperand #inExpr
|
|
54
|
-
| left=expression op=AND right=expression #boolExpr
|
|
55
|
-
| left=expression op=(OR|XOR) right=expression #boolExpr
|
|
56
|
-
| IF conditionalExpr=expression THEN thenExpr=expression (ELSE elseExpr=expression)? ENDIF #ifExpr
|
|
57
|
-
| itemReference #itemReferenceExpr
|
|
58
|
-
| propertyReference #propertyReferenceExpr
|
|
59
|
-
| keyNames #keyNamesExpr
|
|
60
|
-
| literal #literalExpr
|
|
61
|
-
| select #selectExpr
|
|
62
|
-
;
|
|
63
|
-
|
|
64
|
-
setOperand:
|
|
65
|
-
CURLY_BRACKET_LEFT setElements CURLY_BRACKET_RIGHT
|
|
66
|
-
;
|
|
67
|
-
|
|
68
|
-
setElements:
|
|
69
|
-
itemReference (COMMA itemReference)*
|
|
70
|
-
| literal (COMMA literal)*
|
|
71
|
-
;
|
|
72
|
-
|
|
73
|
-
functions:
|
|
74
|
-
aggregateOperators #aggregateFunctions
|
|
75
|
-
| numericOperators #numericFunctions
|
|
76
|
-
| comparisonFunctionOperators #comparisonFunctions
|
|
77
|
-
| filterOperators #filterFunctions
|
|
78
|
-
| conditionalOperators #conditionalFunctions
|
|
79
|
-
| timeOperators #timeFunctions
|
|
80
|
-
| stringOperators #stringFunctions
|
|
81
|
-
;
|
|
82
|
-
|
|
83
|
-
numericOperators:
|
|
84
|
-
op=(ABS|EXP|LN|SQRT) LPAREN expression RPAREN #unaryNumericFunctions
|
|
85
|
-
| op=(POWER|LOG) LPAREN left=expression COMMA right=expression RPAREN #binaryNumericFunctions
|
|
86
|
-
| op=(MAX|MIN) LPAREN expression (COMMA expression)+ RPAREN #complexNumericFunctions
|
|
87
|
-
;
|
|
88
|
-
|
|
89
|
-
comparisonFunctionOperators:
|
|
90
|
-
MATCH LPAREN expression COMMA literal RPAREN #matchExpr
|
|
91
|
-
| ISNULL LPAREN expression RPAREN #isnullExpr
|
|
92
|
-
;
|
|
93
|
-
|
|
94
|
-
filterOperators:
|
|
95
|
-
FILTER LPAREN expression COMMA expression RPAREN
|
|
96
|
-
;
|
|
97
|
-
|
|
98
|
-
timeOperators:
|
|
99
|
-
TIME_SHIFT LPAREN expression COMMA TIME_PERIOD COMMA INTEGER_LITERAL (COMMA propertyCode)? RPAREN #timeShiftFunction
|
|
100
|
-
;
|
|
101
|
-
|
|
102
|
-
conditionalOperators:
|
|
103
|
-
NVL LPAREN expression COMMA expression RPAREN #nvlFunction
|
|
104
|
-
;
|
|
105
|
-
|
|
106
|
-
stringOperators:
|
|
107
|
-
LEN LPAREN expression RPAREN #unaryStringFunction
|
|
108
|
-
;
|
|
109
|
-
|
|
110
|
-
aggregateOperators:
|
|
111
|
-
op=(MAX_AGGR
|
|
112
|
-
|MIN_AGGR
|
|
113
|
-
|SUM
|
|
114
|
-
|COUNT
|
|
115
|
-
|AVG
|
|
116
|
-
|MEDIAN) LPAREN expression (groupingClause)? RPAREN #commonAggrOp
|
|
117
|
-
;
|
|
118
|
-
|
|
119
|
-
groupingClause:
|
|
120
|
-
GROUP_BY keyNames (COMMA keyNames)*
|
|
121
|
-
;
|
|
122
|
-
|
|
123
|
-
// Dimension management and members
|
|
124
|
-
itemSignature: ITEM_SIGNATURE;
|
|
125
|
-
itemReference: SQUARE_BRACKET_LEFT itemSignature SQUARE_BRACKET_RIGHT;
|
|
126
|
-
|
|
127
|
-
// Cell Address and table management
|
|
128
|
-
rowElem:
|
|
129
|
-
ROW
|
|
130
|
-
| ROW_RANGE
|
|
131
|
-
| ROW_ALL
|
|
132
|
-
;
|
|
133
|
-
colElem:
|
|
134
|
-
COL
|
|
135
|
-
| COL_RANGE
|
|
136
|
-
| COL_ALL
|
|
137
|
-
;
|
|
138
|
-
sheetElem:
|
|
139
|
-
SHEET
|
|
140
|
-
| SHEET_RANGE
|
|
141
|
-
| SHEET_ALL
|
|
142
|
-
;
|
|
143
|
-
rowHandler:
|
|
144
|
-
rowElem
|
|
145
|
-
| LPAREN ROW (COMMA ROW)* RPAREN;
|
|
146
|
-
|
|
147
|
-
colHandler:
|
|
148
|
-
colElem
|
|
149
|
-
| LPAREN COL (COMMA COL)* RPAREN;
|
|
150
|
-
|
|
151
|
-
sheetHandler:
|
|
152
|
-
sheetElem
|
|
153
|
-
| LPAREN SHEET (COMMA SHEET)* RPAREN
|
|
154
|
-
;
|
|
155
|
-
|
|
156
|
-
interval:
|
|
157
|
-
INTERVAL COLON BOOLEAN_LITERAL
|
|
158
|
-
;
|
|
159
|
-
|
|
160
|
-
default:
|
|
161
|
-
DEFAULT COLON literal
|
|
162
|
-
| DEFAULT COLON NULL_LITERAL
|
|
163
|
-
;
|
|
164
|
-
|
|
165
|
-
argument:
|
|
166
|
-
rowHandler #rowArg
|
|
167
|
-
| colHandler #colArg
|
|
168
|
-
| sheetHandler #sheetArg
|
|
169
|
-
| interval #intervalArg
|
|
170
|
-
| default #defaultArg
|
|
171
|
-
;
|
|
172
|
-
|
|
173
|
-
select:
|
|
174
|
-
CURLY_BRACKET_LEFT selectOperand CURLY_BRACKET_RIGHT
|
|
175
|
-
;
|
|
176
|
-
|
|
177
|
-
selectOperand:
|
|
178
|
-
cellRef
|
|
179
|
-
| varRef
|
|
180
|
-
| operationRef
|
|
181
|
-
| preconditionElem
|
|
182
|
-
;
|
|
183
|
-
|
|
184
|
-
varID:
|
|
185
|
-
CURLY_BRACKET_LEFT varRef CURLY_BRACKET_RIGHT
|
|
186
|
-
;
|
|
187
|
-
|
|
188
|
-
cellRef:
|
|
189
|
-
address=cellAddress
|
|
190
|
-
;
|
|
191
|
-
|
|
192
|
-
preconditionElem:
|
|
193
|
-
PRECONDITION_ELEMENT
|
|
194
|
-
;
|
|
195
|
-
|
|
196
|
-
varRef:
|
|
197
|
-
VAR_REFERENCE
|
|
198
|
-
;
|
|
199
|
-
|
|
200
|
-
operationRef:
|
|
201
|
-
OPERATION_REFERENCE
|
|
202
|
-
;
|
|
203
|
-
|
|
204
|
-
cellAddress:
|
|
205
|
-
tableReference (COMMA argument)* #tableRef
|
|
206
|
-
| argument (COMMA argument)* #compRef;
|
|
207
|
-
|
|
208
|
-
tableReference:
|
|
209
|
-
TABLE_REFERENCE
|
|
210
|
-
| TABLE_GROUP_REFERENCE
|
|
211
|
-
;
|
|
212
|
-
|
|
213
|
-
clauseOperators:
|
|
214
|
-
WHERE expression #whereExpr
|
|
215
|
-
| GET keyNames #getExpr
|
|
216
|
-
| RENAME renameClause (COMMA renameClause)* #renameExpr
|
|
217
|
-
| SUB propertyCode EQ (literal | select | itemReference) #subExpr
|
|
218
|
-
;
|
|
219
|
-
|
|
220
|
-
// Always on grammar, not on tokens. Order is important (top ones should be the enclosing ones)
|
|
221
|
-
|
|
222
|
-
renameClause:
|
|
223
|
-
keyNames TO keyNames
|
|
224
|
-
;
|
|
225
|
-
|
|
226
|
-
comparisonOperators:
|
|
227
|
-
EQ
|
|
228
|
-
|NE
|
|
229
|
-
|GT
|
|
230
|
-
|LT
|
|
231
|
-
|GE
|
|
232
|
-
|LE;
|
|
233
|
-
|
|
234
|
-
literal:
|
|
235
|
-
INTEGER_LITERAL
|
|
236
|
-
| DECIMAL_LITERAL
|
|
237
|
-
| PERCENT_LITERAL
|
|
238
|
-
| STRING_LITERAL
|
|
239
|
-
| BOOLEAN_LITERAL
|
|
240
|
-
| DATE_LITERAL
|
|
241
|
-
| TIME_INTERVAL_LITERAL
|
|
242
|
-
| TIME_PERIOD_LITERAL
|
|
243
|
-
| EMPTY_LITERAL
|
|
244
|
-
;
|
|
245
|
-
|
|
246
|
-
keyNames:
|
|
247
|
-
ROW_COMPONENT
|
|
248
|
-
| COL_COMPONENT
|
|
249
|
-
| SHEET_COMPONENT
|
|
250
|
-
| PROPERTY_CODE
|
|
251
|
-
;
|
|
252
|
-
|
|
253
|
-
propertyReference:
|
|
254
|
-
SQUARE_BRACKET_LEFT propertyCode SQUARE_BRACKET_RIGHT;
|
|
255
|
-
|
|
256
|
-
propertyCode:
|
|
257
|
-
PROPERTY_CODE
|
|
258
|
-
| CODE
|
|
259
|
-
;
|
|
260
|
-
|
|
261
|
-
temporaryIdentifier:
|
|
262
|
-
CODE
|
|
263
|
-
;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
import networkx as nx
|
|
3
|
-
|
|
4
|
-
from py_dpm.AST.ASTObjects import Start, PersistentAssignment, WithExpression, AST, OperationRef, TemporaryAssignment
|
|
5
|
-
from py_dpm.AST.ASTTemplate import ASTTemplate
|
|
6
|
-
from py_dpm.Exceptions import exceptions
|
|
7
|
-
from py_dpm.Utils.tokens import INPUTS, OUTPUTS
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class DAGAnalyzer(ASTTemplate):
|
|
11
|
-
"""
|
|
12
|
-
Class to generate the Direct Acyclic Graph from calculations scripts.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
def __init__(self):
|
|
16
|
-
super().__init__()
|
|
17
|
-
self.inputs: list = []
|
|
18
|
-
self.outputs: list = []
|
|
19
|
-
self.dependencies: dict = {}
|
|
20
|
-
self.calculation_number = 1
|
|
21
|
-
|
|
22
|
-
self.vertex: dict = {}
|
|
23
|
-
self.edges: dict = {}
|
|
24
|
-
self.number_of_vertex: int = 0
|
|
25
|
-
self.adjacency_matrix = None
|
|
26
|
-
self.sorting = None
|
|
27
|
-
|
|
28
|
-
self.graph = None
|
|
29
|
-
|
|
30
|
-
def create_DAG(self, ast: AST):
|
|
31
|
-
"""
|
|
32
|
-
Method to generate the Direct Acyclic Graph from ast
|
|
33
|
-
"""
|
|
34
|
-
self.visit(ast)
|
|
35
|
-
|
|
36
|
-
self.load_vertex()
|
|
37
|
-
self.load_edges()
|
|
38
|
-
self.create_adjacency_matrix()
|
|
39
|
-
|
|
40
|
-
try:
|
|
41
|
-
self.nx_topological_sort()
|
|
42
|
-
if len(self.edges):
|
|
43
|
-
self.sort_ast(ast=ast)
|
|
44
|
-
|
|
45
|
-
except nx.NetworkXUnfeasible:
|
|
46
|
-
graph_cycles = nx.find_cycle(self.graph)
|
|
47
|
-
pos1, pos2 = graph_cycles[0]
|
|
48
|
-
op1 = self.vertex[pos1]
|
|
49
|
-
op2 = self.vertex[pos2]
|
|
50
|
-
raise exceptions.ScriptingError(code="6-4", op1=op1, op2=op2)
|
|
51
|
-
|
|
52
|
-
def load_vertex(self):
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
for key, calculation in self.dependencies.items():
|
|
58
|
-
outputs = calculation[OUTPUTS]
|
|
59
|
-
if len(outputs) > 0:
|
|
60
|
-
self.vertex[key] = outputs[0]
|
|
61
|
-
self.number_of_vertex = len(self.vertex)
|
|
62
|
-
|
|
63
|
-
def load_edges(self):
|
|
64
|
-
"""
|
|
65
|
-
|
|
66
|
-
"""
|
|
67
|
-
if len(self.vertex) > 0:
|
|
68
|
-
number_of_edges = 0
|
|
69
|
-
for key, calculation in self.dependencies.items():
|
|
70
|
-
outputs = calculation[OUTPUTS]
|
|
71
|
-
if len(outputs) > 0:
|
|
72
|
-
output = outputs[0]
|
|
73
|
-
for sub_key, sub_calculation in self.dependencies.items():
|
|
74
|
-
inputs = sub_calculation[INPUTS]
|
|
75
|
-
if inputs and output in inputs:
|
|
76
|
-
self.edges[number_of_edges] = (key, sub_key)
|
|
77
|
-
number_of_edges += 1
|
|
78
|
-
|
|
79
|
-
def create_adjacency_matrix(self):
|
|
80
|
-
"""
|
|
81
|
-
|
|
82
|
-
"""
|
|
83
|
-
self.adjacency_matrix = np.zeros((self.number_of_vertex, self.number_of_vertex), dtype=int)
|
|
84
|
-
for edge in list(self.edges.values()):
|
|
85
|
-
self.adjacency_matrix[edge[0] - 1][edge[1] - 1] = 1
|
|
86
|
-
|
|
87
|
-
def nx_topological_sort(self):
|
|
88
|
-
"""
|
|
89
|
-
|
|
90
|
-
"""
|
|
91
|
-
edges = list(self.edges.values())
|
|
92
|
-
self.graph = DAG = nx.DiGraph()
|
|
93
|
-
DAG.add_nodes_from(self.vertex)
|
|
94
|
-
DAG.add_edges_from(edges)
|
|
95
|
-
self.sorting = list(nx.topological_sort(DAG))
|
|
96
|
-
|
|
97
|
-
def sort_ast(self, ast):
|
|
98
|
-
"""
|
|
99
|
-
|
|
100
|
-
"""
|
|
101
|
-
lst = []
|
|
102
|
-
calculations = list(ast.children)
|
|
103
|
-
for x in self.sorting:
|
|
104
|
-
for i in range(len(calculations)):
|
|
105
|
-
if i == x - 1:
|
|
106
|
-
lst.append(calculations[i])
|
|
107
|
-
self.check_overwriting(lst)
|
|
108
|
-
ast.children = lst
|
|
109
|
-
|
|
110
|
-
def check_overwriting(self, outputs):
|
|
111
|
-
"""
|
|
112
|
-
|
|
113
|
-
"""
|
|
114
|
-
non_repeated = []
|
|
115
|
-
outputs_lst = []
|
|
116
|
-
for output in outputs:
|
|
117
|
-
if isinstance(output, TemporaryAssignment):
|
|
118
|
-
temporary_identifier_value = output.left.value
|
|
119
|
-
outputs_lst.append(temporary_identifier_value)
|
|
120
|
-
if isinstance(output.right, PersistentAssignment):
|
|
121
|
-
outputs_lst.append(output.right.left.variable)
|
|
122
|
-
for output_value in outputs_lst:
|
|
123
|
-
if output_value not in non_repeated:
|
|
124
|
-
non_repeated.append(output_value)
|
|
125
|
-
else:
|
|
126
|
-
raise exceptions.SemanticError("6-1", variable=output_value)
|
|
127
|
-
|
|
128
|
-
def get_calculation_structure(self):
|
|
129
|
-
"""
|
|
130
|
-
|
|
131
|
-
"""
|
|
132
|
-
inputs = list(set(self.inputs))
|
|
133
|
-
outputs = list(set(self.outputs))
|
|
134
|
-
|
|
135
|
-
return {INPUTS: inputs, OUTPUTS: outputs}
|
|
136
|
-
|
|
137
|
-
def visit_Start(self, node: Start):
|
|
138
|
-
for child in node.children:
|
|
139
|
-
self.visit(child)
|
|
140
|
-
self.dependencies[self.calculation_number] = self.get_calculation_structure()
|
|
141
|
-
|
|
142
|
-
self.calculation_number += 1
|
|
143
|
-
|
|
144
|
-
self.inputs = []
|
|
145
|
-
self.outputs = []
|
|
146
|
-
|
|
147
|
-
def visit_PersistentAssignment(self, node: PersistentAssignment):
|
|
148
|
-
self.visit(node.right)
|
|
149
|
-
|
|
150
|
-
def visit_TemporaryAssignment(self, node: TemporaryAssignment):
|
|
151
|
-
self.outputs.append(node.left.value)
|
|
152
|
-
self.visit(node.right)
|
|
153
|
-
|
|
154
|
-
def visit_OperationRef(self, node: OperationRef):
|
|
155
|
-
self.inputs.append(node.operation_code)
|
|
156
|
-
|
|
157
|
-
def visit_WithExpression(self, node: WithExpression):
|
|
158
|
-
self.visit(node.expression)
|
py_dpm/semantics/DAG/__init__.py
DELETED
|
File without changes
|
py_dpm/semantics/__init__.py
DELETED
|
File without changes
|
py_dpm/views/data_types.sql
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
CREATE
|
|
2
|
-
OR ALTER
|
|
3
|
-
VIEW data_types AS
|
|
4
|
-
SELECT vv.VariableID as datapoint,
|
|
5
|
-
dt.Code as data_type,
|
|
6
|
-
vv.StartReleaseID as start_release,
|
|
7
|
-
vv.EndReleaseID as end_release
|
|
8
|
-
from VariableVersion vv
|
|
9
|
-
inner join Property p on
|
|
10
|
-
p.PropertyID = vv.PropertyID
|
|
11
|
-
inner join DataType dt on
|
|
12
|
-
dt.DataTypeID = p.DataTypeID
|
py_dpm/views/datapoints.sql
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
CREATE OR ALTER VIEW datapoints AS
|
|
2
|
-
SELECT distinct tvc.CellCode AS cell_code,
|
|
3
|
-
tv.Code AS table_code,
|
|
4
|
-
hvr.Code AS row_code,
|
|
5
|
-
hvc.Code AS column_code,
|
|
6
|
-
hvs.Code AS sheet_code,
|
|
7
|
-
vv.VariableID AS variable_id,
|
|
8
|
-
dt.Code AS data_type,
|
|
9
|
-
tv.TableVID AS table_vid,
|
|
10
|
-
|
|
11
|
-
p.PropertyID AS property_id,
|
|
12
|
-
mv.StartReleaseID AS start_release,
|
|
13
|
-
mv.EndReleaseID AS end_release,
|
|
14
|
-
tvc.CellID AS cell_id,
|
|
15
|
-
vv.ContextID AS context_id,
|
|
16
|
-
vv.VariableVID AS variable_vid
|
|
17
|
-
|
|
18
|
-
FROM dbo.TableVersionCell AS tvc
|
|
19
|
-
|
|
20
|
-
INNER JOIN dbo.TableVersion AS tv
|
|
21
|
-
ON tvc.TableVID = tv.TableVID AND tvc.IsVoid = 0
|
|
22
|
-
INNER JOIN dbo.ModuleVersionComposition mvc on tv.TableVID = mvc.TableVID
|
|
23
|
-
inner join dbo.ModuleVersion mv on mvc.ModuleVID = mv.ModuleVID
|
|
24
|
-
|
|
25
|
-
LEFT OUTER JOIN dbo.VariableVersion AS vv
|
|
26
|
-
ON tvc.VariableVID = vv.VariableVID
|
|
27
|
-
|
|
28
|
-
LEFT OUTER JOIN dbo.Property AS p ON vv.PropertyID = p.PropertyID
|
|
29
|
-
|
|
30
|
-
LEFT OUTER JOIN dbo.DataType AS dt ON p.DataTypeID = dt.DataTypeID
|
|
31
|
-
|
|
32
|
-
INNER JOIN dbo.Cell AS c ON tvc.CellID = c.CellID
|
|
33
|
-
|
|
34
|
-
LEFT OUTER JOIN
|
|
35
|
-
|
|
36
|
-
(SELECT hv.HeaderVID, hv.HeaderID, hv.Code, hv.EndReleaseID, tvh.TableVID
|
|
37
|
-
|
|
38
|
-
FROM HeaderVersion hv
|
|
39
|
-
|
|
40
|
-
INNER JOIN TableVersionHeader tvh
|
|
41
|
-
ON tvh.HeaderVID = hv.HeaderVID) hvr
|
|
42
|
-
ON hvr.HeaderID = c.RowID AND hvr.EndReleaseID IS NULL AND
|
|
43
|
-
tv.TableVID = hvr.TableVID
|
|
44
|
-
|
|
45
|
-
LEFT OUTER JOIN
|
|
46
|
-
|
|
47
|
-
(SELECT hv.HeaderVID, hv.HeaderID, hv.Code, hv.EndReleaseID, tvh.TableVID
|
|
48
|
-
|
|
49
|
-
FROM HeaderVersion hv
|
|
50
|
-
|
|
51
|
-
INNER JOIN TableVersionHeader tvh
|
|
52
|
-
ON tvh.HeaderVID = hv.HeaderVID) hvc
|
|
53
|
-
ON hvc.HeaderID = c.ColumnID AND hvc.EndReleaseID IS NULL AND
|
|
54
|
-
tv.TableVID = hvc.TableVID
|
|
55
|
-
|
|
56
|
-
LEFT OUTER JOIN
|
|
57
|
-
|
|
58
|
-
(SELECT hv.HeaderVID, hv.HeaderID, hv.Code, hv.EndReleaseID, tvh.TableVID
|
|
59
|
-
|
|
60
|
-
FROM HeaderVersion hv
|
|
61
|
-
|
|
62
|
-
INNER JOIN TableVersionHeader tvh
|
|
63
|
-
ON tvh.HeaderVID = hv.HeaderVID) hvs
|
|
64
|
-
ON hvs.HeaderID = c.SheetID AND hvs.EndReleaseID IS NULL AND
|
|
65
|
-
tv.TableVID = hvs.TableVID
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
CREATE OR ALTER VIEW hierarchy_operand_reference_info AS
|
|
2
|
-
select distinct o.code as operation_code,
|
|
3
|
-
on2.NodeID as operation_node_id,
|
|
4
|
-
orl.CellID as cell_id,
|
|
5
|
-
or2.VariableID as variable_id
|
|
6
|
-
FROM OperandReferenceLocation orl
|
|
7
|
-
inner join OperandReference or2 on orl.OperandReferenceID = or2.OperandReferenceID
|
|
8
|
-
inner join OperationNode on2 on on2.NodeID = or2.NodeID
|
|
9
|
-
inner join OperationVersion ov on ov.OperationVID = on2.OperationVID
|
|
10
|
-
inner join Operation o on o.OperationID = ov.OperationID
|
|
11
|
-
WHERE o.[Source] = 'hierarchy';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
CREATE OR ALTER VIEW hierarchy_preconditions
|
|
2
|
-
AS
|
|
3
|
-
SELECT ov.Expression as expression,
|
|
4
|
-
o.Code as operation_code,
|
|
5
|
-
VV.Code as variable_code
|
|
6
|
-
FROM Operation o
|
|
7
|
-
inner join OperationVersion ov on o.OperationID = ov.OperationID
|
|
8
|
-
inner join dbo.OperationNode N on ov.OperationVID = N.OperationVID
|
|
9
|
-
inner join dbo.OperandReference OR2 on N.NodeID = OR2.NodeID
|
|
10
|
-
inner join dbo.Variable V on OR2.VariableID = V.VariableID
|
|
11
|
-
inner join dbo.VariableVersion VV on V.VariableID = VV.VariableID
|
|
12
|
-
where o.Code like 'p_%'
|
|
13
|
-
and Expression not like '%or%';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
CREATE OR ALTER VIEW hierarchy_variables AS
|
|
2
|
-
SELECT scv.SubCategoryID as subcategory_id,
|
|
3
|
-
vv.VariableVID as variable_vid,
|
|
4
|
-
tvc.CellCode as cell_code,
|
|
5
|
-
mp.Code as main_property_code,
|
|
6
|
-
cp.Code as context_property_code,
|
|
7
|
-
i.Code as item_code,
|
|
8
|
-
mv.StartReleaseID as start_release_id,
|
|
9
|
-
mv.EndReleaseID as end_release_id
|
|
10
|
-
FROM SubCategoryVersion scv
|
|
11
|
-
inner join SubCategoryItem sci
|
|
12
|
-
on sci.SubCategoryVID = scv.SubCategoryVID
|
|
13
|
-
inner join ContextComposition cc on cc.ItemID = sci.ItemID
|
|
14
|
-
inner join VariableVersion vv on vv.ContextID = cc.ContextID
|
|
15
|
-
inner join TableVersionCell tvc on vv.VariableVID = tvc.VariableVID
|
|
16
|
-
inner join Property p on vv.PropertyID = p.PropertyID
|
|
17
|
-
inner join DataType dt on p.DataTypeID = dt.DataTypeID
|
|
18
|
-
left join ItemCategory mp on mp.ItemID = vv.PropertyID and mp.EndReleaseID is Null
|
|
19
|
-
left join ItemCategory cp on cp.ItemID = cc.PropertyID and cp.EndReleaseID is Null
|
|
20
|
-
left join ItemCategory i on i.ItemID = cc.ItemID and i.EndReleaseID is Null
|
|
21
|
-
inner join TableVersion tv on tv.TableVID = tvc.TableVID
|
|
22
|
-
inner join ModuleVersionComposition mvc on tv.TableVID = mvc.TableVID
|
|
23
|
-
inner join ModuleVersion mv on mvc.ModuleVID = mv.ModuleVID
|
|
24
|
-
|
|
25
|
-
where dt.Code in ('m', 'i', 'r')
|
|
26
|
-
and tvc.CellCode is not Null
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
CREATE or ALTER VIEW hierarchy_variables_context as
|
|
2
|
-
SELECT distinct vv.VariableVID as variable_vid,
|
|
3
|
-
cp.Code as context_property_code,
|
|
4
|
-
i.Code as item_code,
|
|
5
|
-
mv.StartReleaseID as start_release_id,
|
|
6
|
-
mv.EndReleaseID as end_release_id
|
|
7
|
-
FROM VariableVersion vv
|
|
8
|
-
inner join ContextComposition cc on cc.ContextID = vv.ContextID
|
|
9
|
-
inner join ItemCategory cp on cp.ItemID = cc.PropertyID and cp.EndReleaseID is Null
|
|
10
|
-
inner join ItemCategory i on i.ItemID = cc.ItemID and i.EndReleaseID is Null
|
|
11
|
-
inner join TableVersionCell tvc on vv.VariableVID = tvc.VariableVID
|
|
12
|
-
inner join TableVersion tv on tvc.TableVID = tv.TableVID
|
|
13
|
-
inner join ModuleVersionComposition mvc on tv.TableVID = mvc.TableVID
|
|
14
|
-
inner join ModuleVersion mv on mvc.ModuleVID = mv.ModuleVID;
|
py_dpm/views/key_components.sql
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
CREATE OR ALTER VIEW key_components AS
|
|
2
|
-
select tv.Code as table_code,
|
|
3
|
-
ic.Code as property_code,
|
|
4
|
-
dt.Code as data_type,
|
|
5
|
-
tv.TableVID as table_version_id,
|
|
6
|
-
ic.StartReleaseID as start_release_ic,
|
|
7
|
-
ic.EndReleaseID as end_release_ic,
|
|
8
|
-
mv.StartReleaseID as start_release_mv,
|
|
9
|
-
mv.EndReleaseID as end_release_mv
|
|
10
|
-
from [dbo].TableVersion tv
|
|
11
|
-
inner join [dbo].KeyComposition kc on tv.KeyID = kc.KeyID
|
|
12
|
-
inner join [dbo].VariableVersion vv on vv.VariableVID = kc.VariableVID
|
|
13
|
-
inner join [dbo].Item i on vv.PropertyID = i.ItemID
|
|
14
|
-
inner join [dbo].ItemCategory ic on ic.ItemID = i.ItemID
|
|
15
|
-
inner join [dbo].Property p on vv.PropertyID = p.PropertyID
|
|
16
|
-
left join [dbo].DataType dt on p.DataTypeID = dt.DataTypeID
|
|
17
|
-
inner join [dbo].ModuleVersionComposition mvc on tv.TableVID = mvc.TableVID
|
|
18
|
-
inner join [dbo].ModuleVersion mv on mvc.ModuleVID = mv.ModuleVID;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
CREATE OR ALTER VIEW module_from_table AS
|
|
2
|
-
SELECT MV.Code as module_code,
|
|
3
|
-
TV.Code as table_code,
|
|
4
|
-
MV.FromReferenceDate as from_date,
|
|
5
|
-
MV.ToReferenceDate as to_date
|
|
6
|
-
from Module m
|
|
7
|
-
inner join ModuleVersion MV on m.ModuleID = MV.ModuleID
|
|
8
|
-
inner join ModuleVersionComposition MVC
|
|
9
|
-
on MV.ModuleVID = MVC.ModuleVID
|
|
10
|
-
inner join TableVersion TV on MVC.TableVID = TV.TableVID
|
|
11
|
-
where TV.Code is not null;
|
py_dpm/views/open_keys.sql
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
CREATE
|
|
2
|
-
OR ALTER
|
|
3
|
-
VIEW open_keys AS
|
|
4
|
-
select ic.Code as property_code,
|
|
5
|
-
dt.Code as data_type,
|
|
6
|
-
ic.StartReleaseID as start_release,
|
|
7
|
-
ic.EndReleaseID as end_release
|
|
8
|
-
from [dbo].KeyComposition kc
|
|
9
|
-
inner join [dbo].VariableVersion vv on vv.VariableVID = kc.VariableVID
|
|
10
|
-
inner join [dbo].Item i on vv.PropertyID = i.ItemID
|
|
11
|
-
inner join [dbo].ItemCategory ic on ic.ItemID = i.ItemID
|
|
12
|
-
inner join [dbo].Property p on vv.PropertyID = p.PropertyID
|
|
13
|
-
left join [dbo].DataType dt on p.DataTypeID = dt.DataTypeID;
|
py_dpm/views/operation_info.sql
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
CREATE
|
|
2
|
-
OR ALTER
|
|
3
|
-
VIEW operation_info AS
|
|
4
|
-
select opN.NodeID as operation_node_id,
|
|
5
|
-
opN.OperationVID as operation_version_id,
|
|
6
|
-
opN.ParentNodeID as parent_node_id,
|
|
7
|
-
O.OperatorID as operator_id,
|
|
8
|
-
O.Symbol as symbol,
|
|
9
|
-
opA.Name as argument,
|
|
10
|
-
opA.[Order] as operator_argument_order,
|
|
11
|
-
opN.IsLeaf as is_leaf,
|
|
12
|
-
opN.Scalar as scalar,
|
|
13
|
-
opR.OperandReferenceId as operand_reference_id,
|
|
14
|
-
opR.OperandReference as operand_reference,
|
|
15
|
-
opR.ItemID as item_id,
|
|
16
|
-
opR.PropertyID as property_id,
|
|
17
|
-
opR.VariableID as variable_id,
|
|
18
|
-
opR.x,
|
|
19
|
-
opR.y,
|
|
20
|
-
opR.z,
|
|
21
|
-
opN.UseIntervalArithmetics as use_interval_arithmetics,
|
|
22
|
-
opN.FallbackValue as fallback_value
|
|
23
|
-
from [dbo].OperationNode opN
|
|
24
|
-
left join [dbo].OperandReference opR on opN.NodeID = opR.NodeID
|
|
25
|
-
left join [dbo].Operator O on O.OperatorID = opN.OperatorID
|
|
26
|
-
left join [dbo].OperatorArgument opA
|
|
27
|
-
on opN.ArgumentID = opA.ArgumentID;
|
py_dpm/views/operation_list.sql
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
CREATE OR ALTER VIEW operations AS
|
|
2
|
-
SELECT o.Code as operation_code,
|
|
3
|
-
ov.StartReleaseID as start_release,
|
|
4
|
-
ov.EndReleaseID as end_release,
|
|
5
|
-
ov.Expression as expression,
|
|
6
|
-
ov.OperationVID as operation_version_id,
|
|
7
|
-
ov.PreconditionOperationVID as precondition_operation_version_id
|
|
8
|
-
from Operation o
|
|
9
|
-
inner join OperationVersion ov on o.OperationId = ov.OperationId
|
|
10
|
-
where o.Code in (SELECT DISTINCT o.Code
|
|
11
|
-
from Operation o
|
|
12
|
-
inner join OperationVersion ov
|
|
13
|
-
on o.OperationID = ov.OperationID
|
|
14
|
-
left join dbo.OperationScope OS
|
|
15
|
-
on ov.OperationVID = OS.OperationVID
|
|
16
|
-
where OS.IsActive = 1)
|
|
17
|
-
-- inner join Expression E on ov.OperationVID = E.OperationVID
|
|
18
|
-
-- where E.LanguageID = 2;
|