Skip to content

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(deployment_name, pipeline_name, execution_rule, deployment_mode, outputs_mapping=[], inputs_mapping=[], description) 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.

CraftAiSdk.create_deployment(
    pipeline_name, 
    deployment_name, 
    execution_rule="endpoint",
    deployment_mode=DEPLOYMENT_MODES.ELASTIC,
    inputs_mapping=None,
    outputs_mapping=None, 
    description=None
    )

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.
  • deployment_mode (str) – Mode of the deployment. Must be “elastic”.
  • 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.
  • description (str, optional) – Description of the deployment.

Returns

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

  • 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”.

Example

Example auto mapping

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

> {
>   'name': 'name-endpoint', 
>   'endpoint_token': 'S_xZOKU ... KHs'
> }

Example manual mapping

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


> {
>   'name': 'name-endpoint', 
>   'endpoint_token': 'S_xZOkCI ... FIg'
> }

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.

CraftAiSdk.create_deployment(
    pipeline_name, 
    deployment_name, 
    execution_rule="periodic",
    deployment_mode=DEPLOYMENT_MODES.ELASTIC,
    schedule=None, 
    inputs_mapping=None,
    outputs_mapping=None, 
    description=None
    )

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], 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], optional) - List of output mappings, to map pipeline outputs to different :
    destinations. See OutputDestination for more details. For endpoint execution rules, if an output of the step in the pipeline is not explicitly mapped, it will be automatically mapped to an endpoint input with the same name. For other rules, all outputs of the step in the pipeline must be explicitly mapped.

  • description (str, optional) – Description of the deployment.

Returns

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

  • 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”.

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 * * *"
)


> {
>   'name': 'produit-endpoint-periodic', 
>   'schedule': '*/2 * * * *', 
>   'human_readable_schedule': 'Every 2 minutes'
> }