cli
openml.cli
#
Command Line Interface for openml
to configure its settings.
configure
#
Calls the right submenu(s) to edit args.field
in the configuration file.
Source code in openml/cli.py
configure_field
#
configure_field(field: str, value: None | str, check_with_message: Callable[[str], str], intro_message: str, input_message: str, sanitize: Callable[[str], str] | None = None) -> None
Configure field
with value
. If value
is None ask the user for input.
value
and user input are first corrected/auto-completed with convert_value
if provided,
then validated with check_with_message
function.
If the user input a wrong value in interactive mode, the user gets to input a new value.
The new valid value is saved in the openml configuration file.
In case an invalid value
is supplied directly (non-interactive), no changes are made.
Parameters#
field: str
Field to set.
value: str, None
Value to field to. If None
will ask user for input.
check_with_message: Callable[[str], str]
Function which validates value
or user input, and returns either an error message if it
is invalid, or a False-like value if value
is valid.
intro_message: str
Message that is printed once if user input is requested (e.g. instructions).
input_message: str
Message that comes with the input prompt.
sanitize: Union[Callable[[str], str], None]
A function to convert user input to 'more acceptable' input, e.g. for auto-complete.
If no correction of user input is possible, return the original value.
If no function is provided, don't attempt to correct/auto-complete input.
Source code in openml/cli.py
wait_until_valid_input
#
wait_until_valid_input(prompt: str, check: Callable[[str], str], sanitize: Callable[[str], str] | None) -> str
Asks prompt
until an input is received which returns True for check
.
Parameters#
prompt: str message to display check: Callable[[str], str] function to call with the given input, that provides an error message if the input is not valid otherwise, and False-like otherwise. sanitize: Callable[[str], str], optional A function which attempts to sanitize the user input (e.g. auto-complete).
Returns#
valid input