towhee.dag.variable_repr.VariableRepr¶
- class towhee.dag.variable_repr.VariableRepr(name: str, vtype: str, identifier: Optional[str] = None)[source]¶
Bases:
BaseRepr
The representation of a variable at compile-phase.
- Parameters:
name (str) – The representation name.
vtype (str) – This can be one of many possible variable types, such as a numpy array or PyTorch tensor.
dtype (str) – A string or instance of numpy.dtype indicating the internal data type for this variable.
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
vtype
- static is_valid(info: Dict[str, Any], essentials: Set[str]) bool ¶
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 ¶
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 ¶
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.
- static load_str(string: str) dict ¶
Load the representation(s) information from a YAML file (pre-loaded as string).
- Parameters:
string (str) – The string pre-loaded from a YAML.
- Returns:
- (dict)
The dict loaded from the YAML file that contains the representation information.
- static load_url(url: str) dict ¶
Load the representation information from a remote YAML file.
- Parameters:
url (str) – The url points to the remote YAML file.
- Returns:
- (dict)
The dict loaded from the YAML file that contains the representation information.