After you build a model, if you want to access the service on an instance over the Internet or a virtual private cloud (VPC), Data Science Workshop (DSW) of Platform for AI (PAI) offers the custom service access configuration feature that allows you to share the calling address with collaborating developers. They can then call the service over the Internet or VPC. This feature is intended for testing and validation during development. If you need to use it in a production environment, we recommend that you deploy the model as an EAS service.
Limits
The custom service access configuration feature is intended for the development phase. The feature allows developers to share services with collaborators for testing and validation. Take note that you cannot access the custom services on a DSW instance after you stop the DSW instance. If you want to use custom services in a production environment, we recommend that you deploy models as EAS services. Elastic Algorithm Service (EAS) services can provide comprehensive public access capabilities and support elastic scaling and service monitoring. This way, EAS services can better meet the high availability and performance requirements of a production environment. For more information, see Deploy a model.
Up to five custom services can be configured for each DSW instance. For Internet access, these services must use the same VPC and EIP.
The feature requires Internet NAT gateway and Elastic IP Address (EIP). These are two separate services and can cause extra fees. For more information, see Billing of Internet NAT gateways and Billing of EIP.
The following two types of DSW instances support custom service features:
Pay-as-you-go DSW instances that are created by using public resource groups and the Instance Type parameter of the instances does not start with ecs.ebm.
DSW instances that are created by using Lingjun resources.
Configuration methods
Method 1: Configure on the Create Instance page
Create a DSW instance and configure Network Information and Custom Services.
Authorize inbound rules for all listening ports of the selected security group. For more information, see Add a security group rule.
Configure Port Range and Authorization Object based on your actual requirements.
Method 2: Configure on the instance details page
Configure the custom services on the instance details page. The essential configurations are the same as those in Method 1: Configure on the Create Instance page.
Option 3: Configure within the DSW instance
Configure the custom services directly within the DSW instance. The essential configurations are the same as those in Method 1: Configure on the Create Instance page.
Sample test
After configuring service access, you can test the service connectivity with a simple Python application written with the Bottle framework.
In the Terminal of the DSW instance, run the following command to install the Bottle package.
pip install bottle
Create a new Python file. Copy the following code into it, then execute it.
from bottle import Bottle, run # Create an instance app = Bottle() # Define a route that returns "Hello, World" @app.route('/hello', method=['GET', 'POST']) def hello(): return 'Hello, World!' # Run the server if __name__ == '__main__': run(app, host='0.0.0.0', port=9000)
In the Access Configuration section of the instance details page, view the endpoint.
Take Access over Internet as an example, copy the endpoint and combine it into a URL
http://**.**.**.**:9000/hello
. Access the URL in a browser. When "Hello, World!" is returned, service access is configured.