Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi Everyone, Please once check this. while Testing and Running Test Queries of Deployed API with
client.predict_record(params["api_endpoint_id"], record_to_predict)
Error message here
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)
Stack traceself = <requests.packages.urllib3.connectionpool.HTTPSConnectionPool object at 0x7f9b64ac5cc0>method = 'GET'url = '//dip/publicapi/api-deployer/infras/aks-design-tier-useast2-api/settings'body = Noneheaders = {'User-Agent': 'python-requests/2.15.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/...retries = Retry(total=0, connect=None, read=False, redirect=None, status=None)redirect = False, assert_same_host = Falsetimeout = <requests.packages.urllib3.util.timeout.Timeout object at 0x7f9b64ac5e10>pool_timeout
==============
Here is the code
def test_missing_param(params):
client = build_apinode_client(params)
print("Test is using API node URL {}".format(client.base_uri))
record_to_predict = {
"DIM_VOLUME_CALC_METRIC": 1008,
"XXXXX-PACKAGING-TYPE": "01",
"XXXXX-DESCRIPTION-1": "GEOLOGICAL ROCK",
"XXXXX-COM-CUSTOMS-VALUE": 10,
"XXXXX-DANG-GOODS-FLAG": "X",
"Account_Number": "100003350",
"country": "US",
"Location_Code": "MEM",
"HS6_CODE": "901580"
}
prediction = client.predict_record(params["api_endpoint_id"], record_to_predict)
assert prediction['result']['ignored'] == True , "Request status status should be ignored = true is {}".format(prediction['result'])
assert prediction['result']['ignoreReason'] == "IGNORED_BY_MODEL" , "Reason should be IGNORED_BY_MODELbut is {}".format(prediction['result'])
Operating system used: linux
Hi shajay12,
This error indicates an issue with the SSL certificate in the environment where your API service is deployed.
As a workaround, you can add the following line after instantiating your client:
client._session.verify = False
However, please keep in mind that this is not a good long-term solution as it disable checks for all hosts. The best solution would be to fix the certificate issue on your infrastructure's end.
Best,
Harizo
Hi shajay12,
This error indicates an issue with the SSL certificate in the environment where your API service is deployed.
As a workaround, you can add the following line after instantiating your client:
client._session.verify = False
However, please keep in mind that this is not a good long-term solution as it disable checks for all hosts. The best solution would be to fix the certificate issue on your infrastructure's end.
Best,
Harizo
Thank you HorizoR for the reply, I will put this in Python code, and will inform you. Currently, there is some space issue on our Dataiku platform. Once it is solved, I will try your code. Thank you
Hi HarizoR and Everyone,
Request you to please check and help me.
Now I am getting errors on this code.
Error :
2_deploy_dev/test_dev.py:34: in <module>
prediction = client.predict_record("api_endpoint_id", "record_to_predict")
E AttributeError: 'DSSClient' object has no attribute 'predict_record'
CODE :
client = dataikuapi.DSSClient(host, apiKey)
client._session.verify = False
# client = build_apinode_client(params)
# print("Test is using API node URL {}".format(client.base_uri))
record_to_predict = {
"XXXXX-ORIG-COUNTRY": "NL",
"DIM_VOLUME_CALC_METRIC": XXX8,
"XXXXX-PACKAGING-TYPE": "X1",
"XXXXX-DESCRIPTION-1": "XXXXXXCAL XXXK",
"XXXXX-COM-CUSTOMS-VALUE": XX0,
"XXXXX-DANG-GOODS-FLAG": "X",
"Account_Number": "10000XXXX",
"country": "US",
"Location_Code": "XXM",
"HS6_CODE": "9XXXXX"
}
prediction = client.predict_record("api_endpoint_id", record_to_predict)
assert prediction['result']['prediction'] == '1', "Prediction should be 1 but is {}".format(prediction['result']['prediction'])
with above code, I am testing the TEST QUERIES on API Deployer NODE
Hi,
The predict_record() method is part of the dataikuapi.APINodeClient class, apparently in your code you have instantiated a DSSClient object which is not the same. To create the right client, you should proceed like this:
from dataikuapi import APINodeClient
api_node_client = APINodeClient(api_uri api_service)
response = api_node_client.predict_record(data)
Hope this helps!
Best,
Harizo
Hi HarizoR and Everyone,
Thanks for the help. I have made the changes as you told me. But it gives this error.
Error :
2_deploy_dev/test_dev.py:35: in <module>
prediction = client.predict_record("api_endpoint_id", record_to_predict)
/usr/local/lib/python3.6/dist-packages/dataikuapi/apinode_client.py:54: in predict_record
return self._perform_json("POST", "%s/predict" % endpoint_id, body = obj)
/usr/local/lib/python3.6/dist-packages/dataikuapi/base_client.py:41: in _perform_json
return self._perform_http(method, path, params, body, False).json()
/usr/local/lib/python3.6/dist-packages/dataikuapi/base_client.py:27: in _perform_http
auth=auth, stream = stream)
/usr/local/lib/python3.6/dist-packages/requests/sessions.py:522: in request
resp = self.send(prep, **send_kwargs)
/usr/local/lib/python3.6/dist-packages/requests/sessions.py:636: in send
adapter = self.get_adapter(url=request.url)
/usr/local/lib/python3.6/dist-packages/requests/sessions.py:727: in get_adapter
raise InvalidSchema("No connection adapters were found for '%s'" % url)
E requests.exceptions.InvalidSchema: No connection adapters were found for '-o/public/api/v1/--host=https://apideployer-01.design.dataiku.fedex.com:11000//api_endpoint_id/predict'
Attachments ()
here is the code
import dataikuapi
import sys
from dataikuapi import APINodeClient
host = sys.argv[2]
apiKey = sys.argv[3]
api_service_id = sys.argv[4]
api_endpoint_id = sys.argv[5]
api_dev_infra_id = sys.argv[6]
client = dataikuapi.APINodeClient(host, api_service_id, apiKey)
client._session.verify = False
record_to_predict = {
"XXXXX-ORIG-XXXXXXX": "XXXX",
"DIM_XXXXXXXXXXRIC": XXXX,
"XXXXX-XXXXXXXXXPE": "XX",
"XXXXX-DESCRIPTION-1": "XXXXXXXXXXCK",
"XXXXX-XXXXXXXXXXUE": 10XX,
"XXXXX-XXXXXXXXXXX": "X",
"XXXXXXXXNumber": "XXXXXXXX",
"XXXXXXX": "UXX",
"XXXXXXXXode": "XXX",
"XXXXXXX": "XXXXX0"
}
prediction = client.predict_record("api_endpoint_id", record_to_predict)
assert prediction['result']['prediction'] == '1', "Prediction should be 1 but is {}".format(prediction['result']['prediction'])
record_to_predict = {
"DIM_XXXXXXXXXXXTRIC": XXXXX,
"XXXXX-XXXXXXXXX-TYPE": "01",
"XXXXX-DXXXXXXXXON-1": "XXXXXXXXXXCK",
"XXXXX-COM-XXXXXXXX-VALUE": XXX,
"XXXXX-XXXXXXXX-XXXX": "X",
"XXXXXXXXer": "XXXXXXX50",
"coXXXXXX": "XX",
"XXXXXXXXode": "MEMXXX",
"XXXXXX": "9XXXXXX0"
}
prediction = client.predict_record("api_endpoint_id", record_to_predict)
assert prediction['result']['ignored'] == True , "Request status status should be ignored = true is {}".format(prediction['result'])
assert prediction['result']['ignoreReason'] == "IGNORED_BY_MODEL" , "Reason should be IGNORED_BY_MODELbut is {}".format(prediction['result'])