- Create a project to encapsulate all of the components necessary to use or run your model.
- Deploy the project with the
rest_api
command (shown in Step 4 below) to build the software dependencies—all of the libraries required for it to run—and encapsulate them so they are completely self-contained. - Share the deployment, or the URL of the endpoint, and generate a unique token so that they can connect to the deployment and use it from within notebooks, APIs or other applications.
Using the API wrapper
As an alternative to using the REST API wrapper provided with Anaconda Enterprise, you can construct an API endpoint using any web framework and serve the endpoint on port8086
within your deployment, to make it available as a secure REST API endpoint in Anaconda Enterprise.
Follow this process to wrap your code with an API:
-
Open the Jupyter Notebook and add this code to be able to handle HTTP requests. Define a global REQUEST JSON string that will be replaced on each invocation of the API.
-
Import the Anaconda Enterprise
publish
function. -
Add the deployment command and an appropriate environment variable to the
anaconda-project.yml
file: -
Ensure the
anaconda-enterprise
channel is listed underchannels:
and theanaconda-enterprise-web-publisher
package is listed underpackages:
. For example: -
Use the following command to test the API within your notebook session (without deploying it):
-
Now if you visit
http://localhost:8888/{function}
from within a notebook session you will see the results of your function. From within a notebook session, execute the following command: - Click the Deploy icon in the toolbar to deploy the project as an API. This deploys the notebook as an API which you can then query.
-
To query externally, create a token and find the url to the running project.
Example using
curl
:The-L
option tells curl to follow redirects. The-H
adds a header. In this case-H
adds the token required to authorize the client to visit that URL. If you deploy the project as described above you can add the-X POST
option tocurl
to access that function.