Deploying Python functions (Watson Machine Learning)

This topic describes how to deploy Python functions.

You can deploy Python functions in Watson Machine Learning the same way that you can deploy models. Your tools and apps can use the Watson Machine Learning Python client or REST API to send data to your deployed functions the same way that they send data to deployed models. Deploying functions gives you the ability to hide details (such as credentials), preprocess data before passing it to models, perform error handling, and include calls to multiple models, all within the deployed function instead of in your application.

Sample notebooks for creating and deploying Python functions

Refer to Using Watson Machine Learning in a notebook for links to sample notebooks that demonstrate creating and deploying a Python function using the Watson Machine Learning Python client library.

The notebooks demonstrate the six steps for creating and deploying a function:

  1. Define the function.
  2. Authenticate and define a space.
  3. Store the function in the repository.
  4. Get the software specification.
  5. Deploy the stored function.
  6. Send data to the function for processing.

Increasing scalability for a function

When you deploy a function from a deployment space or programmatically, a single copy of the function is deployed by default. To increase scalability, you can increase the number of replicas by editing the configuration of the deployment. Additional replicas allow for a larger volume of scoring requests.

The following example uses the Python client API to set the number of replicas to 3.

change_meta = {
                client.deployments.ConfigurationMetaNames.HARDWARE_SPEC: {
                                       "name":"S", 
                                       "num_nodes":3}
            }

client.deployments.update(<deployment_id>, change_meta)

Learn more

Parent topic: Deploying assets