def __init__(self, schema: AggregateSchema, identity: str, evaluation_context: EvaluationContext) -> None: super().__init__(schema, identity, evaluation_context) self._dimension_fields: Dict[str, Field] = { name: TypeLoader.load_item(item_schema.type)(item_schema, self._evaluation_context) for name, item_schema in self._schema.dimension_fields.items() } # Also add the dimension fields to regular fields so that they get processed by other # functions such as snapshot, restore, etc as per normal. # We don't add self._dimension_fields here as we want these fields to be separate objects. self._fields.update({ name: TypeLoader.load_item(item_schema.type)(item_schema, self._evaluation_context) for name, item_schema in self._schema.dimension_fields.items() }) self._existing_key = None
def __init__(self, schema: BaseSchemaCollection, evaluation_context: EvaluationContext) -> None: super().__init__(schema, evaluation_context) self._fields: Dict[str, Type[BaseItem]] = { name: TypeLoader.load_item(item_schema.type)(item_schema, self._evaluation_context) for name, item_schema in self._schema.nested_schema.items() }
def __init__(self, schema: TransformerSchema, identity: str) -> None: super().__init__(schema, copy(schema.schema_context.context)) # Load the nested items into the item self._aggregates: Dict[str, Aggregate] = { name: TypeLoader.load_item(item_schema.type)(item_schema, identity, self._evaluation_context) for name, item_schema in schema.nested_schema.items() } self._identity = identity self._evaluation_context.global_add('identity', self._identity) self._evaluation_context.global_context.merge(self._nested_items)
def _load_blocks(self, blocks: List[Tuple[Key, Any]]) -> List[TimeAggregate]: """ Converts [(Key, block)] to [BlockAggregate] :param blocks: List of (Key, block) blocks. :return: List of BlockAggregate """ return [ TypeLoader.load_item(self._schema.source.type)( self._schema.source, self._identity, EvaluationContext()).run_restore(block) for (_, block) in blocks ]
def __init__(self, schema: AggregateSchema, identity: str, evaluation_context: EvaluationContext) -> None: """ Initializes the data group with the inherited context and adds its own nested items into the local context for execution :param schema: Schema for initializing the data group :param evaluation_context: Context dictionary for evaluation """ super().__init__(schema, evaluation_context) self._identity = identity self._fields: Dict[str, Type[BaseItem]] = { name: TypeLoader.load_item(item_schema.type)(item_schema, self._evaluation_context) for name, item_schema in self._schema.nested_schema.items() } self._store = None if self._schema.store_schema: self._store = self._schema.schema_loader.get_store( self._schema.store_schema.fully_qualified_name)
def get_store(self, fully_qualified_name: str) -> Optional['Store']: """ Used to generate a store object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the store object needed. :return: An initialized store object """ if fully_qualified_name not in self._store_cache: schema = self.get_schema_object(fully_qualified_name) if not schema: return None if Type.is_store_type(schema.type): self._store_cache[fully_qualified_name] = TypeLoader.load_item( schema.type)(schema) else: self.add_errors( InvalidTypeError(fully_qualified_name, {}, ATTRIBUTE_TYPE, InvalidTypeError.Reason.INCORRECT_BASE, schema.type, InvalidTypeError.BaseTypes.STORE)) return self._store_cache.get(fully_qualified_name, None)