def ReserveExperiment(self, request, context): if not self.check_permission(request, context): return service_pb2.SimpleReply(status=False, error='access denied') if self.db.reserve_experiment(request.namespace, request.experiment, request.duration): return service_pb2.SimpleReply(status=True) return service_pb2.SimpleReply(status=False, error='experiment exists')
def CreateExperiment(self, request, context): if not self.check_permission(request, context): return service_pb2.SimpleReply(status=False, error='access denied') exp = request.experiment ts = datetime.datetime.fromtimestamp(exp.time.seconds + exp.time.nanos / 1e9) if self.db.create_experiment(request.namespace, exp.name, exp.params, exp.metrics, ts): return service_pb2.SimpleReply(status=True) return service_pb2.SimpleReply(status=False, error='cannot add experiment')
def GetExperiments(self, request, context): if not self.check_permission(request, context): return service_pb2.SimpleReply(status=False, error='access denied') resp = service_pb2.ExperimentsReply(status=True) for name, params, metrics, ts in self.db.get_experiments( request.namespace): tspb = Timestamp() # pylint: disable=E1101 tspb.FromDatetime(ts) # pylint: disable=E1101 resp.experiments.append( service_pb2.Experiment(name=name, time=tspb, params=params, metrics=metrics)) return resp
def CheckExperiment(self, request, context): if not self.check_permission(request, context): return service_pb2.SimpleReply(status=False, error='access denied') status = self.db.check_experiment(request.namespace, request.experiment) return service_pb2.SimpleReply(status=status)
def GrantAccess(self, request, context): if not self.check_permission(request, context): return service_pb2.SimpleReply(status=False, error='access denied') self.db.grant_permission(request.other_token, request.namespace) return service_pb2.SimpleReply(status=True)
def RevokeToken(self, request, context): self.db.revoke_token(request.token) return service_pb2.SimpleReply(status=True)
def CreateNamespace(self, request, context): self.db.grant_permission(request.token, request.namespace) return service_pb2.SimpleReply(status=True)