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,
Once please help on this. I get this error for DSS client. Thanks in Advance.
2_deploy_dev/test_dev.py:37: in <module> prediction = client_dep.predict_record(api_endpoint_id, record_to_predict) E AttributeError: 'DSSClient' object has no attribute 'predict_record'
at this line
prediction = client_dep.predict_record(api_endpoint_id, record_to_predict)
Code here:
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_dep = dataikuapi.DSSClient(host,apiKey)
client_dep._session.verify = False
record_to_predict = {
"XXXXXXXCOUNTRY": "XXX",
"XXXXXXXXXXXX": XXXX,
"FXXXXXXXXXX": "XXX",
"XXXXXXXXXXXXXXXXXX": "XXXXXXXXXXXXXK",
"XXXXXXXXXXXX": XXXXX,
"XXXXXXXXXXAG": "X",
"XXXXXXXXXXXXr": "1XXXXXXX",
"cXXXXXXX": "XX",
"LXXXXXXde": "XXXXXM",
"HXXXXXX": "9XXXXXX"
}
prediction = client_dep.predict_record(api_endpoint_id, record_to_predict)
assert prediction['result']['prediction'] == '1', "Prediction should be 1 but is {}".format(prediction['result']['prediction'])
Hello @shajay12,
As your are requesting an API Node, you need to use an APINodeClient instead of a DSSClient:
client = dataikuapi.APINodeClient(uri, service_id, api_key)
See https://doc.dataiku.com/dss/latest/apinode/api/user-api.html for more details.
Hope this helps
Hi Louisplt,
I used the APINodeClient, but it gives this error.
2_deploy_dev/test_dev.py:39: in <module> prediction = client_dep.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.XXXX.com:11000//--api=o1pz4GQUPGD1vE8YqoOq8wuUd0824xzs/predict...
Hello @shajay12
Could you please share the code you used to call APINodeClient.predict_record?
Hi louisplt, Thanks for the reply and help.
here is the code.
import dataikuapi
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_dep = dataikuapi.APINodeClient(host,api_service_id,apiKey)
client_dep._session.verify = False
record_to_predict = {
"XXXX-XXXX-XXX": "XXX",
"XXXXXXXXXXXX": 1XXXXX,
"XXXXXXXXXXXXXXXXYPE": "XXXXXX",
"XXXXXXXXXX-1": "XXXXXXXXXK",
"XXXXXXXXXXXXXXXE": XXXXX,
"XXXXXXXXXXXXXXG": "X",
"XXXXXXXXXXX": "xxxxxx",
"xxxxxxxxxxxx": "xxx",
"xxxxxxxxxxxx": "xxxxxxxx",
"xxxxxxxxxxxxxxx": "xxxxxxxxxxxxx"
}
prediction = client_dep.predict_record(api_endpoint_id, record_to_predict)
assert prediction['result']
['prediction'] == '1', "Prediction should be 1 but is {}".format(prediction['result']['prediction'])
also here is the YAML code that is calling the above Python script in Azure pipeline.
python3 -m pytest 2_deploy_dev/test_dev.py -o junit_family=xunit1 --host='${{ parameters.DEPLOYER_URL }}' --api='${{ parameters.DEPLOYER_API_KEY }}' --api_service_id='${{ parameters.API_SERVICE_ID }}' --api_endpoint_id='${{ parameters.API_ENDPOINT_ID }}' --api_dev_infra_id='${{ parameters.API_DEV_INFRA_ID }}' --junitxml=reports/DEV_TEST.xml
error message.
2_deploy_dev/test_dev.py:39: in <module> prediction = client_dep.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=o1pz4GQUPGD1vE8YqoOq8wuUd0824xzs/predic...
@louisplt wrote:Hello @shajay12,
As your are requesting an API Node, you need to use an APINodeClient instead of a DSSClient:
client = dataikuapi.APINodeClient(uri, service_id, api_key)
See https://doc.dataiku.com/dss/latest/apinode/api/user-api. for more details.
Hope this helps
Ein Metall-Gartenzaun ist eine robuste und pflegeleichte Lösung, um Ihren Garten zu begrenzen. Die Montage eines Zauns aus Metall von den Zaun-Experten bietet eine sinnvolle Möglichkeit, Kinder und Haustiere im Garten zu sichern. Die passenden Pflanzkübel kaufen sie für Ihren Garten und Terrasse bei https://www.pflanzkuebel7.de/.
Definitiv empfhelenswerte Experten für Zäune und Pflanzkübel!
Thanks. This worked for me!
Hi Kurt,
Thanks for your reply and help. Once check the code that I have replied to in the previous post.
Could you please tell me the value of these variables 'apinodes' and 'url' in this link
Though I took code from this link https://knowledge.dataiku.com/latest/kb/o16n/ci-cd/cicd-with-api-deployer.html
in the above link, I was not able to find the value of 'apinodes' and 'url' variables, so I had made changes to the code. But the changed code also did not work.
Below is the code in the above link
def build_apinode_client(params):
client_design = dataikuapi.DSSClient(params["host"], params["api"])
api_deployer = client_design.get_apideployer()
api_url = api_deployer.get_infra(params["api_dev_infra_id"]).get_settings().get_raw()['apiNodes'][0]['url']
return dataikuapi.APINodeClient(api_url, params["api_service_id"])
I have used APINodeClient code also,
but it gives the same error.
client_dep = dataikuapi.APINodeClient(host,api_service_id,apiKey)
client_dep._session.verify = False
record_to_predict = {
"XXXXXXXCOUNTRY": "XXX",
"XXXXXXXXXXXX": XXXX,
"FXXXXXXXXXX": "XXX",
"XXXXXXXXXXXXXXXXXX": "XXXXXXXXXXXXXK",
"XXXXXXXXXXXX": XXXXX,
"XXXXXXXXXXAG": "X",
"XXXXXXXXXXXXr": "1XXXXXXX",
"cXXXXXXX": "XX",
"LXXXXXXde": "XXXXXM",
"HXXXXXX": "9XXXXXX"
}
prediction = client_dep.predict_record(api_endpoint_id, record_to_predict)
assert prediction['result']['prediction'] == '1', "Prediction should be 1 but is {}".format(prediction['result']['prediction'])