def respond(metrics: workload.Response) -> None: # Close the socket after the response from the TERMINATE message, in case the trial # wasn't smart enough to exit after the TERMINATE on its own. if wkld.kind == workload.Workload.Kind.TERMINATE: self.close() return # Handle skipped workloads gracefully. if isinstance(metrics, workload.Skipped): return metrics_json = util.json_encode(metrics) metrics_size = len(metrics_json) if metrics_size >= constants.MAX_METRICS_SIZE: raise AssertionError( f"Metrics size {metrics_size} exceeded max size {constants.MAX_METRICS_SIZE}." ) duration = metrics["end_time"] - metrics["start_time"] logging.info( f"Workload completed: {metrics['workload']} (duration {duration})" ) self.socket.send_text(metrics_json)
def to_delete(request: Any, config: Dict[str, Any]) -> List[Dict[str, Any]]: manager = storage.build(config["checkpoint_storage"]) metadata = [manager.store(StorableFixture()) for _ in range(request.param)] host_path = config["checkpoint_storage"]["host_path"] assert len(os.listdir(host_path)) == request.param return [simplejson.loads(util.json_encode(m)) for m in metadata]
def to_delete(request: Any, manager: storage.StorageManager) -> List[Dict[str, Any]]: metadata = [] for _ in range(request.param): with manager.store_path() as (storage_id, path): storage_util.create_checkpoint(path) metadata.append( storage.StorageMetadata(storage_id, manager._list_directory(path))) assert len(os.listdir(manager._base_path)) == request.param return [simplejson.loads(util.json_encode(m)) for m in metadata]
def respond(metrics: workload.Response) -> None: # Close the socket after the response from the TERMINATE message, in case the trial # wasn't smart enough to exit after the TERMINATE on its own. if wkld.kind == workload.Workload.Kind.TERMINATE: self.close() return # Handle skipped workloads gracefully. if isinstance(metrics, workload.Skipped): return duration = metrics["end_time"] - metrics["start_time"] logging.info(f"Workload completed: {metrics['workload']} (duration {duration})") self.socket.send_text(util.json_encode(metrics))