mlos_bench.services.local.temp_dir_context module¶
Helper functions to work with temp files locally on the scheduler side.
- class mlos_bench.services.local.temp_dir_context.TempDirContextService(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)¶
Bases:
Service
A base service class that provides a method to create a temporary directory context for local scripts.
It is inherited by LocalExecService and MockLocalExecService. This class is not supposed to be used as a standalone service.
- 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.
temp_dir_context
([path])Create a temp directory or use the provided path.
- temp_dir_context(path: str | None = None) TemporaryDirectory | nullcontext ¶
Create a temp directory or use the provided path.
- Parameters:
- pathstr
A path to the temporary directory. Create a new one if None.
- Returns:
- temp_dir_contextTemporaryDirectory
Temporary directory context to use in the with clause.