def predict(addr, model_name, input_lin, batch=False): url = "http://%s/%s/predict" % (addr, model_name) if batch: req_json = json.dumps({'input_batch': [[x.val for x in input_lin]]}) else: req_json = json.dumps({'input': [input_lin.val]}) headers = {'Content-type': 'application/json'} r = requests.post(url, headers=headers, data=req_json) input_lin.make_prediction() return Lineage.add_node(input_lin, model_name, json.loads(r.text)["output"][0])
def predict(addr, model_name, input_lin, batch=False): url = "http://%s/%s/predict" % (addr, model_name) if batch: req_json = json.dumps({'input_batch': [[x.val for x in input_lin]]}) else: req_json = json.dumps({'input': [input_lin.val]}) headers = {'Content-type': 'application/json'} r = requests.post(url, headers=headers, data=req_json) # print(json.loads(r.text)) str_r = json.loads(r.text)["output"].replace("[", "").replace("]", "").split() vals = [float(i) for i in str_r] new_lineage_objs = [ Lineage.add_node(input_lin[i], model_name, vals[i]) for i in range(len(input_lin)) ] return new_lineage_objs