memoryscope.core.operation.base_workflow
- class memoryscope.core.operation.base_workflow.BaseWorkflow(name: str, memoryscope_context: ~memoryscope.core.utils.singleton.singleton.<locals>._singleton, workflow: str = '', **kwargs)[源代码]
基类:
object
- __init__(name: str, memoryscope_context: ~memoryscope.core.utils.singleton.singleton.<locals>._singleton, workflow: str = '', **kwargs)[源代码]
- init_workers(is_backend: bool = False, **kwargs)[源代码]
Initializes worker instances based on the configuration for each worker defined in G_CONTEXT.worker_config. Each worker can be set to run in a multithreaded mode depending on the is_backend flag or the worker's individual configuration.
- 参数:
is_backend (bool, optional) -- A flag indicating whether the workers should be initialized in a
False. (backend context. Defaults to)
**kwargs -- Additional keyword arguments to be passed during worker initialization.
- 抛出:
RuntimeError -- If a worker mentioned in self.worker_dict does not exist in G_CONTEXT.worker_config.
备注
This method modifies self.worker_dict in-place, replacing the keys with actual worker instances.
- run_workflow(**kwargs)[源代码]
Executes the workflow by orchestrating the steps defined in self.workflow_worker_list. This method supports both sequential and parallel execution of sub-workflows based on the structure of self.workflow_worker_list.
If a workflow part consists of a single item, it is executed sequentially. For parts with multiple items, they are submitted for parallel execution using a thread pool. The workflow will stop if any sub-workflow returns False.
- 参数:
**kwargs -- Additional keyword arguments to be passed to context.