def __init__(self, manager_addr, manager_port, study_id, worker_id): self.logger = getLogger(__name__) handler = StreamHandler() handler.setLevel(INFO) self.logger.setLevel(INFO) self.logger.addHandler(handler) self.logger.propagate = False self.manager_addr = manager_addr self.study_id = study_id self.worker_id = worker_id channel = grpc.beta.implementations.insecure_channel(self.manager_addr, manager_port) with api_pb2.beta_create_Manager_stub(channel) as client: gsrep = client.GetStudy(api_pb2.GetStudyRequest(study_id=study_id), 10) self.metrics = gsrep.study_config.metrics self.parser = TFEventFileParser()
if __name__ == '__main__': logger = getLogger(__name__) handler = StreamHandler() handler.setLevel(INFO) logger.setLevel(INFO) logger.addHandler(handler) logger.propagate = False opt = parse_options() manager_server = opt.manager_server_addr.split(':') if len(manager_server) != 2: raise Exception("Invalid katib manager service address: %s" % opt.manager_server_addr) WaitOtherMainProcesses(completed_marked_dir=opt.dir_path) mc = MetricsCollector(opt.metric_names.split(',')) observation_log = mc.parse_file(opt.dir_path) channel = grpc.beta.implementations.insecure_channel( manager_server[0], int(manager_server[1])) with api_pb2.beta_create_Manager_stub(channel) as client: logger.info("In " + opt.trial_name + " " + str(len(observation_log.metric_logs)) + " metrics will be reported.") client.ReportObservationLog(api_pb2.ReportObservationLogRequest( trial_name=opt.trial_name, observation_log=observation_log), timeout=timeout_in_seconds)