Deploy a real-time API service#
You’ve successfully designed and tested an API service including a prediction endpoint. The next step is to actually deploy this API service from the Design node into a production environment!
Publish the API service on the API Deployer#
Recall that our Flow has a prediction model to classify credit card transactions as fraudulent or not. We have packaged this model as a prediction endpoint in an API service, but this service only exists on the Design node (our development environment).
Important
The remaining steps require that you are connected to the API Deployer. Dataiku Cloud users can follow instructions for adding the API node extension. Administrators of self-managed Dataiku instances should follow the reference documentation.
The next step is to publish the API service from the Design node to the API Deployer.
If not already open, navigate to More Options (…) > API Designer in the top navigation bar of the Design node. Select the fraud_detection API service.
Click Publish on Deployer.
Click OK, keeping the default version ID name (v1).
Deploy the API service to the deployment infrastructure#
We now have the API service including the prediction endpoint on the API Deployer. However, to query the endpoint, we still need to deploy the API service to an infrastructure.
If still on the Design node, from the waffle menu in the right-hand corner of the top navigation bar, click Local (or Remote) Deployer.
On the Deployer homepage, select Deploying API Services.
On the Deployments tab of the API Deployer, find the fraud_detection API service on the left, and click Deploy.
If not already selected in the dialog, choose an infrastructure for the new deployment.
Note the default Deployment ID (which takes the form
<api-service-name>-on-<infrastructure-name>
).Click Deploy.
On the Status tab of the new deployment, click Deploy once again.
You now have a prediction endpoint available to serve real-time API calls. Note the dedicated URL for this API endpoint.
Query the API endpoint#
You can now submit real queries to this service by calling the endpoint URL. The Sample code tab provides snippets for calling the API in Shell (cURL), Python, R, or Java.
Within the Status tab of the prediction endpoint, navigate to the Sample code subtab.
Copy-paste the Shell code into a terminal window.
Execute the live query, and see the prediction for this record returned in real-time.
You can also run the test queries previously defined in the API Designer of your project.
Still within the Status tab of the prediction endpoint, navigate to the Run and test subtab.
Click Run All.
Now the same queries tested in the API Designer on the Design node have been run on an API node!
Optional: Copy the deployment to another infrastructure#
Important
This section requires having a second deployment infrastructure. If you don’t have this available, you can skip to the next section on query enrichment.
When choosing an infrastructure in the previous step, you may have seen pre-configured lifecycle stages. An instance admin can modify these stages as desired, so your options may be different depending on the complexity of your organization’s deployment strategy.
Let’s imagine we have another stage of deployment infrastructure, and all tests on the first deployment infrastructure were successful. We now are ready to copy the existing deployment to a new pool of API nodes.
Still within the Status tab of the API service, click Actions > Copy this deployment at the top right.
Select a new infrastructure, keep the other default values, and click Copy.
The service is now ready to be deployed.
Click Deploy again on the page that opens up for the deployment.
Once the deployment has been updated successfully, click Deployments in the top navigation bar to see that the fraud_detection API service was deployed to the development infrastructure and then to the production infrastructure.