Choose an execution rule

A deployment is a way to run a Machine Learning pipeline in a repeatable and automated way.

For each deployment, you can configure an execution rule:

  • by endpoint (web API) : the pipeline will be executed by a call to a web API. In addition, this API will allow, if necessary, to retrieve data as input and deliver the result of the pipeline as output. Access to the API can be securely communicated to external users.

  • by periodic trigger (CRON) : rules can be configured to trigger the pipeline periodically.

Summary

  1. Deploy with execution rule: Endpoint

  2. Deploy with execution rule: Periodic

Function name

Method

Return type

Description

create_deployment

create_deployment(name, pipeline_name, execution_rule, outputs_mapping=[], inputs_mapping=[])

Dict

Function that deploys a pipeline by creating a deployment which allows a user to trigger the pipeline execution

Deploy with execution rule: Endpoint

Definition function

To create an auto-mapping deployment where all inputs and outputs are based on API calls, you can use the create_deployment function. To create a deployment with manual mapping, you can use the create_deployment function with the additional parameters inputs_mapping to specify the precise mapping between input and source.

Warning

Outputs mapping always needs to be precised. Auto-mapping is only available for inputs.

Parameters

  • deployment_name (str) – Name of endpoint chosen by the user to refer to the endpoint

  • pipeline_name (str) – Name of pipeline that will be run by the deployment / endpoint

  • execution_rule (str) - Execution rule of the deployment. Must be “endpoint” or “periodic”. For convenience, members of the enumeration DEPLOYMENT_EXECUTION_RULES could be used too.

  • description (str, optional) – Text description of usage of pipeline for user only

  • outputs_mapping (List) - List of all OutputDestination objects with information for each output mapping.

  • inputs_mapping (List, optional) - List of input mappings, to map pipeline inputs to different sources (such as constant values, endpoint inputs, data store or environment variables). See InputSource for more details. For endpoint rules, if an input of the step in the pipeline is not explicitly mapped, it will be automatically mapped to an endpoint input with the same name.

Returns

Information about the deployment just create in a dict Python format. In this data, you will have :

  • id - Unique identifier of the deployment

  • name - Name of the deployment

  • endpoint_token - Token of the endpoint used to trigger the deployment. Note that this token is only returned if execution_rule is “endpoint”.

  • inputs_mapping - Information about the mapping between the sources of the deployment and the inputs of the pipeline

    • step_input_name - Name of the input in the pipeline

    • endpoint_input_name - Name of the source in the deployment

    • constant_value - Default value for the input if the source is missing

    • environment_variable_name - The name of an environment variable

    • is_null - A flag indicating that the input should not be provided any value at execution time

  • outputs_mapping - Information about the mapping between the destinations of the deployment and the outputs of the pipeline

    • step_output_name - Name of the output in the pipeline

    • endpoint_output_name - Name of the destination in the deployment

    • is_null - This flag indicates that the output will be deleted after execution.

  • pipeline - Information about the pipeline that will be run by the deployment

    • name - Name of the pipeline

Example

Example auto mapping

sdk.create_deployment(
   deployment_name="my_deployment",
   pipeline_name="my_pipeline",
    execution_rule="endpoint",
   outputs_mapping=[prediction_endpoint_ouput],
   inputs_mapping=[],
)

Example manual mapping

sdk.create_deployment(
   deployment_name="my_deployment",
   pipeline_name="my_pipeline",
    execution_rule="endpoint",
   outputs_mapping=[prediction_endpoint_ouput],
    inputs_mapping=[
                seagull_endpoint_input,
                big_whale_input,
                salt_constant_input,
        ],
)

Example of return object

{
    'id': '29d0c371-49ec-4071-a879-10cdab00fda4', 
    'name': 'my_deployment', 
    'endpoint_token': 'EWwIii [...] kjdD5Q', 
    'inputs_mapping': 
    [{
        'step_input_name': 'seagull', 
        'endpoint_input_name': 'sourceData'
    },
    {
        'step_input_name': 'big_whale', 
        'constant_value': 5
    },], 
    'outputs_mapping': 
    [{
        'step_output_name': 'resultMulti', 
        'endpoint_output_name': 'resultMulti'
    }], 
    'pipeline': {
        'name': 'my_pipeline'
    }
}

Deploy with execution rule: Periodic

Definition function

To create an auto-mapping deployment where all inputs and outputs are based on periodicity, you can use the create_deployment function. To create a deployment with manual mapping, you can use the create_deployment function with the additional parameters inputs_mapping to specify the precise mapping between input and source.

Warning

Input and output mapping must always be precise. Auto mapping isn’t available for periodic deployment.

Parameters

  • deployment_name (str) – Name of the deployment chosen

  • pipeline_name (str) – Name of pipeline that will be run by the deployment

  • description (str, optional) – Text description of usage of pipeline for user only.

  • execution_rule (str) - Execution rule of the deployment. Must be “endpoint” or “periodic”. For convenience, members of the enumeration DEPLOYMENT_EXECUTION_RULES could be used too.

  • schedule (str, optional) - Schedule of the deployment. Only required if execution_rule is “periodic”. Must be a valid: cron expression. The deployment will be executed periodically according to this schedule. The schedule must follow this format: <minute> <hour> <day of month> <month> <day of week>. Note that the schedule is in UTC time zone. “*” means all possible values. Here are some examples:

    • "0 0 * * *" will execute the deployment every day at midnight.

    • "0 0 5 * *" will execute the deployment every 5th day of the month at midnight.

  • inputs_mapping (List of instances of [InputSource]{.title-ref}, optional) - List of input mappings, to map pipeline inputs to different : sources (such as constant values, endpoint inputs, or environment variables). See InputSource for more details. For endpoint rules, if an input of the step in the pipeline is not explicitly mapped, it will be automatically mapped to an endpoint input with the same name. For periodic rules, all inputs of the step in the pipeline must be explicitly mapped.

  • outputs_mapping (List of instances of [OutputDestination]{.title-ref}, optional) - List of output mappings, to map pipeline outputs to different :
    destinations. See OutputDestination for more details. Each output of the step should be explicitly mapped.

Returns

Information about the deployment just create in a dict Python format.

  • id - Unique identifier of the deployment

  • name - Name of the deployment

  • schedule - Schedule of the deployment. Note that this schedule is only returned if execution_rule is “periodic”.

  • human_readable_schedule - Human readable schedule of the deployment. Note that this schedule is only returned if execution_rule is “periodic”.

  • inputs_mapping - Information about the mapping between the sources of the deployment and the inputs of the pipeline

    • step_input_name - Name of the input in the pipeline

    • endpoint_input_name - Name of the source in the deployment

    • constant_value - Default value for the input if the source is missing

    • environment_variable_name - The name of an environment variable

    • is_null - A flag indicating that the input should not be provided any value at execution time

  • outputs_mapping - Information about the mapping between the destinations of the deployment and the outputs of the pipeline

    • step_output_name - Name of the output in the pipeline

    • endpoint_output_name - Name of the destination in the deployment

    • is_null - This flag indicates that the output will be deleted after execution.

  • pipeline - Information about the pipeline that will be run by the deployment

    • name - Name of the pipeline

Example

Set up deployment to be triggered automatically every 14 days.

sdk.create_deployment(
   deployment_name="my_deployment",
   pipeline_name="my_pipeline",
   execution_rule="periodic",
   schedule="0 14 * * *"
)