cli_util
SaveAction
¶
Bases: Action
A customized save action for use with argparse.
A custom save action which is used to populate a secondary variable inside of an exclusive group. Used if this file is invoked directly during argument parsing.
This class is intentionally not @traceable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
option_strings |
Sequence[str]
|
A list of command-line option strings which should be associated with this action. |
required |
dest |
str
|
The name of the attribute to hold the created object(s). |
required |
nargs |
Union[int, str, None]
|
The number of command line arguments to be consumed. |
'?'
|
**kwargs |
Dict[str, Any]
|
Pass-through keyword arguments. |
{}
|
Source code in fastestimator/fastestimator/util/cli_util.py
parse_cli_to_dictionary
¶
Convert a list of strings into a dictionary with python objects as values.
a = parse_cli_to_dictionary(["--epochs", "5", "--test", "this", "--lr", "0.74"])
# {'epochs': 5, 'test': 'this', 'lr': 0.74}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_list |
List[str]
|
A list of input strings from the cli. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
A dictionary constructed from the |
Source code in fastestimator/fastestimator/util/cli_util.py
parse_string_to_python
¶
Convert a string into a python object.
x = fe.util.parse_string_to_python("5") # 5
x = fe.util.parse_string_to_python("[5, 4, 0.3]") # [5, 4, 0.3]
x = fe.util.parse_string_to_python("{'a':5, 'b':7}") # {'a':5, 'b':7}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val |
str
|
An input string. |
required |
Returns:
Type | Description |
---|---|
Any
|
A python object version of the input string. |