lmflow.utils.common#
Attributes#
Functions#
|
Return a string or a list of strings that can be used as shell arguments. |
|
Create a copied dataclass with new field names and default values. |
|
Remove the prefix from the attribute names of a dataclass instance. |
|
Add the prefix to the attribute names of a dataclass instance. |
|
Module Contents#
- lmflow.utils.common.make_shell_args_from_dataclass(dataclass_objects: List, format: str = 'subprocess', skip_default: bool = True, ignored_args_list: List[str] | None = None) str | List[str] [source]#
Return a string or a list of strings that can be used as shell arguments.
- Parameters:
- dataclass_objectsList
A list of dataclass objects.
- formatstr, optional
Return format, can be “shell” or “subprocess”, by default “subprocess”.
- skip_defaultbool, optional
Whether to skip attributes with default values, by default True.
- Returns:
- Union[str, List[str]]
- lmflow.utils.common.create_copied_dataclass(original_dataclass, field_prefix: str, class_prefix: str, new_default: Dict = None)[source]#
Create a copied dataclass with new field names and default values.
- Parameters:
- original_dataclassdataclass
- field_prefixstr
The prefix to add to the field names of the copied dataclass.
- class_prefixstr
The prefix to add to the class name of the copied dataclass.
- new_defaultDict, optional
The new default values for the copied dataclass. When None, the default values of the original dataclass are used.
- Returns:
- dataclass
- lmflow.utils.common.remove_dataclass_attr_prefix(data_instance, prefix: str) Dict [source]#
Remove the prefix from the attribute names of a dataclass instance.
- Parameters:
- data_instancedataclass
- prefixstr
The prefix to remove from the attribute names of the dataclass instance.
- Returns:
- Dict