easydel.utils.cli_helpers#
- easydel.utils.cli_helpers.Argu(*, aliases: ~typing.Optional[~typing.Union[str, ~typing.List[str]]] = None, help: ~typing.Optional[str] = None, default: ~typing.Any = <dataclasses._MISSING_TYPE object>, default_factory: ~typing.Callable[[], ~typing.Any] = <dataclasses._MISSING_TYPE object>, metadata: ~typing.Optional[dict] = None, **kwargs) Field[source]#
- class easydel.utils.cli_helpers.DataClassArgumentParser(dataclass_types: Union[DataClassType, Iterable[DataClassType]], **kwargs: Any)[source]#
Bases:
ArgumentParserA subclass of argparse.ArgumentParser that automatically generates arguments based on dataclass type hints.
It supports additional argparse features (like sub-groups) and can also load configuration from dictionaries, JSON files, or YAML files.
- dataclass_types: Iterable[DataClassType]#
- parse_args_into_dataclasses(args: Optional[List[str]] = None, return_remaining_strings: bool = False, look_for_args_file: bool = True, args_filename: Optional[str] = None, args_file_flag: Optional[str] = None) Tuple[Any, ...][source]#
Parse command-line arguments into instances of the specified dataclass types.
Optionally, this method can also look for an external “.args” file or a command-line flag that points to one, and prepend its content to the command-line arguments.
- Raises
ValueError – If there are any unknown arguments (and return_remaining_strings is False).
- parse_dict(args: Dict[str, Any], allow_extra_keys: bool = False) Tuple[Any, ...][source]#
Parse a dictionary of configuration values into dataclass instances.
- Parameters
args – Dictionary containing configuration values.
allow_extra_keys – If False, raises an exception if unknown keys are present.