pytrilogy 0.0.3.91__py3-none-any.whl → 0.0.3.93__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.

Potentially problematic release.


This version of pytrilogy might be problematic. Click here for more details.

@@ -90,9 +90,7 @@ def validate_concepts(v) -> BuildEnvironmentConceptDict:
90
90
  if isinstance(v, BuildEnvironmentConceptDict):
91
91
  return v
92
92
  elif isinstance(v, dict):
93
- return BuildEnvironmentConceptDict(
94
- **{x: BuildConcept.model_validate(y) for x, y in v.items()}
95
- )
93
+ return BuildEnvironmentConceptDict(**{x: y for x, y in v.items()})
96
94
  raise ValueError
97
95
 
98
96
 
@@ -100,9 +98,7 @@ def validate_datasources(v) -> BuildEnvironmentDatasourceDict:
100
98
  if isinstance(v, BuildEnvironmentDatasourceDict):
101
99
  return v
102
100
  elif isinstance(v, dict):
103
- return BuildEnvironmentDatasourceDict(
104
- **{x: BuildDatasource.model_validate(y) for x, y in v.items()}
105
- )
101
+ return BuildEnvironmentDatasourceDict(**{x: y for x, y in v.items()})
106
102
  raise ValueError
107
103
 
108
104
 
@@ -225,6 +225,18 @@ class StructType(BaseModel):
225
225
  fields: Sequence[StructComponent | TYPEDEF_TYPES]
226
226
  fields_map: Dict[str, DataTyped | int | float | str | StructComponent]
227
227
 
228
+ def __repr__(self):
229
+ return "struct<{}>".format(
230
+ ", ".join(
231
+ f"{field.name}:{field.type.name}"
232
+ for field in self.fields
233
+ if isinstance(field, StructComponent)
234
+ )
235
+ )
236
+
237
+ def __str__(self) -> str:
238
+ return self.__repr__()
239
+
228
240
  @field_validator("fields", mode="plain")
229
241
  def validate_type(cls, v):
230
242
  final = []
@@ -859,7 +859,7 @@ class RecursiveCTE(CTE):
859
859
  ),
860
860
  BuildCaseElse(expr=False),
861
861
  ],
862
- output_datatype=DataType.BOOL,
862
+ output_data_type=DataType.BOOL,
863
863
  output_purpose=Purpose.KEY,
864
864
  ),
865
865
  )
@@ -884,7 +884,7 @@ class RecursiveCTE(CTE):
884
884
  ),
885
885
  BuildCaseElse(expr=False),
886
886
  ],
887
- output_datatype=DataType.BOOL,
887
+ output_data_type=DataType.BOOL,
888
888
  output_purpose=Purpose.KEY,
889
889
  ),
890
890
  )
@@ -909,7 +909,7 @@ class RecursiveCTE(CTE):
909
909
  ),
910
910
  BuildCaseElse(expr=right_recurse_concept),
911
911
  ],
912
- output_datatype=recursive_derived.datatype,
912
+ output_data_type=recursive_derived.datatype,
913
913
  output_purpose=recursive_derived.purpose,
914
914
  ),
915
915
  )
@@ -61,13 +61,13 @@ def gen_group_node(
61
61
 
62
62
  # if the aggregation has a grain, we need to ensure these are the ONLY optional in the output of the select
63
63
  output_concepts = [concept]
64
-
64
+ grain_components = [environment.concepts[c] for c in concept.grain.components]
65
65
  if (
66
66
  concept.grain
67
67
  and len(concept.grain.components) > 0
68
68
  and not concept.grain.abstract
69
69
  ):
70
- grain_components = [environment.concepts[c] for c in concept.grain.components]
70
+
71
71
  parent_concepts += grain_components
72
72
  build_grain_parents = get_aggregate_grain(concept, environment)
73
73
  output_concepts += grain_components
@@ -131,10 +131,6 @@ def gen_group_node(
131
131
  else:
132
132
  parents = []
133
133
 
134
- # the keys we group by
135
- # are what we can use for enrichment
136
- group_key_parents = [environment.concepts[c] for c in concept.grain.components]
137
-
138
134
  group_node = GroupNode(
139
135
  output_concepts=output_concepts,
140
136
  input_concepts=parent_concepts,
@@ -164,7 +160,7 @@ def gen_group_node(
164
160
  )
165
161
  return gen_enrichment_node(
166
162
  group_node,
167
- join_keys=group_key_parents,
163
+ join_keys=grain_components,
168
164
  local_optional=local_optional,
169
165
  environment=environment,
170
166
  g=g,
@@ -453,6 +453,7 @@ def gen_merge_node(
453
453
  else:
454
454
  all_search_concepts = all_concepts
455
455
  all_search_concepts = sorted(all_search_concepts, key=lambda x: x.address)
456
+ break_set = set([x.address for x in all_search_concepts])
456
457
  for filter_downstream in [True, False]:
457
458
  weak_resolve = resolve_weak_components(
458
459
  all_search_concepts,
@@ -466,27 +467,28 @@ def gen_merge_node(
466
467
  logger.info(
467
468
  f"{padding(depth)}{LOGGER_PREFIX} wasn't able to resolve graph through intermediate concept injection with accept_partial {accept_partial}, filter_downstream {filter_downstream}"
468
469
  )
469
- else:
470
- log_graph = [[y.address for y in x] for x in weak_resolve]
471
- logger.info(
472
- f"{padding(depth)}{LOGGER_PREFIX} Was able to resolve graph through weak component resolution - final graph {log_graph}"
473
- )
474
- for flat in log_graph:
475
- if set(flat) == set([x.address for x in all_search_concepts]):
476
- logger.info(
477
- f"{padding(depth)}{LOGGER_PREFIX} expanded concept resolution was identical to search resolution; breaking to avoid recursion error."
478
- )
479
- return None
480
- return subgraphs_to_merge_node(
481
- weak_resolve,
482
- depth=depth,
483
- all_concepts=all_search_concepts,
484
- environment=environment,
485
- g=g,
486
- source_concepts=source_concepts,
487
- history=history,
488
- conditions=conditions,
489
- search_conditions=search_conditions,
490
- output_concepts=all_concepts,
491
- )
470
+ continue
471
+
472
+ log_graph = [[y.address for y in x] for x in weak_resolve]
473
+ logger.info(
474
+ f"{padding(depth)}{LOGGER_PREFIX} Was able to resolve graph through weak component resolution - final graph {log_graph}"
475
+ )
476
+ for flat in log_graph:
477
+ if set(flat) == break_set:
478
+ logger.info(
479
+ f"{padding(depth)}{LOGGER_PREFIX} expanded concept resolution was identical to search resolution; breaking to avoid recursion error."
480
+ )
481
+ return None
482
+ return subgraphs_to_merge_node(
483
+ weak_resolve,
484
+ depth=depth,
485
+ all_concepts=all_search_concepts,
486
+ environment=environment,
487
+ g=g,
488
+ source_concepts=source_concepts,
489
+ history=history,
490
+ conditions=conditions,
491
+ search_conditions=search_conditions,
492
+ output_concepts=all_concepts,
493
+ )
492
494
  return None