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,
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 :
with the
client = dataikuapi.DSSClient(host, apiKey)
client._session.verify = False
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'])
above code, I am testing the TEST QUERIES on API Deployer NODE
Hi,
To use an API node, you need to create an APINodeClient instead of a DSSClient
Your code needs to be:
client = dataikuapi.APINodeClient(host, api_service_name, apiKey)
client._session.verify = False
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'])
Hi Clément_Stenac,
After adding deployer API connection code, I am getting this error at this line
prediction = client.predict_record("api_endpoint_id", record_to_predict)
ERROR:
2_deploy_dev/test_dev.py:34: 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'
CODE: Here is the first code. The first predict_record should pass and the second should fail, as in the second, one row is missing.
import dataikuapi
import sys
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'])
The error also attached