TaskD Agent APIs

def init_taskd_agent(config : dict = {}, cls = None) -> bool

Function Description

The user-side code calls this function to initialize TaskD Agent.

Input Parameters

Table 1 Parameter description

ParameterTypeDescription
configdict:{str : str}Agent configuration information, including Agent configuration and network configuration. The keys include:
  • Framework: Agent framework, currently supports PyTorch and MindSpore
  • UpstreamAddr: Upstream IP address on the network side
  • UpstreamPort: Upstream port on the network side
  • ServerRank: Agent rank number
clsSpecific instance typeThis input parameter is used under the PyTorch framework and is a SimpleElasticAgent instance. It is not required for other frameworks.

Return Value

Table 2 Return value description

Return Value TypeDescription
boolIndicates whether the initialization is successful.
  • True: Initialization succeeded.
  • False: Initialization failed.

def start_taskd_agent():

Function Description

The user-side code calls this function to start TaskD Agent.

Input Parameters

None

Return Value

Table 1 Return value description

Return Value TypeDescription
VariesThe return result is determined by the main execution logic of the Agent under the framework. Agents under different frameworks will have different return results after startup. For example, under the PyTorch framework, SimpleElasticAgent run() will return the training result.

def register_func(operator, func) -> bool:

Function Description

The user-side code calls this function to register a TaskD Agent callback function.

Input Parameters

Table 1 Parameters

ParameterTypeDescription
operatorstrKey for registering the callback function, such as START_ALL_WORKER.
funccallableThe corresponding callback function.

Return Value

Table 2 Return value description

Return Value TypeDescription
boolIndicates whether the registration is successful.
  • True: Registration succeed.
  • False: Registration failed.