The component runtime provides a framework for building components for both component-initiated and client-initiated workflows. To implement a component for use with this framework:
-
Implement each measurement, query, or other action performed by the component as a subclass of
mplane.scheduler.Service. Each service is bound to a single capability. Your service must implement at least themplane.scheduler.Service.run(self, specification, check_interrupt)method. This method should run the implemented measurement or query to completion. This measurement corresponds to thespecification(an instance ofmplane.model.Specification), which itself corresponds to the capability bound to the service (an instance ofmplane.model.Capability). The method should return anmplane.model.Result. Long-running methods (with common runtimes measured in seconds or more) should periodically call the function passed ascheck_interruptand return a truncatedmplane.model.Resultwhen that function returns True. -
Implement a
servicesfunction in your module that takes a set of keyword arguments derived from the configuration file section, and returns a list of Services provided by your component. For example:
def service(**kwargs):
return [MyFirstService(kwargs['local-ip-address']),
MySecondService(kwargs['local-ip-address'])]- Create a module section in the component configuration file; for example if your module is called mplane.components.mycomponent:
[service_mycomponent]
module: mplane.components.mycomponent
local-ip-address: 10.2.3.4
- Run
mpcomto start your component. The--configargument points to the configuration file to use.