TimeloopFE
Loading...
Searching...
No Matches
timeloopfe.common.base_specification.BaseSpecification Class Reference

Base class for specifications in the Timeloop framework. More...

Inheritance diagram for timeloopfe.common.base_specification.BaseSpecification:
Collaboration diagram for timeloopfe.common.base_specification.BaseSpecification:

Public Member Functions

 declare_attrs (cls, *args, **kwargs)
 Initialize the attributes of this node.
 
 declare_attrs (cls, *args, **kwargs)
 Initialize the attributes of this node.
 
 __init__ (self, *args, **kwargs)
 
 needs_processing (self, Optional[List["Processor"]] with_processors=None, Optional[List["Processor"]] to_run=None, bool pre_parse=False)
 
 process (self, Union["Processor", List["Processor"]] with_processors=None, bool check_types=False, bool check_types_ignore_empty=True, bool reprocess=True)
 Process the specification with the given processors.
 
"Specification" from_yaml_files (cls, *args, **kwargs)
 Create a Specification object from YAML files.
 
 parse_expressions (self, Optional[Dict[str, Any]] symbol_table=None, Optional[set] parsed_ids=None)
 Parse expressions in the specification.
 
- Public Member Functions inherited from timeloopfe.common.nodes.DictNode
 require_one_of (cls, *args)
 Require that at least one of the given keys is present.
 
 require_all_or_none_of (cls, *args)
 Require that all or none of the given keys are present.
 
"DictNode" combine (self, "DictNode" other)
 Combines this dictionary with another dictionary.
 
Any __getitem__ (self, Any __key)
 Get the value at the given key or index.
 
None __setitem__ (self, Any __key, Any __value)
 Set the value at the given key or index.
 
Any get (self, Any __key, Any __default=None)
 Gets a key from the dictionary.
 
Any setdefault (self, Any __key, Any __default=None)
 Sets the default value for a key.
 
Any pop (self, Any __key, Any __default=None)
 Pops a key from the dictionary.
 
None check_unrecognized (self, *args, **kwargs)
 Check for unrecognized keys in this node and all subnodes.
 
 __getattr__ (self, name)
 Index into the attributes or the contents of this node.
 
 __setattr__ (self, name, value)
 
- Public Member Functions inherited from timeloopfe.common.nodes.Node
 get_specifiers_from_processors (cls, "BaseSpecification" spec)
 Get the specifiers that have been set from processors.
 
 reset_specifiers_from_processors (cls, Optional[Type] processor=None)
 Reset the specifiers that have been set from processors.
 
 reset_processor_elems (cls, Optional[Type] processor=None)
 
 recognize_all (cls, bool recognize_all=True)
 Set whether all attributes under this node should be recognized.
 
str get_tag (self)
 Get the tag of this node.
 
Iterable[Tuple[Union[str, int], Any]] items (self)
 Get iterable of (key, value) or (index, value) pairs.
 
T combine_index (self, Union[str, int] key, T value)
 Combine the value at the given key with the given value.
 
str get_name (self, Union[Set, None] seen=None)
 Get the name of this node.
 
Any recursive_apply (self, callable func, bool self_first=False, set applied_to=None)
 Apply a function to this node and all subnodes.
 
 clean_empties (self)
 Remove empty nodes from this node and all subnodes.
 
bool isempty (self)
 Return True if this node is empty.
 
bool isempty_recursive (self)
 Return True if this node or all subnodes are empty.
 
 add_attr (cls, str key_or_tag, Optional[Union[type, Tuple[type,...], Tuple[None,...], Tuple[str,...], None]] required_type=None, Any default=default_unspecified_, Optional[Callable] callfunc=None, Optional[bool] part_name_match=None, Optional[bool] no_change_key=None, Any _processor_responsible_for_removing=None, Optional[Dict[str, TypeSpecifier]] _add_checker_to=None)
 Initialize a type specifier for this class.
 
