I am facing problem with delaying response time in generating data frm my local host server. (display
the data in Anvil web page).
I fire some parameters from client (Anvil) and submit to my server (Jupyter notebook), it will generate
5 data and send them back.
At the client side, however, I need to wait some times to get the 5 data from server. (response time a bit slow).
Any way to speed up the data displaying time?
This is my client side code.
if self.drop_down_3.selected_value =="abc":
param_text = str(self.drop_down_4.selected_value) + ',' + str(self.drop_down_5.selected_value) + ',' + str(self.text_box_5.text)
preds_data1=anvil.server.call('predictABC',param_text)
preds_data2=anvil.server.call('predictABC',param_text)
preds_data3=anvil.server.call('predictABC',param_text)
preds_data4=anvil.server.call('predictABC',param_text)
preds_data5=anvil.server.call('predictABC',param_text)
if preds_data1:
self.text_area_1.visible = True
self.text_area_1.text = preds_data1
if preds_data2:
self.text_area_2.visible = True
self.text_area_2.text = preds_data2
if preds_data3:
self.text_area_3.visible = True
self.text_area_3.text = preds_data3
if preds_data4:
self.text_area_4.visible = True
self.text_area_4.text = preds_data4
if preds_data5:
self.text_area_5.visible = True
self.text_area_5.text = preds_data5
Server side code that send the 5 data back to Anvil:
preds = model.predict([query])
for pred in preds[0]:
return(str(pred))
Server calls have a communications overhead, so you never want to make multiple server calls when one would do. Combine your server calls into a single call, and return a dictionary or list of results.
Thanks for reply.
My return result frm notebook to Anvil is is 5 different data.
If I use a single server call: (preds_data1=anvil.server.call(‘predictABC’,param_text)), how should I separate the 5 data into different text_area?
Currently result returned one by one (that’s why slow).
The AnVIL is cloud computing resource developed in part by the National Human Genome Research Institute. The AnVIL package provides end-user and developer functionality.
Okay, looks like you are returning a list which contains another list containing the sentences.
So, before calling the re.split(), you need to do this
preds_data=preds_data[0]
Edit: I realized that the re.split() method may be unnecessary since you already maybe returning separate sentences. So just try this and let me know the results.