brain_pipe.parser.file.FileParser¶
- class FileParser¶
 Bases:
FileLoadMixin,TextParser,ABCParser based on TextParser that can parse files instead of text.
Attributes
ARGS_STRCALLABLE_STRCONFIG_STRDATALOADERS_STRDATA_FROM_STREXTRA_PATHS_STRNAME_STRPARSER_STRPIPELINES_STRPOINTER_STRREAD_MODERUNNER_CLASS_STRRUNNER_STR- __init__()¶
 Initialize the parser.
Methods
__init__()Initialize the parser.
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.
load_file(path)Load a file into a text that can be parsed.
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(args)Set the additional arguments defined in
get_additional_kwargs().- 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,…).
- set_additional_kwargs(args: Dict[str, Any])¶
 Set the additional arguments defined in
get_additional_kwargs().- Parameters:
 args (Dict[str, Any]) – The additional arguments.
Notes
This method calls
apply_config()internally, so the additional arguments can also be specified in the dictionary itself under the parser configuration.