towhee.dag.base_repr.BaseRepr¶
- class towhee.dag.base_repr.BaseRepr(name: str)[source]¶
Bases:
object
Base representation from which all other representation objects inherit.
Primarily implements automatic serialization into YAML/YAML-like string formats, along with defining other universally used properties.
- Parameters:
name (str) – Name of the internal object described by this representation.
Methods
inject_template
Check if the src is a valid YAML file to describe a component in Towhee.
Load the representation(s) information from a local YAML file.
Load the information for the representation.
Load the representation(s) information from a YAML file (pre-loaded as string).
Load the representation information from a remote YAML file.
render_template
Attributes
name
- static is_valid(info: Dict[str, Any], essentials: Set[str]) bool [source]¶
Check if the src is a valid YAML file to describe a component in Towhee.
- Parameters:
info (Dict[str, Any]) – The dict loaded from the source file.
essentials (Set[str]) – The essential keys that a valid YAML file should contain.
- Returns:
- (bool)
Return True if the src file is a valid YAML file to describe a component in Towhee, else False.
- static load_file(file: str) dict [source]¶
Load the representation(s) information from a local YAML file.
- Parameters:
file (str) – The file path.
- Returns:
- (dict)
The dict loaded from the YAML file that contains the representation information.
- static load_src(file_or_src: str) dict [source]¶
Load the information for the representation. We support file from local file/HTTP/HDFS.
- Parameters:
file_or_src (str) – The source YAML file or the URL points to the source file or a str loaded from source file.
- Returns:
- (dict)
The YAML file loaded as dict.