def reset_execution(self, request, context):

        # We start by fetching the initial belief
        self.belief = self.pomdp.initialBelState

        self.execStep = 0

        return model_pb2.Empty()
def run():
    print("Calling HPP_Stub..")
    with grpc.insecure_channel('localhost:{}'.format(port)) as channel:
        stub = model_pb2_grpc.DatabrokerStub(channel)
        ui_request = model_pb2.Empty()
        response = stub.hppdatabroker(ui_request)

    print("Greeter client received: ")
    print(response)
    def compute_policy(self, request, context):

        # Load the pomdp class that implements all the methods to interact with the solver
        self.pomdp = JClass.POMDP(JClass.JString(self.pomdpfile))

        # This calls the POMDP-IR solver. For now, we assume the model file is hardcoded (ToDO: how to pass a user model file into it?)
        self.pomdp.solve(request.nRounds, request.numBelStates,
                         request.maxBelStates, request.episodeLength,
                         request.threshold, request.explorProb,
                         request.nIterations, request.maxAlphaSetSize,
                         JClass.JString(self.basename))

        return model_pb2.Empty()
Beispiel #4
0
def list_features(stub, idx):
    idx = myconstants.DATA_ID
    # features = stub.PullData(model_pb2.DataID(idx=idx))
    features = stub.PullData(model_pb2.Empty())
    df = pd.DataFrame()
    labels = pd.Series(dtype='object')
    try:
        data = []
        label = []
        for i, row in enumerate(features):
            data.append(row.record.split(','))
            label.append(row.label)
        columns = data[1]
        types = data[0]
        df = pd.DataFrame(data[2:], columns=columns)
        if label[1] != '':
            labels = pd.Series(label[2:], name=label[1], dtype=label[0])
        for i, c in enumerate(df.columns):
            df[c] = df[c].astype(types[i])
    except:
        print(f'Sorry, No data with ID {idx} found.')

    return df, labels
Beispiel #5
0
 def print_text(self, request, context):
     print("print_text got called with:")
     print(request.text)
     return model_pb2.Empty()
Beispiel #6
0
from random import randint
from timeit import default_timer as timer

import grpc

# import the generated classes
import model_pb2
import model_pb2_grpc

start_ch = timer()
port_addr = "localhost:8061"

# open a gRPC channel
channel = grpc.insecure_channel(port_addr)

# create a stub (client)
stub = model_pb2_grpc.POMDPIRStub(channel)

resetExecInit = model_pb2.Empty()

response = stub.reset_execution(resetExecInit)

print('Success, reset execution')

print('Done!')
 def AddEpisode(self, events, context):
     episode = model_pb2.Episode()
     episode.event.extend(events)
     self.q.put(episode)
     return model_pb2.Empty()
Beispiel #8
0
import grpc
import model_pb2
import model_pb2_grpc

port_addr = 'localhost:8061'

channel = grpc.insecure_channel(port_addr)

stub = model_pb2_grpc.IDSTextConnectorStub(channel)

response = stub.get_text(model_pb2.Empty())

print(response.text)