Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred while communicating with the Analytics Extension #449

Closed
vipuln89 opened this issue Sep 3, 2020 · 2 comments
Closed
Labels

Comments

@vipuln89
Copy link

vipuln89 commented Sep 3, 2020

Environment information:

  • OS: Windows 7 64 bit
  • Python version: [3.8.5]
  • TabPy release: [Latest]

Describe the issue
I have a use case in which i have to use tableau to fetch the results from a REST API endpoint. The goal is to let the user enter or select latitude and longitude and pass those arguments to fetch the results (dictionary or a list - any would work) from the rest api end point.

I have implemented the function that fetches the scores and the code for that is attached in the next section. When i try doing - client.query('getscoreList', 38.482, -78.80), i get the results which confirms that the deployed .pkl is working fine. But when i try to query it from the calculation in tableau it gives me following error -

Unable to complete action
An error occurred while communicating with the Analytics Extension.
Error Code: 6116DD27
Error processing script
The endpoint you're trying to query did not respond. Please make sure the endpoint exists and the correct set of arguments are provided.

To Reproduce
The script used to deploy the function that interacts with the API is -


from tabpy_client import Client
import pandas as pd
import json
import glob
import requests
import urllib3
import time
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

client = Client("http://localhost:9004/")

def getscoreList(latitude,longitude) :

url = 'https://<private>.com:34443/physical-risk/api/v1/score/all-hazards/multi'


filename = pd.DataFrame(columns = ['latitude','longitude'])
filename['latitude'] = [latitude]
filename['longitude'] = [longitude]
headers = {'Content-type': 'application/json'}
master_df = pd.DataFrame()
scores_df = pd.DataFrame()
for i in range (len(filename)) :
    
        testfile = filename.iloc[i:i+1] 
        testjson = testfile.to_json(orient = 'records')
        testjson = json.loads(testjson)
        r = requests.post(url,json = testjson, headers = headers, verify=False)
        output = json.loads(r.content)
        a = output.get('riskScores')
        b = a[0].get('scores')
        scores_list = []
    
        for j in range(len(b)) :
        
            c = b[j].get('scenarios')
            hazard = b[j].get('hazard')

            for k in range(len(c)) :
        
                scores_df[str(hazard) + str(c[k].get('scenarioName')) + str(c[k].get('year'))] = c[k].get('score')
                scores_list.append(c[k].get('score'))
return scores_list

client.deploy('getscoreList',getscoreList,"get score list",override = True)


The script in tableau calculation is -


SCRIPT_REAL("
return tabpy.query('getscoreList',_arg1,_arg2) ['response']",[latitude],[longitude])

Expected behavior
Ideally, i expect the calculation to return a list of scores (a dictionary or a dataframe would be even better) that are being retrieved from the API end point.

If there is some other way i should be working with the REST API endpoint, i would appreciate that. On running the query -

client.query('getscoreList', 38.482, -78.80)

I get the following result -

{'response': [52.0,
44.0,
48.0,
52.0,
59.0,
50.0,
52.0,
47.0,
34.0,
7.0,
9.0,
13.0,
16.0,
9.0,
15.0,
19.0,
9.0,
18.0,
30.0,
100.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
94.0,
100.0,
100.0,
94.0,
100.0,
100.0,
94.0,
98.0,
100.0,
32.0,
32.0,
33.0,
32.0,
23.0,
19.0,
32.0,
30.0,
39.0],
'version': 1,
'model': 'getscoreList',
'uuid': '98061656-e5d2-4c86-bad7-ee38ad26dec6'}

Screenshots
Attaching screenshots of the error and the text file with the result in the command window
error log.txt
error

Additional context
Add any other context about the problem here.

@vipuln89
Copy link
Author

vipuln89 commented Sep 4, 2020

Issue resolved after i passed the parameter as the first item in the list.

@vipuln89 vipuln89 closed this as completed Sep 4, 2020
@Sahuism
Copy link

Sahuism commented Sep 25, 2020

Hi there,

I am also getting the same error on Tableau. Please help.

Unable to complete action
An error occurred while communicating with the Analytics Extension.
Error Code: 6116DD27
Error processing script
The endpoint you're trying to query did not respond. Please make sure the endpoint exists and the correct set of arguments are provided.

My deployed function works absolutely fine, however it is unable to communicate with the endpoint. Below is the code:
==========================CODE USED===========================================

Connect to TabPy server using the client library

import tabpy_client
connection = tabpy_client.Client('http://localhost:9004/')

The scoring function that will use the Catboost Classifier to classify new data points

def CandidateClassifier(_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7,_arg8,_arg9,_arg10,_arg11,_arg12,_arg13,_arg14,_arg15,
_arg16,_arg17,_arg18,_arg19,_arg20,_arg21):
import numpy as np
import pandas as pd
from catboost import CatBoostClassifier

data=[_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7,_arg8,_arg9,_arg10,_arg11,_arg12,_arg13,_arg14,_arg15,_arg16,
      _arg17,_arg18,_arg19,_arg20,_arg21]

Prediction=model_classifier.predict(data)
    
return Prediction

Publish the SuggestDiagnosis function to TabPy server so it can be used from Tableau

Using the name and a short description of what it does

connection.deploy('Hackathon',
CandidateClassifier,
'Numbers we can expect in the given settings', override=True)

connection.get_endpoints()

{'Hackathon': {'schema': None, 'last_modified_time': datetime.datetime(2020, 9, 25, 22, 12, 16), 'dependencies': [], 'creation_time': datetime.datetime(2020, 9, 25, 22, 12, 16), 'type': 'model', 'name': 'Hackathon', 'version': 1, 'description': 'Number of Candidates we can expect in the given settings'}}

#can run queries to TabPy outside Tableau as well.
connection.query('Hackathon', args**)

=============================ERROR==============================================

ResponseError Traceback (most recent call last)
in
1 #can run queries to TabPy outside Tableau as well.
----> 2 connection.query('Hackathon',**args)

C:**\tabpy_client\client.py in query(self, name, *args, **kwargs)
184 uuid : a unique id for the request.
185 """
--> 186 return self._service.query(name, *args, **kwargs)
187
188 #

C:**\tabpy_client\rest_client.py in query(self, name, *args, **kwargs)
151 return self.service_client.POST('query/'+name,
152 data={'data':args or kwargs},
--> 153 timeout=self.query_timeout)
154
155

C:\tabpy_client\rest.py in POST(self, url, data, timeout)
170 def POST(self, url, data=None, timeout=None):
171 """Prepends self.endpoint to the url and issues a POST request."""
--> 172 return self.network_wrapper.POST(self.endpoint + url, data, timeout)
173
174 def PUT(self, url, data=None, timeout=None):

C:\tabpy_client\rest.py in POST(self, url, data, timeout)
106 timeout=timeout)
107 if response.status_code not in (200, 201):
--> 108 self.raise_error(response)
109
110 return response.json()

C:\tabpy_client\rest.py in raise_error(self, response)
61 response.text)
62
---> 63 raise ResponseError(response)
64
65 def _remove_nones(self, data):

ResponseError: (500) Error querying GLS {'uri': 'Hackathon', 'error': "AttributeError : 'AttributeError' object has no attribute 'message'", 'type': 'QueryFailed'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants