brain_pipe.parser.yaml.YAMLTextParser¶
- class YAMLTextParser¶
Bases:
YAMLMixin
,TextParser
Parser based on TextParser that can parse YAML text.
Attributes
ARGS_STR
CALLABLE_STR
CONFIG_STR
DATALOADERS_STR
DATA_FROM_STR
EXTRA_PATHS_STR
NAME_STR
PARSER_STR
PIPELINES_STR
POINTER_STR
RUNNER_CLASS_STR
RUNNER_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.
parse_all
(all_info)Parse all information in the text dictionary.
parse_text_to_dict
(text)Parse YAML text to a dictionary.
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]]]
- parse_text_to_dict(text)¶
Parse YAML text to a dictionary.
- 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.