towhee.engine.operator_loader.OperatorLoader¶
- class towhee.engine.operator_loader.OperatorLoader(cache_path: Optional[str] = None)[source]¶
Bases:
object
Wrapper 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_operator
Attempts to load an operator from cache.
load_operator_from_cache
load_operator_from_internal
load_operator_from_packages
Load 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 arg: The init args for OperatorClass. :type arg: List[str, Any] :param kws: The init kwargs for OperatorClass. :type kws: Dict[str, Any]
- Returns
- (typing.Any)
The Operator output.