brain_pipe.parser.template_text.TemplateTextParser¶
- class TemplateTextParser¶
 Bases:
TextParser,ABCParser that can parse text with template stings.
This parser uses jinja2 to fill in templates in the text. The rendered and filled-in text is then parsed by the TextParser.
Attributes
ARGS_STRCALLABLE_STRCONFIG_STRDATALOADERS_STRDATA_FROM_STRDEFAULT_ENVIRONMENT_KWARGSEXTRA_PATHS_STRNAME_STRPARSER_STRPIPELINES_STRPOINTER_STRRUNNER_CLASS_STRRUNNER_STR- __init__()¶
 Create a new TemplateTextParser.
Methods
__init__()Create a new TemplateTextParser.
apply_config(config)Apply the configuration to the parser.
get_additional_kwargs(input_, info)Find the additional arguments that should be passed to the parser.
get_runner_from_parsed_config(parsed_config)Construct a runner from the configuration.
link_loader_to_pipeline(pipelines, loaders)Pair pipelines with their corresponding dataloaders.
parse_all(all_info)Parse all information in the text dictionary.
parse_text_to_dict(text)Parse text to a dictionary containing simple builtin types (str, int,...).
recursive_parse(text_dict)Parse the configuration.
set_additional_kwargs(kwargs)Set additional arguments for the parser.
- apply_config(config: Dict[str, Any])¶
 Apply the configuration to the parser.
- Parameters:
 config (Dict[str, Any]) – The configuration to apply.
- get_additional_kwargs(input_: Any, info: Dict[str, Any]) Dict[str, Any]¶
 Find the additional arguments that should be passed to the parser.
This function identifies additional arguments that should be passed to the parser by e.g. a CLI.
- Parameters:
 - Returns:
 A dictionary containing the names of the arguments as keys and the options (kwargs) for a (CLI) argument parser as values.
- Return type:
 Dict[str, Any]
- get_runner_from_parsed_config(parsed_config: Dict[str, Any])¶
 Construct a runner from the configuration.
- link_loader_to_pipeline(pipelines: Sequence[Tuple[str, Pipeline]], loaders: Dict[str, DataLoader])¶
 Pair pipelines with their corresponding dataloaders.
- Parameters:
 pipelines (Sequence[Tuple[str, Pipeline]]) – A dictionary containing a mapping between the name of a loader and the Pipeline object
loaders (Dict[str, DataLoader]) – A dictionary containing a mapping between the name of a loader and the DataLoader object
- Returns:
 A list of tuples containing a DataLoader and its corresponding Pipeline.
- Return type:
 List[Tuple[DataLoader, Pipeline]]
- parse_all(all_info: Dict[str, Any])¶
 Parse all information in the text dictionary.
- Parameters:
 all_info (Dict[str, Any]) – The text dictionary to parse.
- Returns:
 A runner and a list of tuples containing a Pipeline and its DataLoader.
- Return type:
 Tuple[Runner, List[Tuple[Pipeline, DataLoader]]]
- abstract parse_text_to_dict(text: str)¶
 Parse text to a dictionary containing simple builtin types (str, int,…).