gt4sd.cli.argument_parser module

Argument parser for training pipelines.

Summary

Classes:

ArgumentParser

ArgumentParser inherited from hf's parser with modified dataclass arguments addition for better handling of None values.

Functions:

eval_lambda

Parse a lambda from a string safely.

none_checker

Check given argument for None.

none_checker_bool

Check given bool argument for None.

Reference

eval_lambda(val)[source]

Parse a lambda from a string safely.

Parameters

val (str) – string representing a lambda.

Return type

Callable

Returns

a callable.

Raises

ValueError – in case the lambda can not be parsed.

none_checker_bool(val)[source]

Check given bool argument for None.

Parameters

val (Union[bool, str]) – model arguments passed to the configuration.

Return type

Optional[bool, None]

Returns

Bool value or None.

Raises

ArgumentTypeError – value can not be parsed.

none_checker(val, dtype)[source]

Check given argument for None.

Parameters
  • val (Any) – model arguments passed to the configuration.

  • dtype (Type) – expected argument type.

Return type

Any

Returns

Value casted in the expected type or None.

class ArgumentParser(dataclass_types, **kwargs)[source]

Bases: HfArgumentParser

ArgumentParser inherited from hf’s parser with modified dataclass arguments addition for better handling of None values.

_add_dataclass_arguments(dtype)[source]

Add a dataclass arguments.

Parameters

dtype (DataClassType) – data class type.

Return type

None

__annotations__ = {}
__doc__ = "ArgumentParser inherited from hf's parser with modified dataclass arguments addition for better handling of None values."
__module__ = 'gt4sd.cli.argument_parser'