Skip to content

RTInstantML pipeline

This part of the series of orchestration solution templates explains how to automate the creation of RTInstantML forecasts. The RTInstantML forecast builds model instantly at the time of forecast which is the difference when comparing to automation of forecasts with already built model. For the purpose of orchestration and automation we use Azure Data Factory tool.

Creating Data Factory pipeline

To follow the steps below there are two requirements:

Steps for creating the pipeline:

  1. Login to Azure Data Factory. You should see welcome screen similar to the one on the image below. In the left pane go to the “Author” tab.

    image.png

  2. Create new pipeline by following the image below.

    image.png

    After that, you should see empty pipeline. To simplify the navigation in the screen we split it visually into “Factory Resources pane”, “Activity pane”, “Lower pane”, “Upper pane 1”, “Upper pane 2”, and “Workspace”, see image below.

    image.png

  3. In the “Lower pane”, go to tab “General” and type name of the pipeline - let's say "build_RTInstantML" pipeline.

    image.png

  4. Then, go to the “Parameters” tab and add five parameters:

    • username – TIM Studio username
    • password – TIM Studio password
    • url – URL of TIM Studio (http://timstudio.tangent.works)
    • dataset_id – ID of the dataset, set the default to 0
    • prediction_horizon – number of samples to predict, set the default to 0

    Set the default values similarly as shown in the image below, we will populate them when running the pipeline.

    image.png

  5. Similarly, go to the "Variables" tab and create variable named token.

    image.png

  6. Now, go to the “Activity pane” -> “General” and find “Web”. Drag & drop this activity into the “Workspace”. Select the activity by clicking on it. In the "Lower pane" go to tab "General" and fill name of the activity, e.g. "get_auth_token". This activity will be responsible for the user authentication.

    image.png

  7. By replicating the previous step add two more activities - "Set variable" and "Web". These activities will be responsible for storing the token variable and sending the RTInstantML forecast request respectively. Join the activities with green arrows as illustrated on the image below. The arrow indicates the order in which the activities of the pipeline will run and the green color indicates that the activity executes only if execution of the previous activity is successful.

    image.png

  8. Select the first "Web" activity. In the “Lower pane” go to tab “Settings”. Here we have to specify the API request for the user authentication. We use the username and password parameters of the pipeline defined in step 4.

    URL: @{pipeline().parameters.url}/api/auth/
    Method: POST
    Body: {"username":"@{pipeline().parameters.username}","password":"@{pipeline().parameters.password}"}
    

    Enter each of the values by clicking on the corresponding input field and selecting "Add dynamic content".

    image.png

  9. Select the "Set variable" activity. In the “Lower pane” go to tab “Settings”. Select the token variable that was defined in step 5 and set the value to:

    value: @{activity('get_auth_token').output.token}
    

    It takes the retrieved token from the "Web" activity and stores it in the token variable we created in step 5.

    image.png

  10. Select the second "Web" activity. In the “Lower pane” go to tab “Settings”. Here we have to specify the API request for building the forecast. Fill the input fields as following:

    URL: @{pipeline().parameters.url}/api/prediction/instant-forecast/
    Method: POST
    Headers:
        Authorization: Bearer @{variables('token')}
    Body: {"dataset":@{pipeline().parameters.dataset_id},"forecast_to":"Sample","offset":@{pipeline().parameters.prediction_horizon}}
    

    The body of the request contains ID of the dataset we build the forecast for and prediction horizon (the number of samples we want to forecast).

    image.png

  11. To test the pipeline, click on the “Debug” in the “Upper pane 1”. In the popup, we have to specify the input parameters entering the pipeline. Change the default values of “username”, “password”, and “url” parameters if needed. Set prediction_horizon to the number of samples you want to forecast.

    image.png

    The “dataset_id” can be found in TIM Studio in the list of datasets in the column “ID”.

    image.png

    After filling the parameters, click on “Finish”. You should see the output of the debug run in the “Lower pane” -> “Output”. All three activities should end up with status "Succeeded".

    image.png

    The result can be verified in TIM Studio. Go to Forecasting screen and under the dataset you should see the forecast.

    image.png

  12. Now we can run the pipeline and simulate production mode. Navigate to "Upper pane 1" and select "Add trigger" -> "Trigger now". Fill the parameters similarly as when debugging the pipeline in previous step.

    In the left pane go to "Monitor" tab to see result of the pipeline run. After a while we should see that the execution is over with status "Succeeded".

    image.png

  13. Go back to the "Author" tab in the left pane and save the pipelines by clicking on the “Publish all” button in the “Upper pane 2”.

Download the pipeline

The pipeline can be downloaded here. See Importing pipelines for importing the pipeline to your Azure Data Factory subscription.

Next steps