List[Tget_nodes_of_type (self, Type[T] node_type)
 Return a list of all subnodes of a given type.
 
Callable get_setter_lambda (self, Union[str, int] keytag)
 Get a function that can be used to set a value in this node.
 
Callable get_combiner_lambda (self, Union[str, int] keytag)
 Get a function that can be used to combine a value to this node.
 
List[Tuple[Any, Callable]] get_setters_for_keytag (self, str keytag, bool recursive=True)
 Get a list of tuples of the form (value, setter) for all keys/tags in this node that match the given key/tag.
 
List[Tuple[Any, Callable]] get_combiners_for_keytag (self, str keytag, bool recursive=True)
 Get a list of tuples of the form (value, combiner) for all keys/tags in this node that match the given key/tag.
 
List[Tuple[Any, Callable]] get_setters_for_type (self, Type t, bool recursive=True)
 Get a list of tuples of the form (value, setter) for all keys/tags in this node that match the given type.
 
List[Tuple[Any, Callable]] get_combiners_for_type (self, Type t, bool recursive=True)
 Get a list of tuples of the form (value, combiner) for all keys/tags in this node that match the given type.
 
 __str__ (self)
 Return the name of this node.
 
 __format__ (self, format_spec)
 Formats the name of this node.
 
bool is_defined_non_default_non_empty (self, str key)
 Returns True if the given key is defined in this node and is not the default value and is not empty.
 
 unique_class_name (cls)
 Return a unique name for this class.
 

Public Attributes

ListNode[Processorprocessors = ProcessorListHolder(kwargs["processors"])
 
 spec = self
 
bool processors = True):
 
- Public Attributes inherited from timeloopfe.common.nodes.DictNode
 spec
 
- Public Attributes inherited from timeloopfe.common.nodes.Node
Node parent_node = None
 
"BaseSpecification" spec = Node.get_global_spec()
 
 logger = logging.getLogger(self.__class__.__name__)
 
 from_data = None
 

Protected Member Functions

 _claim_nodes (self, *args, **kwargs)
 
 _processors_declare_attrs (self, *args, **kwargs)
 
 _early_init_processors (self, List["Processor"] _required_processors, **kwargs)
 
 _process (self)
 
 _parse_timeloop_output (self, str timeloop_output_dir, str prefix)
 
- Protected Member Functions inherited from timeloopfe.common.nodes.DictNode
 _update_combine_pre_parse (self, dict other)
 
None _check_alias (self, key)
 
- Protected Member Functions inherited from timeloopfe.common.nodes.Node
Dict[str, TypeSpecifier_get_type_specifiers (cls, "BaseSpecification" spec)
 Get the type specifiers for this node.
 
 _get_all_recognized (self)
 
Dict[Union[str, int], TypeSpecifier_get_index2checker (self, Optional[List[Tuple[str, Any]]] key2elem=None)
 
 _parse_elem (self, Union[str, int] key, TypeSpecifier check, Any value_override=None)
 
 _parse_elems (self)
 
 _parse_extra_elems (self, List[Tuple[str, Any]] key2elem)
 
 _check_unrecognized (self, ignore_empty=False, ignore_should_have_been_removed_by=False)
 
 _parse_expression (self, Union[str, int] index, Dict[str, Any] symbol_table, Optional[TypeSpecifier] checker=None)
 

Protected Attributes

ListNode[Processor_required_processors
 
dict _processor_attributes = {}
 
List[Processor_processors_run = self["_processors_run"]
 
List[Processor_processors_run_pre_parse
 
bool _parsed_expressions = self["_parsed_expressions"]
 
- Protected Attributes inherited from timeloopfe.common.nodes.DictNode
 _require_one_of = _require_one_of
 
 _require_all_or_none_of = _require_all_or_none_of
 
- Protected Attributes inherited from timeloopfe.common.nodes.Node
tuple _init_args = (args, kwargs)
 
bool _default_parse = False
 

Additional Inherited Members

- Static Public Member Functions inherited from timeloopfe.common.nodes.Node
"BaseSpecification" get_global_spec ()
 Get the global specification object.
 
 set_global_spec ("BaseSpecification" spec)
 Set the global specification object.
 
Any try_combine (Any a, Any b, Union["Node", None] innonde=None, Union[int, str, None] index=None)
 Try to combine two values.
 
- Static Protected Member Functions inherited from timeloopfe.common.nodes.Node
str _get_tag (x)
 

Detailed Description

Base class for specifications in the Timeloop framework.

Attributes: processors (ListNode): List of processors associated with the specification. _required_processors (ListNode): List of required processors. _parsed_expressions (bool): Flag indicating whether expressions have been parsed. _processors_run (List[Processor]): List of processors that have been run.

Constructor & Destructor Documentation

◆ __init__()

timeloopfe.common.base_specification.BaseSpecification.__init__ ( self,
* args,
** kwargs )

Member Function Documentation

◆ _claim_nodes()

timeloopfe.common.base_specification.BaseSpecification._claim_nodes ( self,
* args,
** kwargs )
protected

◆ _early_init_processors()

timeloopfe.common.base_specification.BaseSpecification._early_init_processors ( self,
List["Processor"] _required_processors,
** kwargs )
protected

◆ _parse_timeloop_output()

timeloopfe.common.base_specification.BaseSpecification._parse_timeloop_output ( self,
str timeloop_output_dir,
str prefix )
protected

◆ _process()

timeloopfe.common.base_specification.BaseSpecification._process ( self)
protected

◆ _processors_declare_attrs()

timeloopfe.common.base_specification.BaseSpecification._processors_declare_attrs ( self,
* args,
** kwargs )
protected

◆ declare_attrs() [1/2]

timeloopfe.common.base_specification.BaseSpecification.declare_attrs ( cls,
* args,
** kwargs )

Initialize the attributes of this node.

Reimplemented from timeloopfe.common.nodes.Node.

Reimplemented in timeloopfe.v4.specification.Specification.

◆ declare_attrs() [2/2]

timeloopfe.common.base_specification.BaseSpecification.declare_attrs ( cls,
* args,
** kwargs )

Initialize the attributes of this node.

Reimplemented from timeloopfe.common.nodes.Node.

Reimplemented in timeloopfe.v4.specification.Specification.

◆ from_yaml_files()

"Specification" timeloopfe.common.base_specification.BaseSpecification.from_yaml_files ( cls,
* args,
** kwargs )

Create a Specification object from YAML files.

Args: *args: YAML file paths. jinja_parse_data: Dictionary of data to be used for Jinja parsing.

Returns: Specification: The created Specification object.

Reimplemented from timeloopfe.common.nodes.DictNode.

◆ needs_processing()

timeloopfe.common.base_specification.BaseSpecification.needs_processing ( self,
Optional[List["Processor"]] with_processors = None,
Optional[List["Processor"]] to_run = None,
bool pre_parse = False )

◆ parse_expressions()

timeloopfe.common.base_specification.BaseSpecification.parse_expressions ( self,
Optional[Dict[str, Any]] symbol_table = None,
Optional[set] parsed_ids = None )

Parse expressions in the specification.

Args: symbol_table (Optional[Dict[str, Any]], optional): Symbol table to be used for parsing. Defaults to None. parsed_ids (Optional[set], optional): Set of IDs of specifications that have already been parsed. Defaults to None.

Reimplemented from timeloopfe.common.nodes.Node.

Reimplemented in timeloopfe.v4.specification.Specification.

◆ process()

timeloopfe.common.base_specification.BaseSpecification.process ( self,
Union["Processor", List["Processor"]] with_processors = None,
bool check_types = False,
bool check_types_ignore_empty = True,
bool reprocess = True )

Process the specification with the given processors.

Args: with_processors (Union[Processor, List[Processor]], optional): Processors to be used for processing the specification. Defaults to None. check_types (bool, optional): Flag indicating whether to check for unrecognized types. Defaults to False. check_types_ignore_empty (bool, optional): Flag indicating whether to ignore empty types during type checking. Defaults to True. reprocess (bool, optional): Flag indicating whether to reprocess the specification even if it has been processed before. Defaults to True.

Member Data Documentation

◆ _parsed_expressions

bool timeloopfe.common.base_specification.BaseSpecification._parsed_expressions = self["_parsed_expressions"]
protected

◆ _processor_attributes

dict timeloopfe.common.base_specification.BaseSpecification._processor_attributes = {}
protected

◆ _processors_run

List[Processor] timeloopfe.common.base_specification.BaseSpecification._processors_run = self["_processors_run"]
protected

◆ _processors_run_pre_parse

List[Processor] timeloopfe.common.base_specification.BaseSpecification._processors_run_pre_parse
protected
Initial value:
= self[
"_processors_run_pre_parse"
]

◆ _required_processors

ListNode[Processor] timeloopfe.common.base_specification.BaseSpecification._required_processors
protected

◆ processors [1/2]

ListNode[Processor] timeloopfe.common.base_specification.BaseSpecification.processors = ProcessorListHolder(kwargs["processors"])

◆ processors [2/2]

bool timeloopfe.common.base_specification.BaseSpecification.processors = True):

◆ spec

timeloopfe.common.base_specification.BaseSpecification.spec = self

The documentation for this class was generated from the following file: