nvflare.fuel.utils.argument_utils module

class SafeArgumentParser(**kwargs)[source]

Bases: ArgumentParser

Safe version of ArgumentParser which doesn’t exit on error

error(message: string)[source]

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

parse_var(s)[source]

Parse string variable into key-value tuple.

Returns (key, value) tuple from string with equals sign with the portion before the first equals sign as the key and the rest as the value.

Parameters:

s – string to parse

Returns: Tuple of key and value

parse_vars(items)[source]

Converts a list of key value pairs into a dictionary.

Parameters:

items – list like [‘a=1’, ‘b=2’, ‘c=3’]

Returns: dictionary like {‘a’: ‘1’, ‘b’: ‘2’, ‘c’: ‘3’}

str2bool(value, raise_exc=False)[source]