towhee.engine.operator_loader.OperatorLoader¶
- class towhee.engine.operator_loader.OperatorLoader(cache_path: Optional[str] = None)[source]¶
Bases:
objectWrapper class used to load operators from either local cache or a remote location.
- Parameters:
cache_path – (str) Local cache path to use. If not specified, it will default to $HOME/.towhee/operators.
Methods
instance_operatorAttempts to load an operator from cache.
load_operator_from_cacheload_operator_from_internalload_operator_from_packagesLoad operator form local path.
load_operator_from_registry- load_operator(function: str, arg: List[Any], kws: Dict[str, Any], tag: str) Operator[source]¶
Attempts to load an operator from cache. If it does not exist, looks up the operator in a remote location and downloads it to cache instead. By standard convention, the operator must be called Operator and all associated data must be contained within a single directory.
- Parameters:
function – (str) Origin and method/class name of the operator. Used to look up the proper operator in cache.
- Raises:
FileExistsError – Cannot find operator.
- load_operator_from_path(path: Union[str, Path], arg: List[Any], kws: Dict[str, Any]) Operator[source]¶
Load operator form local path. :param path: Path to the operator python file. :type path: Union[str, Path] :param args: The init args for OperatorClass. :type args: Dict[str, Any]
- Returns
- (typing.Any)
The Operator output.