Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 def RevokeToken(self, request, context):
     self.db.revoke_token(request.token)
     return service_pb2.SimpleReply(status=True)
Ejemplo n.º 7
0
 def CreateNamespace(self, request, context):
     self.db.grant_permission(request.token, request.namespace)
     return service_pb2.SimpleReply(status=True)