mlos_bench.services
.Service¶
- class mlos_bench.services.Service(config: Dict[str, Any] | None = None, global_config: Dict[str, Any] | None = None, parent: Service | None = None, methods: Dict[str, Callable] | List[Callable] | None = None)¶
An abstract base of all Environment Services and used to build up mix-ins.
- Attributes:
config_loader_service
Return a config loader service.
Methods
export
()Return a dictionary of functions available in this service.
merge_methods
(ext_methods, local_methods)Merge methods from the external caller with the local ones.
new
(class_name[, config, global_config, parent])Factory method for a new service with a given config.
pprint
()Produce a human-readable string listing all public methods of the service.
register
(services)Register new mix-in services.
- __init__(config: Dict[str, Any] | None = None, global_config: Dict[str, Any] | None = None, parent: Service | None = None, methods: Dict[str, Callable] | List[Callable] | None = None)¶
Create a new service with a given config.
- Parameters:
- configdict
Free-format dictionary that contains the service configuration. It will be passed as a constructor parameter of the class specified by class_name.
- global_configdict
Free-format dictionary of global parameters.
- parentService
An optional parent service that can provide mixin functions.
- methodsUnion[Dict[str, Callable], List[Callable], None]
New methods to register with the service.
- property config_loader_service: SupportsConfigLoading¶
Return a config loader service.
- Returns:
- config_loader_serviceSupportsConfigLoading
A config loader service.
- export() Dict[str, Callable] ¶
Return a dictionary of functions available in this service.
- Returns:
- servicesdict
A dictionary of string -> function pairs.
- static merge_methods(ext_methods: Dict[str, Callable] | List[Callable] | None, local_methods: Dict[str, Callable] | List[Callable]) Dict[str, Callable] ¶
Merge methods from the external caller with the local ones.
This function is usually called by the derived class constructor just before invoking the constructor of the base class.
- classmethod new(class_name: str, config: Dict[str, Any] | None = None, global_config: Dict[str, Any] | None = None, parent: Service | None = None) Service ¶
Factory method for a new service with a given config.
- Parameters:
- class_name: str
FQN of a Python class to instantiate, e.g., “mlos_bench.services.remote.azure.AzureVMService”. Must be derived from the Service class.
- configdict
Free-format dictionary that contains the service configuration. It will be passed as a constructor parameter of the class specified by class_name.
- global_configdict
Free-format dictionary of global parameters.
- parentService
A parent service that can provide mixin functions.
- Returns:
- svcService
An instance of the Service class initialized with config.
- pprint() str ¶
Produce a human-readable string listing all public methods of the service.
- register(services: Dict[str, Callable] | List[Callable]) None ¶
Register new mix-in services.
- Parameters:
- servicesdict or list
A dictionary of string -> function pairs.