lmflow.utils.common#

Attributes#

Functions#

make_shell_args_from_dataclass(→ Union[str, list[str]])

Return a string or a list of strings that can be used as shell arguments.

create_copied_dataclass(original_dataclass, ...[, ...])

Create a copied dataclass with new field names and default values.

remove_dataclass_attr_prefix(→ dict)

Remove the prefix from the attribute names of a dataclass instance.

add_dataclass_attr_prefix(→ dict)

Add the prefix to the attribute names of a dataclass instance.

print_banner(message)

Module Contents#

lmflow.utils.common.logger[source]#
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_objects (list) – A list of dataclass objects.

  • format (str, optional) – Return format, can be “shell” or “subprocess”, by default “subprocess”.

  • skip_default (bool, optional) – Whether to skip attributes with default values, by default True.

Return type:

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_dataclass (dataclass)

  • field_prefix (str) – The prefix to add to the field names of the copied dataclass.

  • class_prefix (str) – The prefix to add to the class name of the copied dataclass.

  • new_default (dict, optional) – The new default values for the copied dataclass. When None, the default values of the original dataclass are used.

Return type:

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_instance (dataclass)

  • prefix (str) – The prefix to remove from the attribute names of the dataclass instance.

Return type:

dict

lmflow.utils.common.add_dataclass_attr_prefix(data_instance, prefix: str) dict[source]#

Add the prefix to the attribute names of a dataclass instance.

Parameters:
  • data_instance (dataclass)

  • prefix (str) – The prefix to add to the attribute names of the dataclass instance.

Return type:

dict

lmflow.utils.common.print_banner(message: str)[source]#