{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Operationalize end-to-end Amazon Personalize model deployment process using AWS Step Functions Data Science SDK\n", "\n", "1. [Introduction](#Introduction)\n", "2. [Setup](#Setup)\n", "3. [Task-States](#Task-States)\n", "4. [Wait-States](#Wait-States)\n", "5. [Choice-States](#Choice-States)\n", "6. [Workflow](#Workflow)\n", "7. [Generate-Recommendations](#Generate-Recommendations)\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "\n", "This notebook describes using the AWS Step Functions Data Science SDK to create and manage an Amazon Personalize workflow. The Step Functions SDK is an open source library that allows data scientists to easily create and execute machine learning workflows using AWS Step Functions. For more information on Step Functions SDK, see the following.\n", "* [AWS Step Functions](https://aws.amazon.com/step-functions/)\n", "* [AWS Step Functions Developer Guide](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)\n", "* [AWS Step Functions Data Science SDK](https://aws-step-functions-data-science-sdk.readthedocs.io)\n", "\n", "In this notebook we will use the SDK to create steps to create Personalize resources, link them together to create a workflow, and execute the workflow in AWS Step Functions. \n", "\n", "For more information, on Amazon Personalize see the following.\n", "\n", "* [Amazon Personalize](https://aws.amazon.com/personalize/)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import required modules from the SDK" ] }, { "cell_type": "code", "execution_count": 890, "metadata": {}, "outputs": [], "source": [ "#import sys\n", "#!{sys.executable} -m pip install --upgrade stepfunctions" ] }, { "cell_type": "code", "execution_count": 891, "metadata": {}, "outputs": [], "source": [ "import boto3\n", "import json\n", "import numpy as np\n", "import pandas as pd\n", "import time\n", "\n", "personalize = boto3.client('personalize')\n", "personalize_runtime = boto3.client('personalize-runtime')\n", "\n", "\n", "import stepfunctions\n", "import logging\n", "\n", "from stepfunctions.steps import *\n", "from stepfunctions.workflow import Workflow\n", "\n", "stepfunctions.set_stream_logger(level=logging.INFO)\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Setup S3 location and filename\n", "create an Amazon S3 bucket to store the training dataset and provide the Amazon S3 bucket name and file name in the walkthrough notebook step Setup S3 location and filename below:" ] }, { "cell_type": "code", "execution_count": 892, "metadata": {}, "outputs": [], "source": [ "bucket = \"\" # replace with the name of your S3 bucket\n", "filename = \"\" # replace with a name that you want to save the dataset under" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Setup IAM Roles\n", "\n", "#### Create an execution role for Step Functions\n", "\n", "You need an execution role so that you can create and execute workflows in Step Functions.\n", "\n", "1. Go to the [IAM console](https://console.aws.amazon.com/iam/)\n", "2. Select **Roles** and then **Create role**.\n", "3. Under **Choose the service that will use this role** select **Step Functions**\n", "4. Choose **Next** until you can enter a **Role name**\n", "5. Enter a name such as `StepFunctionsWorkflowExecutionRole` and then select **Create role**\n", "\n", "\n", "Attach a policy to the role you created. The following steps attach a policy that provides full access to Step Functions, however as a good practice you should only provide access to the resources you need. \n", "\n", "1. Under the **Permissions** tab, click **Add inline policy**\n", "2. Enter the following in the **JSON** tab\n", "\n", "```json\n", "{\n", " \"Version\": \"2012-10-17\",\n", " \"Statement\": [\n", " \n", " {\n", " \"Effect\": \"Allow\",\n", " \"Action\": [\n", " \"personalize:*\"\n", " ],\n", " \"Resource\": \"*\"\n", " }, \n", "\n", " {\n", " \"Effect\": \"Allow\",\n", " \"Action\": [\n", " \"lambda:InvokeFunction\"\n", " ],\n", " \"Resource\": \"*\"\n", " },\n", " {\n", " \"Effect\": \"Allow\",\n", " \"Action\": [\n", " \"iam:PassRole\"\n", " ],\n", " \"Resource\": \"*\",\n", " },\n", " {\n", " \"Effect\": \"Allow\",\n", " \"Action\": [\n", " \"events:PutTargets\",\n", " \"events:PutRule\",\n", " \"events:DescribeRule\"\n", " ],\n", " \"Resource\": \"*\"\n", " }\n", " ]\n", "}\n", "```\n", "\n", "3. Choose **Review policy** and give the policy a name such as `StepFunctionsWorkflowExecutionPolicy`\n", "4. Choose **Create policy**. You will be redirected to the details page for the role.\n", "5. Copy the **Role ARN** at the top of the **Summary**\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "workflow_execution_role = \"\" # paste the StepFunctionsWorkflowExecutionRole ARN from above" ] }, { "cell_type": "code", "execution_count": 893, "metadata": {}, "outputs": [], "source": [ "lambda_state_role = LambdaStep(\n", " state_id=\"create bucket and role\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_create_personalize_role\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"bucket\": bucket\n", " }\n", " },\n", " result_path='$'\n", " \n", ")\n", "\n", "lambda_state_role.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_role.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"CreateRoleTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Attach Policy to S3 Bucket" ] }, { "cell_type": "code", "execution_count": 894, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'ResponseMetadata': {'RequestId': 'CD1EF0803009C0DF',\n", " 'HostId': '/S5SnhjYlSY8ARlyZnuSFJPnFzh4TsZ8COqiuXe7SHgel7whbtryHpRpnzqfcUZn1oz1pcss8L8=',\n", " 'HTTPStatusCode': 204,\n", " 'HTTPHeaders': {'x-amz-id-2': '/S5SnhjYlSY8ARlyZnuSFJPnFzh4TsZ8COqiuXe7SHgel7whbtryHpRpnzqfcUZn1oz1pcss8L8=',\n", " 'x-amz-request-id': 'CD1EF0803009C0DF',\n", " 'date': 'Tue, 05 Jan 2021 22:27:33 GMT',\n", " 'server': 'AmazonS3'},\n", " 'RetryAttempts': 0}}" ] }, "execution_count": 894, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s3 = boto3.client(\"s3\")\n", "\n", "policy = {\n", " \"Version\": \"2012-10-17\",\n", " \"Id\": \"PersonalizeS3BucketAccessPolicy\",\n", " \"Statement\": [\n", " {\n", " \"Sid\": \"PersonalizeS3BucketAccessPolicy\",\n", " \"Effect\": \"Allow\",\n", " \"Principal\": {\n", " \"Service\": \"personalize.amazonaws.com\"\n", " },\n", " \"Action\": [\n", " \"s3:GetObject\",\n", " \"s3:ListBucket\"\n", " ],\n", " \"Resource\": [\n", " \"arn:aws:s3:::{}\".format(bucket),\n", " \"arn:aws:s3:::{}/*\".format(bucket)\n", " \n", " ]\n", " }\n", " ]\n", "}\n", "\n", "s3.put_bucket_policy(Bucket=bucket, Policy=json.dumps(policy))\n", "\n", "# AmazonPersonalizeFullAccess provides access to any S3 bucket with a name that includes \"personalize\" or \"Personalize\" \n", "# if you would like to use a bucket with a different name, please consider creating and attaching a new policy\n", "# that provides read access to your bucket or attaching the AmazonS3ReadOnlyAccess policy to the role\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Personalize Role\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "iam = boto3.client(\"iam\")\n", "\n", "role_name = \"personalize-role\" # Create a personalize role\n", "\n", "\n", "assume_role_policy_document = {\n", " \"Version\": \"2012-10-17\",\n", " \"Statement\": [\n", " {\n", " \"Effect\": \"Allow\",\n", " \"Principal\": {\n", " \"Service\": \"personalize.amazonaws.com\"\n", " },\n", " \"Action\": \"sts:AssumeRole\"\n", " }\n", " ]\n", "}\n", "\n", "create_role_response = iam.create_role(\n", " RoleName = role_name,\n", " AssumeRolePolicyDocument = json.dumps(assume_role_policy_document)\n", ")\n", "\n", "\n", "\n", "policy_arn = \"arn:aws:iam::aws:policy/service-role/AmazonPersonalizeFullAccess\"\n", "iam.attach_role_policy(\n", " RoleName = role_name,\n", " PolicyArn = policy_arn\n", ")\n", "\n", "time.sleep(60) # wait for a minute to allow IAM role policy attachment to propagate\n", "\n", "role_arn = create_role_response[\"Role\"][\"Arn\"]\n" ] }, { "cell_type": "code", "execution_count": 895, "metadata": {}, "outputs": [], "source": [ "role_arn = \"\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data-Preparation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Download, Prepare, and Upload Training Data" ] }, { "cell_type": "code", "execution_count": 896, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/ec2-user/SageMaker/Personalize-Workflow\r\n" ] } ], "source": [ "!pwd" ] }, { "cell_type": "code", "execution_count": 897, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2021-01-05 22:27:32-- http://files.grouplens.org/datasets/movielens/ml-100k.zip\n", "Resolving files.grouplens.org (files.grouplens.org)... 128.101.65.152\n", "Connecting to files.grouplens.org (files.grouplens.org)|128.101.65.152|:80... connected.\n", "HTTP request sent, awaiting response... 304 Not Modified\n", "File ‘ml-100k.zip’ not modified on server. Omitting download.\n", "\n", "Archive: ml-100k.zip\n", " inflating: ml-100k/allbut.pl \n", " inflating: ml-100k/mku.sh \n", " inflating: ml-100k/README \n", " inflating: ml-100k/u.data \n", " inflating: ml-100k/u.genre \n", " inflating: ml-100k/u.info \n", " inflating: ml-100k/u.item \n", " inflating: ml-100k/u.occupation \n", " inflating: ml-100k/u.user \n", " inflating: ml-100k/u1.base \n", " inflating: ml-100k/u1.test \n", " inflating: ml-100k/u2.base \n", " inflating: ml-100k/u2.test \n", " inflating: ml-100k/u3.base \n", " inflating: ml-100k/u3.test \n", " inflating: ml-100k/u4.base \n", " inflating: ml-100k/u4.test \n", " inflating: ml-100k/u5.base \n", " inflating: ml-100k/u5.test \n", " inflating: ml-100k/ua.base \n", " inflating: ml-100k/ua.test \n", " inflating: ml-100k/ub.base \n", " inflating: ml-100k/ub.test \n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
USER_IDITEM_IDRATINGTIMESTAMP
01962423881250949
11863023891717742
...............
99998132252882399156
99999122033879959583
\n", "

100000 rows × 4 columns

\n", "
" ], "text/plain": [ " USER_ID ITEM_ID RATING TIMESTAMP\n", "0 196 242 3 881250949\n", "1 186 302 3 891717742\n", "... ... ... ... ...\n", "99998 13 225 2 882399156\n", "99999 12 203 3 879959583\n", "\n", "[100000 rows x 4 columns]" ] }, "execution_count": 897, "metadata": {}, "output_type": "execute_result" } ], "source": [ "!wget -N http://files.grouplens.org/datasets/movielens/ml-100k.zip\n", "!unzip -o ml-100k.zip\n", "data = pd.read_csv('./ml-100k/u.data', sep='\\t', names=['USER_ID', 'ITEM_ID', 'RATING', 'TIMESTAMP'])\n", "pd.set_option('display.max_rows', 5)\n", "data\n", "\n" ] }, { "cell_type": "code", "execution_count": 898, "metadata": {}, "outputs": [], "source": [ "data = data[data['RATING'] > 2] # keep only movies rated 2 and above\n", "data2 = data[['USER_ID', 'ITEM_ID', 'TIMESTAMP']] \n", "data2.to_csv(filename, index=False)\n", "\n", "boto3.Session().resource('s3').Bucket(bucket).Object(filename).upload_file(filename)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task-States" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Lambda Task state\n", "\n", "A `Task` State in Step Functions represents a single unit of work performed by a workflow. Tasks can call Lambda functions and orchestrate other AWS services. See [AWS Service Integrations](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-service-integrations.html) in the *AWS Step Functions Developer Guide*.\n", "\n", "The following creates a [LambdaStep](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/compute.html#stepfunctions.steps.compute.LambdaStep) called `lambda_state`, and then configures the options to [Retry](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-retrying-after-an-error) if the Lambda function fails.\n", "\n", "#### Create a Lambda functions\n", "\n", "The Lambda task states in this workflow uses Lambda function **(Python 3.x)** that returns a Personalize resources such as Schema, Datasetgroup, Dataset, Solution, SolutionVersion, etc. Create the following functions in the [Lambda console](https://console.aws.amazon.com/lambda/).\n", "\n", "1. stepfunction-create-schema\n", "2. stepfunctioncreatedatagroup\n", "3. stepfunctioncreatedataset\n", "4. stepfunction-createdatasetimportjob\n", "5. stepfunction_select-recipe_create-solution\n", "6. stepfunction_create_solution_version\n", "7. stepfunction_getsolution_metric_create_campaign\n", "\n", "Copy/Paste the corresponding lambda function code from ./Lambda/ folder in the repo\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Schema\n", "\n", "Before you add a dataset to Amazon Personalize, you must define a schema for that dataset. Once you define the schema and create the dataset, you can't make changes to the schema.for more information refer this documentation." ] }, { "cell_type": "code", "execution_count": 899, "metadata": {}, "outputs": [], "source": [ "lambda_state_schema = LambdaStep(\n", " state_id=\"create schema\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction-create-schema\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"input\": \"personalize-stepfunction-schema3484\"\n", " }\n", " },\n", " result_path='$' \n", ")\n", "\n", "lambda_state_schema.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_schema.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"CreateSchemaTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Datasetgroup\n", "\n", "Craete Datasetgroup: Creates an empty dataset group. A dataset group contains related datasets that supply data for training a model. A dataset group can contain at most three datasets, one for each type of dataset:\n", "•\tInteractions\n", "•\tItems\n", "•\tUsers\n", "To train a model (create a solution), a dataset group that contains an Interactions dataset is required. Call CreateDataset to add a dataset to the group.\n", "\n", "After you have created a schema , we will create another Stepfunction state based on this lambda function stepfunctioncreatedatagroup.py below in github lambdas folder by running the Create Datasetgroup¶ step of the notebook. We are using python boto3 APIs to create_dataset_group." ] }, { "cell_type": "code", "execution_count": 900, "metadata": {}, "outputs": [], "source": [ "lambda_state_datasetgroup = LambdaStep(\n", " state_id=\"create dataset Group\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunctioncreatedatagroup\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"input\": \"personalize-stepfunction-dataset-group\", \n", " \"schemaArn.$\": '$.Payload.schemaArn'\n", " }\n", " },\n", "\n", " result_path='$'\n", ")\n", "\n", "\n", "\n", "lambda_state_datasetgroup.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "\n", "lambda_state_datasetgroup.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"CreateDataSetGroupTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Dataset\n", "\n", "Creates an empty dataset and adds it to the specified dataset group. Use CreateDatasetImportJob to import your training data to a dataset.\n", "\n", "There are three types of datasets:\n", "\n", "Interactions\n", "\n", "Items\n", "\n", "Users\n", "\n", "Each dataset type has an associated schema with required field types. Only the Interactions dataset is required in order to train a model (also referred to as creating a solution)." ] }, { "cell_type": "code", "execution_count": 901, "metadata": {}, "outputs": [], "source": [ "lambda_state_createdataset = LambdaStep(\n", " state_id=\"create dataset\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunctioncreatedataset\", #replace with the name of the function you created\n", "# \"Payload\": { \n", "# \"schemaArn.$\": '$.Payload.schemaArn',\n", "# \"datasetGroupArn.$\": '$.Payload.datasetGroupArn',\n", " \n", " \n", "# }\n", " \n", " \"Payload\": { \n", " \"schemaArn.$\": '$.schemaArn',\n", " \"datasetGroupArn.$\": '$.datasetGroupArn', \n", " } \n", " \n", " \n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_createdataset.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_createdataset.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"CreateDataSetTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Dataset Import Job\n", "\n", "When you have completed Step 1: Creating a Dataset Group and Step 2: Creating a Dataset and a Schema, you are ready to import your training data into Amazon Personalize. When you import data, you can choose to import records in bulk, import records individually, or both, depending on your business requirements and the amount of historical data you have collected. If you have a large amount of historical records, \n", "we recommend you first import data in bulk and then add data incrementally as necessary." ] }, { "cell_type": "code", "execution_count": 902, "metadata": {}, "outputs": [], "source": [ "lambda_state_datasetimportjob = LambdaStep(\n", " state_id=\"create dataset import job\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction-createdatasetimportjob\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"datasetimportjob\": \"stepfunction-createdatasetimportjob\",\n", " \"dataset_arn.$\": '$.Payload.dataset_arn',\n", " \"datasetGroupArn.$\": '$.Payload.datasetGroupArn',\n", " \"bucket_name\": bucket,\n", " \"file_name\": filename,\n", " \"role_arn\": role_arn\n", " \n", " }\n", " },\n", "\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_datasetimportjob.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_datasetimportjob.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"DatasetImportJobTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Solution\n", "\n", "Once you have finished Preparing and Importing Data, you are ready to create a Solution. A Solution refers to the combination of an Amazon Personalize recipe, customized parameters, and one or more solution versions (trained models). Once you create a solution with a solution version, you can create a campaign to deploy the solution version and get recommendations.\n", "\n", "To create a solution in Amazon Personalize, you do the following:\n", "\n", "Choose a recipe – A recipe is an Amazon Personalize term specifying an appropriate algorithm to train for a given use case. See Step 1: Choosing a Recipe.\n", "\n", "Configure a solution – Customize solution parameters and recipe-specific hyperparameters so the model meets your specific business needs. See Step 2: Configuring a Solution.\n", "\n", "Create a solution version (train a model) – Train the machine learning model Amazon Personalize will use to generate recommendations for your customers. See Step 3: Creating a Solution Version.\n", "\n", "Evaluate the solution version – Use the metrics Amazon Personalize generates from the new solution version to evaluate the performance of the model. See Step 4: Evaluating the Solution Version.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Choosing a Recipe and Configuring a Solution\n", "\n", "A recipe is an Amazon Personalize term specifying an appropriate algorithm to train for a given use case. " ] }, { "cell_type": "code", "execution_count": 903, "metadata": {}, "outputs": [], "source": [ "lambda_state_select_receipe_create_solution = LambdaStep(\n", " state_id=\"select receipe and create solution\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_select-recipe_create-solution\", #replace with the name of the function you created\n", " \"Payload\": { \n", " #\"dataset_group_arn.$\": '$.Payload.datasetGroupArn' \n", " \"dataset_group_arn.$\": '$.datasetGroupArn'\n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_select_receipe_create_solution.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_select_receipe_create_solution.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"DatasetReceiptCreateSolutionTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Solution Version\n", "\n", "Once you have completed Choosing a Recipe and Configuring a Solution, you are ready to create a Solution Version. A Solution Version refers to a trained machine learning model you can deploy to get recommendations for customers. You can create a solution version using the console, AWS Command Line Interface (AWS CLI), or AWS SDK." ] }, { "cell_type": "code", "execution_count": 904, "metadata": {}, "outputs": [], "source": [ "lambda_create_solution_version = LambdaStep(\n", " state_id=\"create solution version\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_create_solution_version\", \n", " \"Payload\": { \n", " \"solution_arn.$\": '$.Payload.solution_arn' \n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_create_solution_version.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_create_solution_version.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"CreateSolutionVersionTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create Campaign\n", "\n", "A campaign is used to make recommendations for your users. You create a campaign by deploying a solution version" ] }, { "cell_type": "code", "execution_count": 905, "metadata": {}, "outputs": [], "source": [ "lambda_create_campaign = LambdaStep(\n", " state_id=\"create campaign\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_getsolution_metric_create_campaign\", \n", " \"Payload\": { \n", " #\"solution_version_arn.$\": '$.Payload.solution_version_arn' \n", " \"solution_version_arn.$\": '$.solution_version_arn'\n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_create_campaign.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_create_campaign.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"CreateCampaignTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Wait-States\n", "\n", "#### A `Wait` state in Step Functions waits a specific amount of time. See [Wait](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/states.html#stepfunctions.steps.states.Wait) in the AWS Step Functions Data Science SDK documentation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Wait for Schema to be ready" ] }, { "cell_type": "code", "execution_count": 906, "metadata": {}, "outputs": [], "source": [ "wait_state_schema = Wait(\n", " state_id=\"Wait for create schema - 5 secs\",\n", " seconds=5\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Wait for Datasetgroup to be ready" ] }, { "cell_type": "code", "execution_count": 907, "metadata": {}, "outputs": [], "source": [ "wait_state_datasetgroup = Wait(\n", " state_id=\"Wait for datasetgroup - 30 secs\",\n", " seconds=30\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Wait for Dataset to be ready" ] }, { "cell_type": "code", "execution_count": 908, "metadata": {}, "outputs": [], "source": [ "wait_state_dataset = Wait(\n", " state_id=\"wait for dataset - 30 secs\",\n", " seconds=30\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Wait for Dataset Import Job to be ACTIVE" ] }, { "cell_type": "code", "execution_count": 909, "metadata": {}, "outputs": [], "source": [ "wait_state_datasetimportjob = Wait(\n", " state_id=\"Wait for datasetimportjob - 30 secs\",\n", " seconds=30\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Wait for Receipe to ready" ] }, { "cell_type": "code", "execution_count": 910, "metadata": {}, "outputs": [], "source": [ "wait_state_receipe = Wait(\n", " state_id=\"Wait for receipe - 30 secs\",\n", " seconds=30\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Wait for Solution Version to be ACTIVE" ] }, { "cell_type": "code", "execution_count": 911, "metadata": {}, "outputs": [], "source": [ "wait_state_solutionversion = Wait(\n", " state_id=\"Wait for solution version - 60 secs\",\n", " seconds=60\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Wait for Campaign to be ACTIVE" ] }, { "cell_type": "code", "execution_count": 912, "metadata": {}, "outputs": [], "source": [ "wait_state_campaign = Wait(\n", " state_id=\"Wait for Campaign - 30 secs\",\n", " seconds=30\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "### Check status of the lambda task and take action accordingly" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### If a state fails, move it to `Fail` state. See [Fail](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/states.html#stepfunctions.steps.states.Fail) in the AWS Step Functions Data Science SDK documentation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### check datasetgroup status" ] }, { "cell_type": "code", "execution_count": 913, "metadata": {}, "outputs": [], "source": [ "lambda_state_datasetgroupstatus = LambdaStep(\n", " state_id=\"check dataset Group status\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_waitforDatasetGroup\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"input.$\": '$.Payload.datasetGroupArn',\n", " \"schemaArn.$\": '$.Payload.schemaArn'\n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_datasetgroupstatus.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_datasetgroupstatus.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"DatasetGroupStatusTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### check dataset import job status" ] }, { "cell_type": "code", "execution_count": 914, "metadata": {}, "outputs": [], "source": [ "lambda_state_datasetimportjob_status = LambdaStep(\n", " state_id=\"check dataset import job status\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_waitfordatasetimportjob\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"dataset_import_job_arn.$\": '$.Payload.dataset_import_job_arn',\n", " \"datasetGroupArn.$\": '$.Payload.datasetGroupArn'\n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_datasetimportjob_status.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_datasetimportjob_status.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"DatasetImportJobStatusTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### check solution version status" ] }, { "cell_type": "code", "execution_count": 915, "metadata": {}, "outputs": [], "source": [ "\n", "solutionversion_succeed_state = Succeed(\n", " state_id=\"The Solution Version ready?\"\n", ")" ] }, { "cell_type": "code", "execution_count": 916, "metadata": {}, "outputs": [], "source": [ "lambda_state_solutionversion_status = LambdaStep(\n", " state_id=\"check solution version status\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_waitforSolutionVersion\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"solution_version_arn.$\": '$.Payload.solution_version_arn' \n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_solutionversion_status.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_solutionversion_status.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"SolutionVersionStatusTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### check campaign status" ] }, { "cell_type": "code", "execution_count": 917, "metadata": {}, "outputs": [], "source": [ "lambda_state_campaign_status = LambdaStep(\n", " state_id=\"check campaign status\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_waitforCampaign\", #replace with the name of the function you created\n", " \"Payload\": { \n", " \"campaign_arn.$\": '$.Payload.campaign_arn' \n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_campaign_status.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_campaign_status.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"CampaignStatusTaskFailed\")\n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Choice-States\n", "\n", "Now, attach branches to the Choice state you created earlier. See *Choice Rules* in the [AWS Step Functions Data Science SDK documentation](https://aws-step-functions-data-science-sdk.readthedocs.io) ." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Chain together steps for the define the workflow path\n", "\n", "The following cell links together the steps you've created above into a sequential group. The new path sequentially includes the Lambda state, Wait state, and the Succeed state that you created earlier.\n", "\n", "#### After chaining together the steps for the workflow path, we will define and visualize the workflow." ] }, { "cell_type": "code", "execution_count": 918, "metadata": {}, "outputs": [], "source": [ "create_campaign_choice_state = Choice(\n", " state_id=\"Is the Campaign ready?\"\n", ")" ] }, { "cell_type": "code", "execution_count": 919, "metadata": {}, "outputs": [], "source": [ "create_campaign_choice_state.add_choice(\n", " rule=ChoiceRule.StringEquals(variable=lambda_state_campaign_status.output()['Payload']['status'], value='ACTIVE'),\n", " next_step=Succeed(\"CampaignCreatedSuccessfully\") \n", ")\n", "create_campaign_choice_state.add_choice(\n", " ChoiceRule.StringEquals(variable=lambda_state_campaign_status.output()['Payload']['status'], value='CREATE PENDING'),\n", " next_step=wait_state_campaign\n", ")\n", "create_campaign_choice_state.add_choice(\n", " ChoiceRule.StringEquals(variable=lambda_state_campaign_status.output()['Payload']['status'], value='CREATE IN_PROGRESS'),\n", " next_step=wait_state_campaign\n", ")\n", "\n", "create_campaign_choice_state.default_choice(next_step=Fail(\"CreateCampaignFailed\"))\n" ] }, { "cell_type": "code", "execution_count": 920, "metadata": {}, "outputs": [], "source": [ "solutionversion_choice_state = Choice(\n", " state_id=\"Is the Solution Version ready?\"\n", ")" ] }, { "cell_type": "code", "execution_count": 921, "metadata": {}, "outputs": [], "source": [ "solutionversion_succeed_state = Succeed(\n", " state_id=\"The Solution Version ready?\"\n", ")" ] }, { "cell_type": "code", "execution_count": 922, "metadata": {}, "outputs": [], "source": [ "solutionversion_choice_state.add_choice(\n", " rule=ChoiceRule.StringEquals(variable=lambda_state_solutionversion_status.output()['Payload']['status'], value='ACTIVE'),\n", " next_step=solutionversion_succeed_state \n", ")\n", "solutionversion_choice_state.add_choice(\n", " ChoiceRule.StringEquals(variable=lambda_state_solutionversion_status.output()['Payload']['status'], value='CREATE PENDING'),\n", " next_step=wait_state_solutionversion\n", ")\n", "solutionversion_choice_state.add_choice(\n", " ChoiceRule.StringEquals(variable=lambda_state_solutionversion_status.output()['Payload']['status'], value='CREATE IN_PROGRESS'),\n", " next_step=wait_state_solutionversion\n", ")\n", "\n", "solutionversion_choice_state.default_choice(next_step=Fail(\"create_solution_version_failed\"))\n" ] }, { "cell_type": "code", "execution_count": 923, "metadata": {}, "outputs": [], "source": [ "datasetimportjob_succeed_state = Succeed(\n", " state_id=\"The Solution Version ready?\"\n", ")" ] }, { "cell_type": "code", "execution_count": 924, "metadata": {}, "outputs": [], "source": [ "datasetimportjob_choice_state = Choice(\n", " state_id=\"Is the DataSet Import Job ready?\"\n", ")" ] }, { "cell_type": "code", "execution_count": 925, "metadata": {}, "outputs": [], "source": [ "datasetimportjob_choice_state.add_choice(\n", " rule=ChoiceRule.StringEquals(variable=lambda_state_datasetimportjob_status.output()['Payload']['status'], value='ACTIVE'),\n", " next_step=datasetimportjob_succeed_state \n", ")\n", "datasetimportjob_choice_state.add_choice(\n", " ChoiceRule.StringEquals(variable=lambda_state_datasetimportjob_status.output()['Payload']['status'], value='CREATE PENDING'),\n", " next_step=wait_state_datasetimportjob\n", ")\n", "datasetimportjob_choice_state.add_choice(\n", " ChoiceRule.StringEquals(variable=lambda_state_datasetimportjob_status.output()['Payload']['status'], value='CREATE IN_PROGRESS'),\n", " next_step=wait_state_datasetimportjob\n", ")\n", "\n", "\n", "datasetimportjob_choice_state.default_choice(next_step=Fail(\"dataset_import_job_failed\"))\n" ] }, { "cell_type": "code", "execution_count": 926, "metadata": {}, "outputs": [], "source": [ "datasetgroupstatus_choice_state = Choice(\n", " state_id=\"Is the DataSetGroup ready?\"\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Workflow" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Define Workflow\n", "\n", "In the following cell, you will define the step that you will use in our workflow. Then you will create, visualize and execute the workflow. \n", "\n", "Steps relate to states in AWS Step Functions. For more information, see [States](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-states.html) in the *AWS Step Functions Developer Guide*. For more information on the AWS Step Functions Data Science SDK APIs, see: https://aws-step-functions-data-science-sdk.readthedocs.io. \n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dataset workflow" ] }, { "cell_type": "code", "execution_count": 927, "metadata": {}, "outputs": [], "source": [ "Dataset_workflow_definition=Chain([lambda_state_schema,\n", " wait_state_schema,\n", " lambda_state_datasetgroup,\n", " wait_state_datasetgroup,\n", " lambda_state_datasetgroupstatus\n", " ])" ] }, { "cell_type": "code", "execution_count": 928, "metadata": {}, "outputs": [], "source": [ "Dataset_workflow = Workflow(\n", " name=\"Dataset-workflow\",\n", " definition=Dataset_workflow_definition,\n", " role=workflow_execution_role\n", ")" ] }, { "cell_type": "code", "execution_count": 929, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 929, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Dataset_workflow.render_graph()" ] }, { "cell_type": "code", "execution_count": 930, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow created successfully on AWS Step Functions.\u001b[0m\n" ] } ], "source": [ "DatasetWorkflowArn = Dataset_workflow.create()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### DatasetImportWorkflow" ] }, { "cell_type": "code", "execution_count": 931, "metadata": {}, "outputs": [], "source": [ "DatasetImport_workflow_definition=Chain([lambda_state_createdataset,\n", " wait_state_dataset,\n", " lambda_state_datasetimportjob,\n", " wait_state_datasetimportjob,\n", " lambda_state_datasetimportjob_status,\n", " datasetimportjob_choice_state\n", " ])" ] }, { "cell_type": "code", "execution_count": 932, "metadata": {}, "outputs": [], "source": [ "DatasetImport_workflow = Workflow(\n", " name=\"DatasetImport-workflow\",\n", " definition=DatasetImport_workflow_definition,\n", " role=workflow_execution_role\n", ")" ] }, { "cell_type": "code", "execution_count": 933, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 933, "metadata": {}, "output_type": "execute_result" } ], "source": [ "DatasetImport_workflow.render_graph()" ] }, { "cell_type": "code", "execution_count": 934, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow created successfully on AWS Step Functions.\u001b[0m\n" ] } ], "source": [ "DatasetImportflowArn = DatasetImport_workflow.create()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Recepie and Solution workflow" ] }, { "cell_type": "code", "execution_count": 935, "metadata": {}, "outputs": [], "source": [ "Create_receipe_sol_workflow_definition=Chain([lambda_state_select_receipe_create_solution,\n", " wait_state_receipe,\n", " lambda_create_solution_version,\n", " wait_state_solutionversion,\n", " lambda_state_solutionversion_status,\n", " solutionversion_choice_state\n", " ])" ] }, { "cell_type": "code", "execution_count": 936, "metadata": {}, "outputs": [], "source": [ "Create_receipe_sol_workflow = Workflow(\n", " name=\"Create_receipe_sol-workflow\",\n", " definition=Create_receipe_sol_workflow_definition,\n", " role=workflow_execution_role\n", ")" ] }, { "cell_type": "code", "execution_count": 937, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 937, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Create_receipe_sol_workflow.render_graph()" ] }, { "cell_type": "code", "execution_count": 938, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow created successfully on AWS Step Functions.\u001b[0m\n" ] } ], "source": [ "CreateReceipeArn = Create_receipe_sol_workflow.create()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create Campaign Workflow" ] }, { "cell_type": "code", "execution_count": 939, "metadata": {}, "outputs": [], "source": [ "Create_Campaign_workflow_definition=Chain([lambda_create_campaign,\n", " wait_state_campaign,\n", " lambda_state_campaign_status,\n", " wait_state_datasetimportjob,\n", " create_campaign_choice_state\n", " ])" ] }, { "cell_type": "code", "execution_count": 940, "metadata": {}, "outputs": [], "source": [ "Campaign_workflow = Workflow(\n", " name=\"Campaign-workflow\",\n", " definition=Create_Campaign_workflow_definition,\n", " role=workflow_execution_role\n", ")" ] }, { "cell_type": "code", "execution_count": 941, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 941, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Campaign_workflow.render_graph()" ] }, { "cell_type": "code", "execution_count": 942, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow created successfully on AWS Step Functions.\u001b[0m\n" ] } ], "source": [ "CreateCampaignArn = Campaign_workflow.create()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Main workflow" ] }, { "cell_type": "code", "execution_count": 943, "metadata": {}, "outputs": [], "source": [ "call_dataset_workflow_state = Task(\n", " state_id=\"DataSetWorkflow\",\n", " resource=\"arn:aws:states:::states:startExecution.sync:2\",\n", " parameters={\n", " \"Input\": \"true\",\n", " #\"StateMachineArn\": \"arn:aws:states:us-east-1:444602785259:stateMachine:Dataset-workflow\",\n", " \"StateMachineArn\": DatasetWorkflowArn\n", " }\n", ")" ] }, { "cell_type": "code", "execution_count": 944, "metadata": {}, "outputs": [], "source": [ "call_datasetImport_workflow_state = Task(\n", " state_id=\"DataSetImportWorkflow\",\n", " resource=\"arn:aws:states:::states:startExecution.sync:2\",\n", " parameters={\n", " \"Input\":{\n", " \"schemaArn.$\": \"$.Output.Payload.schemaArn\",\n", " \"datasetGroupArn.$\": \"$.Output.Payload.datasetGroupArn\"\n", " },\n", " \"StateMachineArn\": DatasetImportflowArn,\n", " }\n", ")" ] }, { "cell_type": "code", "execution_count": 945, "metadata": {}, "outputs": [], "source": [ "call_receipe_solution_workflow_state = Task(\n", " state_id=\"ReceipeSolutionWorkflow\",\n", " resource=\"arn:aws:states:::states:startExecution.sync:2\",\n", " parameters={\n", " \"Input\":{\n", " \"datasetGroupArn.$\": \"$.Output.Payload.datasetGroupArn\"\n", "\n", " },\n", " \"StateMachineArn\": CreateReceipeArn\n", " }\n", ")" ] }, { "cell_type": "code", "execution_count": 946, "metadata": {}, "outputs": [], "source": [ "call_campaign_solution_workflow_state = Task(\n", " state_id=\"CampaignWorkflow\",\n", " resource=\"arn:aws:states:::states:startExecution.sync:2\",\n", " parameters={\n", " \"Input\":{\n", " \"solution_version_arn.$\": \"$.Output.Payload.solution_version_arn\"\n", "\n", " },\n", " \"StateMachineArn\": CreateCampaignArn\n", " }\n", ")" ] }, { "cell_type": "code", "execution_count": 947, "metadata": {}, "outputs": [], "source": [ "Main_workflow_definition=Chain([call_dataset_workflow_state,\n", " call_datasetImport_workflow_state,\n", " call_receipe_solution_workflow_state,\n", " call_campaign_solution_workflow_state\n", " ])" ] }, { "cell_type": "code", "execution_count": 948, "metadata": {}, "outputs": [], "source": [ "Main_workflow = Workflow(\n", " name=\"Main-workflow\",\n", " definition=Main_workflow_definition,\n", " role=workflow_execution_role\n", ")" ] }, { "cell_type": "code", "execution_count": 949, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 949, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Main_workflow.render_graph()" ] }, { "cell_type": "code", "execution_count": 950, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow created successfully on AWS Step Functions.\u001b[0m\n" ] }, { "data": { "text/plain": [ "'arn:aws:states:us-east-1:261602857181:stateMachine:Main-workflow'" ] }, "execution_count": 950, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Main_workflow.create()" ] }, { "cell_type": "code", "execution_count": 951, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow execution started successfully on AWS Step Functions.\u001b[0m\n" ] } ], "source": [ "Main_workflow_execution = Main_workflow.execute()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Main_workflow_execution = Workflow(\n", " name=\"Campaign_Workflow\",\n", " definition=path1,\n", " role=workflow_execution_role\n", ")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 952, "metadata": {}, "outputs": [], "source": [ "#Main_workflow_execution.render_graph()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create and execute the workflow\n", "\n", "In the next cells, we will create the branching happy workflow in AWS Step Functions with [create](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Workflow.create) and execute it with [execute](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Workflow.execute).\n" ] }, { "cell_type": "code", "execution_count": 953, "metadata": {}, "outputs": [], "source": [ "#personalize_workflow.create()" ] }, { "cell_type": "code", "execution_count": 954, "metadata": {}, "outputs": [], "source": [ "#personalize_workflow_execution = happy_workflow.execute()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Review the workflow progress\n", "\n", "Review the workflow progress with the [render_progress](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Execution.render_progress).\n", "\n", "Review the execution history by calling [list_events](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Execution.list_events) to list all events in the workflow execution." ] }, { "cell_type": "code", "execution_count": 962, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", "
\n", "
    \n", "
  • \n", "
    \n", " Success\n", "
  • \n", "
  • \n", "
    \n", " Failed\n", "
  • \n", "
  • \n", "
    \n", " Cancelled\n", "
  • \n", "
  • \n", "
    \n", " In Progress\n", "
  • \n", "
  • \n", "
    \n", " Caught Error\n", "
  • \n", "
\n", "
\n", "\n", " \n", " Inspect in AWS Step Functions \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 962, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Main_workflow_execution.render_progress()" ] }, { "cell_type": "code", "execution_count": 963, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "
IDTypeStepResourceElapsed Time (ms)Timestamp
\n", "
\n", " 1\n", "
ExecutionStarted-0.0Jan 05, 2021 10:27:34.744 PM
\n", "
{\n",
       "    \"input\": {},\n",
       "    \"roleArn\": \"arn:aws:iam::261602857181:role/StepFunctionsWorkflowExecutionRole\"\n",
       "}
\n", "
\n", "
\n", " 2\n", "
TaskStateEnteredDataSetWorkflow-35.0Jan 05, 2021 10:27:34.779 PM
\n", "
{\n",
       "    \"name\": \"DataSetWorkflow\",\n",
       "    \"input\": {}\n",
       "}
\n", "
\n", "
\n", " 3\n", "
TaskScheduledDataSetWorkflowStep Functions execution35.0Jan 05, 2021 10:27:34.779 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"region\": \"us-east-1\",\n",
       "    \"parameters\": {\n",
       "        \"Input\": \"true\",\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Dataset-workflow\"\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 4\n", "
TaskStartedDataSetWorkflowStep Functions execution73.0Jan 05, 2021 10:27:34.817 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\"\n",
       "}
\n", "
\n", "
\n", " 5\n", "
TaskSubmittedDataSetWorkflowStep Functions execution180.0Jan 05, 2021 10:27:34.924 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Dataset-workflow:8184d018-96a2-4bf5-8afe-b0e08b675813\",\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"937c7020-0a76-4ed5-80b7-6d22f9c8163d\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"149\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/x-amz-json-1.0\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Content-Length\": \"149\",\n",
       "                \"Content-Type\": \"application/x-amz-json-1.0\",\n",
       "                \"x-amzn-RequestId\": \"937c7020-0a76-4ed5-80b7-6d22f9c8163d\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"937c7020-0a76-4ed5-80b7-6d22f9c8163d\"\n",
       "        },\n",
       "        \"StartDate\": 1609885654868\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 6\n", "
TaskSucceededDataSetWorkflowStep Functions execution135.0Jan 05, 2021 10:28:13.879 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Dataset-workflow:8184d018-96a2-4bf5-8afe-b0e08b675813\",\n",
       "        \"Input\": true,\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"8184d018-96a2-4bf5-8afe-b0e08b675813\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"DatasetGroup\": \"ACTIVE\",\n",
       "                \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\",\n",
       "                \"schemaArn\": \"arn:aws:personalize:us-east-1:261602857181:schema/personalize-stepfunction-schema3484\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"3d098791-f078-499d-94ac-336d6d0568bc\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"266\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 22:28:12 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4e7fb-0cae1ef66afb50a23fc5d67c;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"266\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 22:28:12 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"3d098791-f078-499d-94ac-336d6d0568bc\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4e7fb-0cae1ef66afb50a23fc5d67c;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"3d098791-f078-499d-94ac-336d6d0568bc\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609885654868,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Dataset-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609885692401\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 7\n", "
TaskStateExitedDataSetWorkflow-135.0Jan 05, 2021 10:28:13.879 PM
\n", "
{\n",
       "    \"name\": \"DataSetWorkflow\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Dataset-workflow:8184d018-96a2-4bf5-8afe-b0e08b675813\",\n",
       "        \"Input\": true,\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"8184d018-96a2-4bf5-8afe-b0e08b675813\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"DatasetGroup\": \"ACTIVE\",\n",
       "                \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\",\n",
       "                \"schemaArn\": \"arn:aws:personalize:us-east-1:261602857181:schema/personalize-stepfunction-schema3484\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"3d098791-f078-499d-94ac-336d6d0568bc\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"266\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 22:28:12 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4e7fb-0cae1ef66afb50a23fc5d67c;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"266\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 22:28:12 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"3d098791-f078-499d-94ac-336d6d0568bc\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4e7fb-0cae1ef66afb50a23fc5d67c;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"3d098791-f078-499d-94ac-336d6d0568bc\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609885654868,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Dataset-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609885692401\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 8\n", "
TaskStateEnteredDataSetImportWorkflow-142.0Jan 05, 2021 10:28:13.886 PM
\n", "
{\n",
       "    \"name\": \"DataSetImportWorkflow\",\n",
       "    \"input\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Dataset-workflow:8184d018-96a2-4bf5-8afe-b0e08b675813\",\n",
       "        \"Input\": true,\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"8184d018-96a2-4bf5-8afe-b0e08b675813\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"DatasetGroup\": \"ACTIVE\",\n",
       "                \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\",\n",
       "                \"schemaArn\": \"arn:aws:personalize:us-east-1:261602857181:schema/personalize-stepfunction-schema3484\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"3d098791-f078-499d-94ac-336d6d0568bc\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"266\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 22:28:12 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4e7fb-0cae1ef66afb50a23fc5d67c;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"266\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 22:28:12 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"3d098791-f078-499d-94ac-336d6d0568bc\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4e7fb-0cae1ef66afb50a23fc5d67c;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"3d098791-f078-499d-94ac-336d6d0568bc\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609885654868,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Dataset-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609885692401\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 9\n", "
TaskScheduledDataSetImportWorkflowStep Functions execution142.0Jan 05, 2021 10:28:13.886 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"region\": \"us-east-1\",\n",
       "    \"parameters\": {\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\",\n",
       "            \"schemaArn\": \"arn:aws:personalize:us-east-1:261602857181:schema/personalize-stepfunction-schema3484\"\n",
       "        },\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:DatasetImport-workflow\"\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 10\n", "
TaskStartedDataSetImportWorkflowStep Functions execution156.0Jan 05, 2021 10:28:13.900 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\"\n",
       "}
\n", "
\n", "
\n", " 11\n", "
TaskSubmittedDataSetImportWorkflowStep Functions execution272.0Jan 05, 2021 10:28:14.016 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:DatasetImport-workflow:31aa4b58-7359-4e8d-b038-44f77c0ba1ed\",\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"2b5ae6d7-78ba-451f-be9d-cc1b4e884817\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"155\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/x-amz-json-1.0\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Content-Length\": \"155\",\n",
       "                \"Content-Type\": \"application/x-amz-json-1.0\",\n",
       "                \"x-amzn-RequestId\": \"2b5ae6d7-78ba-451f-be9d-cc1b4e884817\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"2b5ae6d7-78ba-451f-be9d-cc1b4e884817\"\n",
       "        },\n",
       "        \"StartDate\": 1609885693964\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 12\n", "
TaskSucceededDataSetImportWorkflowStep Functions execution620.0Jan 05, 2021 10:44:26.364 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:DatasetImport-workflow:31aa4b58-7359-4e8d-b038-44f77c0ba1ed\",\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\",\n",
       "            \"schemaArn\": \"arn:aws:personalize:us-east-1:261602857181:schema/personalize-stepfunction-schema3484\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"31aa4b58-7359-4e8d-b038-44f77c0ba1ed\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"dataset_import_job_arn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-import-job/stepfunction-dataset-import-job\",\n",
       "                \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"261\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 22:44:24 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4ebc8-7643934c513081361af6bba8;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"261\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 22:44:24 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4ebc8-7643934c513081361af6bba8;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609885693964,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:DatasetImport-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609886664841\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 13\n", "
TaskStateExitedDataSetImportWorkflow-620.0Jan 05, 2021 10:44:26.364 PM
\n", "
{\n",
       "    \"name\": \"DataSetImportWorkflow\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:DatasetImport-workflow:31aa4b58-7359-4e8d-b038-44f77c0ba1ed\",\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\",\n",
       "            \"schemaArn\": \"arn:aws:personalize:us-east-1:261602857181:schema/personalize-stepfunction-schema3484\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"31aa4b58-7359-4e8d-b038-44f77c0ba1ed\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"dataset_import_job_arn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-import-job/stepfunction-dataset-import-job\",\n",
       "                \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"261\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 22:44:24 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4ebc8-7643934c513081361af6bba8;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"261\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 22:44:24 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4ebc8-7643934c513081361af6bba8;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609885693964,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:DatasetImport-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609886664841\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 14\n", "
TaskStateEnteredReceipeSolutionWorkflow-637.0Jan 05, 2021 10:44:26.381 PM
\n", "
{\n",
       "    \"name\": \"ReceipeSolutionWorkflow\",\n",
       "    \"input\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:DatasetImport-workflow:31aa4b58-7359-4e8d-b038-44f77c0ba1ed\",\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\",\n",
       "            \"schemaArn\": \"arn:aws:personalize:us-east-1:261602857181:schema/personalize-stepfunction-schema3484\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"31aa4b58-7359-4e8d-b038-44f77c0ba1ed\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"dataset_import_job_arn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-import-job/stepfunction-dataset-import-job\",\n",
       "                \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"261\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 22:44:24 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4ebc8-7643934c513081361af6bba8;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"261\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 22:44:24 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4ebc8-7643934c513081361af6bba8;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"4ebd9e5a-4f44-483f-978b-c7bd05eacb25\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609885693964,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:DatasetImport-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609886664841\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 15\n", "
TaskScheduledReceipeSolutionWorkflowStep Functions execution637.0Jan 05, 2021 10:44:26.381 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"region\": \"us-east-1\",\n",
       "    \"parameters\": {\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\"\n",
       "        },\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Create_receipe_sol-workflow\"\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 16\n", "
TaskStartedReceipeSolutionWorkflowStep Functions execution696.0Jan 05, 2021 10:44:26.440 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\"\n",
       "}
\n", "
\n", "
\n", " 17\n", "
TaskSubmittedReceipeSolutionWorkflowStep Functions execution822.0Jan 05, 2021 10:44:26.566 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Create_receipe_sol-workflow:0b411a66-f56a-4a1b-a4f7-3de0cbf3dc15\",\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"89aad166-d1ad-4d2c-87db-d5ce8cce5682\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"160\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/x-amz-json-1.0\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Content-Length\": \"160\",\n",
       "                \"Content-Type\": \"application/x-amz-json-1.0\",\n",
       "                \"x-amzn-RequestId\": \"89aad166-d1ad-4d2c-87db-d5ce8cce5682\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"89aad166-d1ad-4d2c-87db-d5ce8cce5682\"\n",
       "        },\n",
       "        \"StartDate\": 1609886666506\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 18\n", "
TaskSucceededReceipeSolutionWorkflowStep Functions execution117.0Jan 05, 2021 11:26:13.861 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Create_receipe_sol-workflow:0b411a66-f56a-4a1b-a4f7-3de0cbf3dc15\",\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"0b411a66-f56a-4a1b-a4f7-3de0cbf3dc15\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"solution_version_arn\": \"arn:aws:personalize:us-east-1:261602857181:solution/stepfunction-solution/645628f1\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"1c715eee-f2f2-449f-adba-980e3d43b22e\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"130\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 23:26:11 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4f593-3b270cb957b7bfb462f6d07f;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"130\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 23:26:11 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"1c715eee-f2f2-449f-adba-980e3d43b22e\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4f593-3b270cb957b7bfb462f6d07f;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"1c715eee-f2f2-449f-adba-980e3d43b22e\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609886666506,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Create_receipe_sol-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609889171923\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 19\n", "
TaskStateExitedReceipeSolutionWorkflow-117.0Jan 05, 2021 11:26:13.861 PM
\n", "
{\n",
       "    \"name\": \"ReceipeSolutionWorkflow\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Create_receipe_sol-workflow:0b411a66-f56a-4a1b-a4f7-3de0cbf3dc15\",\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"0b411a66-f56a-4a1b-a4f7-3de0cbf3dc15\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"solution_version_arn\": \"arn:aws:personalize:us-east-1:261602857181:solution/stepfunction-solution/645628f1\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"1c715eee-f2f2-449f-adba-980e3d43b22e\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"130\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 23:26:11 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4f593-3b270cb957b7bfb462f6d07f;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"130\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 23:26:11 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"1c715eee-f2f2-449f-adba-980e3d43b22e\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4f593-3b270cb957b7bfb462f6d07f;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"1c715eee-f2f2-449f-adba-980e3d43b22e\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609886666506,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Create_receipe_sol-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609889171923\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 20\n", "
TaskStateEnteredCampaignWorkflow-124.0Jan 05, 2021 11:26:13.868 PM
\n", "
{\n",
       "    \"name\": \"CampaignWorkflow\",\n",
       "    \"input\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Create_receipe_sol-workflow:0b411a66-f56a-4a1b-a4f7-3de0cbf3dc15\",\n",
       "        \"Input\": {\n",
       "            \"datasetGroupArn\": \"arn:aws:personalize:us-east-1:261602857181:dataset-group/personalize-stepfunction-dataset-group\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"0b411a66-f56a-4a1b-a4f7-3de0cbf3dc15\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"solution_version_arn\": \"arn:aws:personalize:us-east-1:261602857181:solution/stepfunction-solution/645628f1\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"1c715eee-f2f2-449f-adba-980e3d43b22e\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"130\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 23:26:11 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4f593-3b270cb957b7bfb462f6d07f;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"130\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 23:26:11 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"1c715eee-f2f2-449f-adba-980e3d43b22e\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4f593-3b270cb957b7bfb462f6d07f;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"1c715eee-f2f2-449f-adba-980e3d43b22e\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609886666506,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Create_receipe_sol-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609889171923\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 21\n", "
TaskScheduledCampaignWorkflowStep Functions execution124.0Jan 05, 2021 11:26:13.868 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"region\": \"us-east-1\",\n",
       "    \"parameters\": {\n",
       "        \"Input\": {\n",
       "            \"solution_version_arn\": \"arn:aws:personalize:us-east-1:261602857181:solution/stepfunction-solution/645628f1\"\n",
       "        },\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Campaign-workflow\"\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 22\n", "
TaskStartedCampaignWorkflowStep Functions execution136.0Jan 05, 2021 11:26:13.880 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\"\n",
       "}
\n", "
\n", "
\n", " 23\n", "
TaskSubmittedCampaignWorkflowStep Functions execution260.0Jan 05, 2021 11:26:14.004 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Campaign-workflow:4460dc18-54f6-4194-9d18-d95e97307f5e\",\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"1031db9d-b435-4f01-93ae-30561ad903fd\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"150\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/x-amz-json-1.0\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Content-Length\": \"150\",\n",
       "                \"Content-Type\": \"application/x-amz-json-1.0\",\n",
       "                \"x-amzn-RequestId\": \"1031db9d-b435-4f01-93ae-30561ad903fd\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"1031db9d-b435-4f01-93ae-30561ad903fd\"\n",
       "        },\n",
       "        \"StartDate\": 1609889173951\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 24\n", "
TaskSucceededCampaignWorkflowStep Functions execution341.0Jan 05, 2021 11:36:20.085 PM
\n", "
{\n",
       "    \"resourceType\": \"states\",\n",
       "    \"resource\": \"startExecution.sync:2\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Campaign-workflow:4460dc18-54f6-4194-9d18-d95e97307f5e\",\n",
       "        \"Input\": {\n",
       "            \"solution_version_arn\": \"arn:aws:personalize:us-east-1:261602857181:solution/stepfunction-solution/645628f1\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"4460dc18-54f6-4194-9d18-d95e97307f5e\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"campaign_arn\": \"arn:aws:personalize:us-east-1:261602857181:campaign/stepfunction-campaign\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"bdc39ad0-171d-4866-9166-4324e335a52e\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"113\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 23:35:48 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4f7d4-0d568a60206a710d689eeec8;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"113\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 23:35:48 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"bdc39ad0-171d-4866-9166-4324e335a52e\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4f7d4-0d568a60206a710d689eeec8;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"bdc39ad0-171d-4866-9166-4324e335a52e\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609889173951,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Campaign-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609889778805\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 25\n", "
TaskStateExitedCampaignWorkflow-341.0Jan 05, 2021 11:36:20.085 PM
\n", "
{\n",
       "    \"name\": \"CampaignWorkflow\",\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Campaign-workflow:4460dc18-54f6-4194-9d18-d95e97307f5e\",\n",
       "        \"Input\": {\n",
       "            \"solution_version_arn\": \"arn:aws:personalize:us-east-1:261602857181:solution/stepfunction-solution/645628f1\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"4460dc18-54f6-4194-9d18-d95e97307f5e\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"campaign_arn\": \"arn:aws:personalize:us-east-1:261602857181:campaign/stepfunction-campaign\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"bdc39ad0-171d-4866-9166-4324e335a52e\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"113\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 23:35:48 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4f7d4-0d568a60206a710d689eeec8;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"113\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 23:35:48 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"bdc39ad0-171d-4866-9166-4324e335a52e\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4f7d4-0d568a60206a710d689eeec8;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"bdc39ad0-171d-4866-9166-4324e335a52e\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609889173951,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Campaign-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609889778805\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 26\n", "
ExecutionSucceeded-341.0Jan 05, 2021 11:36:20.085 PM
\n", "
{\n",
       "    \"output\": {\n",
       "        \"ExecutionArn\": \"arn:aws:states:us-east-1:261602857181:execution:Campaign-workflow:4460dc18-54f6-4194-9d18-d95e97307f5e\",\n",
       "        \"Input\": {\n",
       "            \"solution_version_arn\": \"arn:aws:personalize:us-east-1:261602857181:solution/stepfunction-solution/645628f1\"\n",
       "        },\n",
       "        \"InputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"Name\": \"4460dc18-54f6-4194-9d18-d95e97307f5e\",\n",
       "        \"Output\": {\n",
       "            \"ExecutedVersion\": \"$LATEST\",\n",
       "            \"Payload\": {\n",
       "                \"status\": \"ACTIVE\",\n",
       "                \"campaign_arn\": \"arn:aws:personalize:us-east-1:261602857181:campaign/stepfunction-campaign\"\n",
       "            },\n",
       "            \"SdkHttpMetadata\": {\n",
       "                \"AllHttpHeaders\": {\n",
       "                    \"X-Amz-Executed-Version\": [\n",
       "                        \"$LATEST\"\n",
       "                    ],\n",
       "                    \"x-amzn-Remapped-Content-Length\": [\n",
       "                        \"0\"\n",
       "                    ],\n",
       "                    \"Connection\": [\n",
       "                        \"keep-alive\"\n",
       "                    ],\n",
       "                    \"x-amzn-RequestId\": [\n",
       "                        \"bdc39ad0-171d-4866-9166-4324e335a52e\"\n",
       "                    ],\n",
       "                    \"Content-Length\": [\n",
       "                        \"113\"\n",
       "                    ],\n",
       "                    \"Date\": [\n",
       "                        \"Tue, 05 Jan 2021 23:35:48 GMT\"\n",
       "                    ],\n",
       "                    \"X-Amzn-Trace-Id\": [\n",
       "                        \"root=1-5ff4f7d4-0d568a60206a710d689eeec8;sampled=0\"\n",
       "                    ],\n",
       "                    \"Content-Type\": [\n",
       "                        \"application/json\"\n",
       "                    ]\n",
       "                },\n",
       "                \"HttpHeaders\": {\n",
       "                    \"Connection\": \"keep-alive\",\n",
       "                    \"Content-Length\": \"113\",\n",
       "                    \"Content-Type\": \"application/json\",\n",
       "                    \"Date\": \"Tue, 05 Jan 2021 23:35:48 GMT\",\n",
       "                    \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                    \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                    \"x-amzn-RequestId\": \"bdc39ad0-171d-4866-9166-4324e335a52e\",\n",
       "                    \"X-Amzn-Trace-Id\": \"root=1-5ff4f7d4-0d568a60206a710d689eeec8;sampled=0\"\n",
       "                },\n",
       "                \"HttpStatusCode\": 200\n",
       "            },\n",
       "            \"SdkResponseMetadata\": {\n",
       "                \"RequestId\": \"bdc39ad0-171d-4866-9166-4324e335a52e\"\n",
       "            },\n",
       "            \"StatusCode\": 200\n",
       "        },\n",
       "        \"OutputDetails\": {\n",
       "            \"Included\": true\n",
       "        },\n",
       "        \"StartDate\": 1609889173951,\n",
       "        \"StateMachineArn\": \"arn:aws:states:us-east-1:261602857181:stateMachine:Campaign-workflow\",\n",
       "        \"Status\": \"SUCCEEDED\",\n",
       "        \"StopDate\": 1609889778805\n",
       "    }\n",
       "}
\n", "
\n", " \n" ], "text/plain": [ "" ] }, "execution_count": 963, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Main_workflow_execution.list_events(html=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate-Recommendations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Now that we have a successful campaign, let's generate recommendations for the campaign" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Select a User and an Item" ] }, { "cell_type": "code", "execution_count": 964, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "user_id 402\n", "items ITEM_ID TITLE\n", "0 2 GoldenEye (1995)\n", "1 3 Four Rooms (1995)\n", "... ... ...\n", "1679 1681 You So Crazy (1994)\n", "1680 1682 Scream of Stone (Schrei aus Stein) (1991)\n", "\n", "[1681 rows x 2 columns]\n", "USER: 402\n", "ITEM: Aladdin (1992)\n", "ITEM ID: 95\n" ] } ], "source": [ "items = pd.read_csv('./ml-100k/u.item', sep='|', usecols=[0,1], encoding='latin-1')\n", "items.columns = ['ITEM_ID', 'TITLE']\n", "\n", "\n", "user_id, item_id, rating, timestamp = data.sample().values[0]\n", "\n", "user_id = int(user_id)\n", "item_id = int(item_id)\n", "\n", "print(\"user_id\",user_id)\n", "print(\"items\",items)\n", "\n", "\n", "item_title = items.loc[items['ITEM_ID'] == item_id].values[0][-1]\n", "print(\"USER: {}\".format(user_id))\n", "print(\"ITEM: {}\".format(item_title))\n", "print(\"ITEM ID: {}\".format(item_id))\n" ] }, { "cell_type": "code", "execution_count": 965, "metadata": {}, "outputs": [], "source": [ "wait_recommendations = Wait(\n", " state_id=\"Wait for recommendations - 10 secs\",\n", " seconds=10\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Lambda Task" ] }, { "cell_type": "code", "execution_count": 966, "metadata": {}, "outputs": [], "source": [ "lambda_state_get_recommendations = LambdaStep(\n", " state_id=\"get recommendations\",\n", " parameters={ \n", " \"FunctionName\": \"stepfunction_getRecommendations\", \n", " \"Payload\": { \n", " \"campaign_arn\": 'arn:aws:personalize:us-east-1:261602857181:campaign/stepfunction-campaign', \n", " \"user_id\": user_id, \n", " \"item_id\": item_id \n", " }\n", " },\n", " result_path = '$'\n", ")\n", "\n", "lambda_state_get_recommendations.add_retry(Retry(\n", " error_equals=[\"States.TaskFailed\"],\n", " interval_seconds=5,\n", " max_attempts=1,\n", " backoff_rate=4.0\n", "))\n", "\n", "lambda_state_get_recommendations.add_catch(Catch(\n", " error_equals=[\"States.TaskFailed\"],\n", " next_step=Fail(\"GetRecommendationTaskFailed\")\n", " #next_step=recommendation_path \n", "))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create a Succeed State" ] }, { "cell_type": "code", "execution_count": 967, "metadata": {}, "outputs": [], "source": [ "workflow_complete = Succeed(\"WorkflowComplete\")" ] }, { "cell_type": "code", "execution_count": 968, "metadata": {}, "outputs": [], "source": [ "recommendation_path = Chain([ \n", "lambda_state_get_recommendations,\n", "wait_recommendations,\n", "workflow_complete\n", "])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Define, Create, Render, and Execute Recommendation Workflow\n", "\n", "In the next cells, we will create a workflow in AWS Step Functions with [create](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Workflow.create) and execute it with [execute](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Workflow.execute)." ] }, { "cell_type": "code", "execution_count": 969, "metadata": {}, "outputs": [], "source": [ "recommendation_workflow = Workflow(\n", " name=\"Recommendation_Workflow4\",\n", " definition=recommendation_path,\n", " role=workflow_execution_role\n", ")\n", "\n" ] }, { "cell_type": "code", "execution_count": 970, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 970, "metadata": {}, "output_type": "execute_result" } ], "source": [ "recommendation_workflow.render_graph()" ] }, { "cell_type": "code", "execution_count": 971, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow created successfully on AWS Step Functions.\u001b[0m\n" ] }, { "data": { "text/plain": [ "'arn:aws:states:us-east-1:261602857181:stateMachine:Recommendation_Workflow4'" ] }, "execution_count": 971, "metadata": {}, "output_type": "execute_result" } ], "source": [ "recommendation_workflow.create()" ] }, { "cell_type": "code", "execution_count": 972, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow execution started successfully on AWS Step Functions.\u001b[0m\n" ] } ], "source": [ "recommendation_workflow_execution = recommendation_workflow.execute()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Review progress\n", "\n", "Review workflow progress with the [render_progress](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Execution.render_progress).\n", "\n", "Review execution history by calling [list_events](https://aws-step-functions-data-science-sdk.readthedocs.io/en/latest/workflow.html#stepfunctions.workflow.Execution.list_events) to list all events in the workflow execution." ] }, { "cell_type": "code", "execution_count": 975, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", " \n", " \n", "
\n", "
    \n", "
  • \n", "
    \n", " Success\n", "
  • \n", "
  • \n", "
    \n", " Failed\n", "
  • \n", "
  • \n", "
    \n", " Cancelled\n", "
  • \n", "
  • \n", "
    \n", " In Progress\n", "
  • \n", "
  • \n", "
    \n", " Caught Error\n", "
  • \n", "
\n", "
\n", "\n", " \n", " Inspect in AWS Step Functions \n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 975, "metadata": {}, "output_type": "execute_result" } ], "source": [ "recommendation_workflow_execution.render_progress()" ] }, { "cell_type": "code", "execution_count": 976, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "
IDTypeStepResourceElapsed Time (ms)Timestamp
\n", "
\n", " 1\n", "
ExecutionStarted-0.0Jan 05, 2021 11:48:47.128 PM
\n", "
{\n",
       "    \"input\": {},\n",
       "    \"roleArn\": \"arn:aws:iam::261602857181:role/StepFunctionsWorkflowExecutionRole\"\n",
       "}
\n", "
\n", "
\n", " 2\n", "
TaskStateEnteredget recommendations-35.0Jan 05, 2021 11:48:47.163 PM
\n", "
{\n",
       "    \"name\": \"get recommendations\",\n",
       "    \"input\": {}\n",
       "}
\n", "
\n", "
\n", " 3\n", "
TaskScheduledget recommendationsStep Functions execution35.0Jan 05, 2021 11:48:47.163 PM
\n", "
{\n",
       "    \"resourceType\": \"lambda\",\n",
       "    \"resource\": \"invoke\",\n",
       "    \"region\": \"us-east-1\",\n",
       "    \"parameters\": {\n",
       "        \"FunctionName\": \"stepfunction_getRecommendations\",\n",
       "        \"Payload\": {\n",
       "            \"campaign_arn\": \"arn:aws:personalize:us-east-1:261602857181:campaign/stepfunction-campaign\",\n",
       "            \"user_id\": 402,\n",
       "            \"item_id\": 95\n",
       "        }\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 4\n", "
TaskStartedget recommendationsStep Functions execution73.0Jan 05, 2021 11:48:47.201 PM
\n", "
{\n",
       "    \"resourceType\": \"lambda\",\n",
       "    \"resource\": \"invoke\"\n",
       "}
\n", "
\n", "
\n", " 5\n", "
TaskSucceededget recommendationsStep Functions execution253.0Jan 05, 2021 11:48:48.381 PM
\n", "
{\n",
       "    \"resourceType\": \"lambda\",\n",
       "    \"resource\": \"invoke\",\n",
       "    \"output\": {\n",
       "        \"ExecutedVersion\": \"$LATEST\",\n",
       "        \"Payload\": {\n",
       "            \"item_list\": [\n",
       "                {\n",
       "                    \"itemId\": \"143\",\n",
       "                    \"score\": 0.0304744\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"174\",\n",
       "                    \"score\": 0.0299079\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"588\",\n",
       "                    \"score\": 0.0254778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"99\",\n",
       "                    \"score\": 0.0196287\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"210\",\n",
       "                    \"score\": 0.0184811\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"432\",\n",
       "                    \"score\": 0.01776\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"173\",\n",
       "                    \"score\": 0.0170072\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"172\",\n",
       "                    \"score\": 0.0163306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"195\",\n",
       "                    \"score\": 0.0146565\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"357\",\n",
       "                    \"score\": 0.0144201\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"483\",\n",
       "                    \"score\": 0.0140931\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"196\",\n",
       "                    \"score\": 0.0136761\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"79\",\n",
       "                    \"score\": 0.0114862\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"197\",\n",
       "                    \"score\": 0.0112875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"211\",\n",
       "                    \"score\": 0.0111778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"168\",\n",
       "                    \"score\": 0.0107306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"71\",\n",
       "                    \"score\": 0.0098636\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"28\",\n",
       "                    \"score\": 0.0097188\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"216\",\n",
       "                    \"score\": 0.009477\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"485\",\n",
       "                    \"score\": 0.0092875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"205\",\n",
       "                    \"score\": 0.0092582\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"969\",\n",
       "                    \"score\": 0.0092435\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"479\",\n",
       "                    \"score\": 0.0090261\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"95\",\n",
       "                    \"score\": 0.0089939\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"318\",\n",
       "                    \"score\": 0.0089615\n",
       "                }\n",
       "            ]\n",
       "        },\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"X-Amz-Executed-Version\": [\n",
       "                    \"$LATEST\"\n",
       "                ],\n",
       "                \"x-amzn-Remapped-Content-Length\": [\n",
       "                    \"0\"\n",
       "                ],\n",
       "                \"Connection\": [\n",
       "                    \"keep-alive\"\n",
       "                ],\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"982\"\n",
       "                ],\n",
       "                \"Date\": [\n",
       "                    \"Tue, 05 Jan 2021 23:48:48 GMT\"\n",
       "                ],\n",
       "                \"X-Amzn-Trace-Id\": [\n",
       "                    \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/json\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Connection\": \"keep-alive\",\n",
       "                \"Content-Length\": \"982\",\n",
       "                \"Content-Type\": \"application/json\",\n",
       "                \"Date\": \"Tue, 05 Jan 2021 23:48:48 GMT\",\n",
       "                \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                \"x-amzn-RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\",\n",
       "                \"X-Amzn-Trace-Id\": \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "        },\n",
       "        \"StatusCode\": 200\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 6\n", "
TaskStateExitedget recommendations-253.0Jan 05, 2021 11:48:48.381 PM
\n", "
{\n",
       "    \"name\": \"get recommendations\",\n",
       "    \"output\": {\n",
       "        \"ExecutedVersion\": \"$LATEST\",\n",
       "        \"Payload\": {\n",
       "            \"item_list\": [\n",
       "                {\n",
       "                    \"itemId\": \"143\",\n",
       "                    \"score\": 0.0304744\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"174\",\n",
       "                    \"score\": 0.0299079\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"588\",\n",
       "                    \"score\": 0.0254778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"99\",\n",
       "                    \"score\": 0.0196287\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"210\",\n",
       "                    \"score\": 0.0184811\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"432\",\n",
       "                    \"score\": 0.01776\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"173\",\n",
       "                    \"score\": 0.0170072\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"172\",\n",
       "                    \"score\": 0.0163306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"195\",\n",
       "                    \"score\": 0.0146565\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"357\",\n",
       "                    \"score\": 0.0144201\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"483\",\n",
       "                    \"score\": 0.0140931\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"196\",\n",
       "                    \"score\": 0.0136761\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"79\",\n",
       "                    \"score\": 0.0114862\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"197\",\n",
       "                    \"score\": 0.0112875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"211\",\n",
       "                    \"score\": 0.0111778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"168\",\n",
       "                    \"score\": 0.0107306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"71\",\n",
       "                    \"score\": 0.0098636\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"28\",\n",
       "                    \"score\": 0.0097188\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"216\",\n",
       "                    \"score\": 0.009477\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"485\",\n",
       "                    \"score\": 0.0092875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"205\",\n",
       "                    \"score\": 0.0092582\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"969\",\n",
       "                    \"score\": 0.0092435\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"479\",\n",
       "                    \"score\": 0.0090261\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"95\",\n",
       "                    \"score\": 0.0089939\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"318\",\n",
       "                    \"score\": 0.0089615\n",
       "                }\n",
       "            ]\n",
       "        },\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"X-Amz-Executed-Version\": [\n",
       "                    \"$LATEST\"\n",
       "                ],\n",
       "                \"x-amzn-Remapped-Content-Length\": [\n",
       "                    \"0\"\n",
       "                ],\n",
       "                \"Connection\": [\n",
       "                    \"keep-alive\"\n",
       "                ],\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"982\"\n",
       "                ],\n",
       "                \"Date\": [\n",
       "                    \"Tue, 05 Jan 2021 23:48:48 GMT\"\n",
       "                ],\n",
       "                \"X-Amzn-Trace-Id\": [\n",
       "                    \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/json\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Connection\": \"keep-alive\",\n",
       "                \"Content-Length\": \"982\",\n",
       "                \"Content-Type\": \"application/json\",\n",
       "                \"Date\": \"Tue, 05 Jan 2021 23:48:48 GMT\",\n",
       "                \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                \"x-amzn-RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\",\n",
       "                \"X-Amzn-Trace-Id\": \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "        },\n",
       "        \"StatusCode\": 200\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 7\n", "
WaitStateEnteredWait for recommendations - 10 secs-260.0Jan 05, 2021 11:48:48.388 PM
\n", "
{\n",
       "    \"name\": \"Wait for recommendations - 10 secs\",\n",
       "    \"input\": {\n",
       "        \"ExecutedVersion\": \"$LATEST\",\n",
       "        \"Payload\": {\n",
       "            \"item_list\": [\n",
       "                {\n",
       "                    \"itemId\": \"143\",\n",
       "                    \"score\": 0.0304744\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"174\",\n",
       "                    \"score\": 0.0299079\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"588\",\n",
       "                    \"score\": 0.0254778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"99\",\n",
       "                    \"score\": 0.0196287\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"210\",\n",
       "                    \"score\": 0.0184811\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"432\",\n",
       "                    \"score\": 0.01776\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"173\",\n",
       "                    \"score\": 0.0170072\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"172\",\n",
       "                    \"score\": 0.0163306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"195\",\n",
       "                    \"score\": 0.0146565\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"357\",\n",
       "                    \"score\": 0.0144201\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"483\",\n",
       "                    \"score\": 0.0140931\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"196\",\n",
       "                    \"score\": 0.0136761\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"79\",\n",
       "                    \"score\": 0.0114862\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"197\",\n",
       "                    \"score\": 0.0112875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"211\",\n",
       "                    \"score\": 0.0111778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"168\",\n",
       "                    \"score\": 0.0107306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"71\",\n",
       "                    \"score\": 0.0098636\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"28\",\n",
       "                    \"score\": 0.0097188\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"216\",\n",
       "                    \"score\": 0.009477\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"485\",\n",
       "                    \"score\": 0.0092875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"205\",\n",
       "                    \"score\": 0.0092582\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"969\",\n",
       "                    \"score\": 0.0092435\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"479\",\n",
       "                    \"score\": 0.0090261\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"95\",\n",
       "                    \"score\": 0.0089939\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"318\",\n",
       "                    \"score\": 0.0089615\n",
       "                }\n",
       "            ]\n",
       "        },\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"X-Amz-Executed-Version\": [\n",
       "                    \"$LATEST\"\n",
       "                ],\n",
       "                \"x-amzn-Remapped-Content-Length\": [\n",
       "                    \"0\"\n",
       "                ],\n",
       "                \"Connection\": [\n",
       "                    \"keep-alive\"\n",
       "                ],\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"982\"\n",
       "                ],\n",
       "                \"Date\": [\n",
       "                    \"Tue, 05 Jan 2021 23:48:48 GMT\"\n",
       "                ],\n",
       "                \"X-Amzn-Trace-Id\": [\n",
       "                    \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/json\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Connection\": \"keep-alive\",\n",
       "                \"Content-Length\": \"982\",\n",
       "                \"Content-Type\": \"application/json\",\n",
       "                \"Date\": \"Tue, 05 Jan 2021 23:48:48 GMT\",\n",
       "                \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                \"x-amzn-RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\",\n",
       "                \"X-Amzn-Trace-Id\": \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "        },\n",
       "        \"StatusCode\": 200\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 8\n", "
WaitStateExitedWait for recommendations - 10 secs-260.0Jan 05, 2021 11:48:58.388 PM
\n", "
{\n",
       "    \"name\": \"Wait for recommendations - 10 secs\",\n",
       "    \"output\": {\n",
       "        \"ExecutedVersion\": \"$LATEST\",\n",
       "        \"Payload\": {\n",
       "            \"item_list\": [\n",
       "                {\n",
       "                    \"itemId\": \"143\",\n",
       "                    \"score\": 0.0304744\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"174\",\n",
       "                    \"score\": 0.0299079\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"588\",\n",
       "                    \"score\": 0.0254778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"99\",\n",
       "                    \"score\": 0.0196287\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"210\",\n",
       "                    \"score\": 0.0184811\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"432\",\n",
       "                    \"score\": 0.01776\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"173\",\n",
       "                    \"score\": 0.0170072\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"172\",\n",
       "                    \"score\": 0.0163306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"195\",\n",
       "                    \"score\": 0.0146565\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"357\",\n",
       "                    \"score\": 0.0144201\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"483\",\n",
       "                    \"score\": 0.0140931\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"196\",\n",
       "                    \"score\": 0.0136761\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"79\",\n",
       "                    \"score\": 0.0114862\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"197\",\n",
       "                    \"score\": 0.0112875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"211\",\n",
       "                    \"score\": 0.0111778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"168\",\n",
       "                    \"score\": 0.0107306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"71\",\n",
       "                    \"score\": 0.0098636\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"28\",\n",
       "                    \"score\": 0.0097188\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"216\",\n",
       "                    \"score\": 0.009477\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"485\",\n",
       "                    \"score\": 0.0092875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"205\",\n",
       "                    \"score\": 0.0092582\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"969\",\n",
       "                    \"score\": 0.0092435\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"479\",\n",
       "                    \"score\": 0.0090261\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"95\",\n",
       "                    \"score\": 0.0089939\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"318\",\n",
       "                    \"score\": 0.0089615\n",
       "                }\n",
       "            ]\n",
       "        },\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"X-Amz-Executed-Version\": [\n",
       "                    \"$LATEST\"\n",
       "                ],\n",
       "                \"x-amzn-Remapped-Content-Length\": [\n",
       "                    \"0\"\n",
       "                ],\n",
       "                \"Connection\": [\n",
       "                    \"keep-alive\"\n",
       "                ],\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"982\"\n",
       "                ],\n",
       "                \"Date\": [\n",
       "                    \"Tue, 05 Jan 2021 23:48:48 GMT\"\n",
       "                ],\n",
       "                \"X-Amzn-Trace-Id\": [\n",
       "                    \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/json\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Connection\": \"keep-alive\",\n",
       "                \"Content-Length\": \"982\",\n",
       "                \"Content-Type\": \"application/json\",\n",
       "                \"Date\": \"Tue, 05 Jan 2021 23:48:48 GMT\",\n",
       "                \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                \"x-amzn-RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\",\n",
       "                \"X-Amzn-Trace-Id\": \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "        },\n",
       "        \"StatusCode\": 200\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 9\n", "
SucceedStateEnteredWorkflowComplete-265.0Jan 05, 2021 11:48:58.393 PM
\n", "
{\n",
       "    \"name\": \"WorkflowComplete\",\n",
       "    \"input\": {\n",
       "        \"ExecutedVersion\": \"$LATEST\",\n",
       "        \"Payload\": {\n",
       "            \"item_list\": [\n",
       "                {\n",
       "                    \"itemId\": \"143\",\n",
       "                    \"score\": 0.0304744\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"174\",\n",
       "                    \"score\": 0.0299079\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"588\",\n",
       "                    \"score\": 0.0254778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"99\",\n",
       "                    \"score\": 0.0196287\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"210\",\n",
       "                    \"score\": 0.0184811\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"432\",\n",
       "                    \"score\": 0.01776\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"173\",\n",
       "                    \"score\": 0.0170072\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"172\",\n",
       "                    \"score\": 0.0163306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"195\",\n",
       "                    \"score\": 0.0146565\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"357\",\n",
       "                    \"score\": 0.0144201\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"483\",\n",
       "                    \"score\": 0.0140931\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"196\",\n",
       "                    \"score\": 0.0136761\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"79\",\n",
       "                    \"score\": 0.0114862\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"197\",\n",
       "                    \"score\": 0.0112875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"211\",\n",
       "                    \"score\": 0.0111778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"168\",\n",
       "                    \"score\": 0.0107306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"71\",\n",
       "                    \"score\": 0.0098636\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"28\",\n",
       "                    \"score\": 0.0097188\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"216\",\n",
       "                    \"score\": 0.009477\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"485\",\n",
       "                    \"score\": 0.0092875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"205\",\n",
       "                    \"score\": 0.0092582\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"969\",\n",
       "                    \"score\": 0.0092435\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"479\",\n",
       "                    \"score\": 0.0090261\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"95\",\n",
       "                    \"score\": 0.0089939\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"318\",\n",
       "                    \"score\": 0.0089615\n",
       "                }\n",
       "            ]\n",
       "        },\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"X-Amz-Executed-Version\": [\n",
       "                    \"$LATEST\"\n",
       "                ],\n",
       "                \"x-amzn-Remapped-Content-Length\": [\n",
       "                    \"0\"\n",
       "                ],\n",
       "                \"Connection\": [\n",
       "                    \"keep-alive\"\n",
       "                ],\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"982\"\n",
       "                ],\n",
       "                \"Date\": [\n",
       "                    \"Tue, 05 Jan 2021 23:48:48 GMT\"\n",
       "                ],\n",
       "                \"X-Amzn-Trace-Id\": [\n",
       "                    \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/json\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Connection\": \"keep-alive\",\n",
       "                \"Content-Length\": \"982\",\n",
       "                \"Content-Type\": \"application/json\",\n",
       "                \"Date\": \"Tue, 05 Jan 2021 23:48:48 GMT\",\n",
       "                \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                \"x-amzn-RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\",\n",
       "                \"X-Amzn-Trace-Id\": \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "        },\n",
       "        \"StatusCode\": 200\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 10\n", "
SucceedStateExitedWorkflowComplete-265.0Jan 05, 2021 11:48:58.393 PM
\n", "
{\n",
       "    \"name\": \"WorkflowComplete\",\n",
       "    \"output\": {\n",
       "        \"ExecutedVersion\": \"$LATEST\",\n",
       "        \"Payload\": {\n",
       "            \"item_list\": [\n",
       "                {\n",
       "                    \"itemId\": \"143\",\n",
       "                    \"score\": 0.0304744\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"174\",\n",
       "                    \"score\": 0.0299079\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"588\",\n",
       "                    \"score\": 0.0254778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"99\",\n",
       "                    \"score\": 0.0196287\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"210\",\n",
       "                    \"score\": 0.0184811\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"432\",\n",
       "                    \"score\": 0.01776\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"173\",\n",
       "                    \"score\": 0.0170072\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"172\",\n",
       "                    \"score\": 0.0163306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"195\",\n",
       "                    \"score\": 0.0146565\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"357\",\n",
       "                    \"score\": 0.0144201\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"483\",\n",
       "                    \"score\": 0.0140931\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"196\",\n",
       "                    \"score\": 0.0136761\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"79\",\n",
       "                    \"score\": 0.0114862\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"197\",\n",
       "                    \"score\": 0.0112875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"211\",\n",
       "                    \"score\": 0.0111778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"168\",\n",
       "                    \"score\": 0.0107306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"71\",\n",
       "                    \"score\": 0.0098636\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"28\",\n",
       "                    \"score\": 0.0097188\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"216\",\n",
       "                    \"score\": 0.009477\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"485\",\n",
       "                    \"score\": 0.0092875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"205\",\n",
       "                    \"score\": 0.0092582\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"969\",\n",
       "                    \"score\": 0.0092435\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"479\",\n",
       "                    \"score\": 0.0090261\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"95\",\n",
       "                    \"score\": 0.0089939\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"318\",\n",
       "                    \"score\": 0.0089615\n",
       "                }\n",
       "            ]\n",
       "        },\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"X-Amz-Executed-Version\": [\n",
       "                    \"$LATEST\"\n",
       "                ],\n",
       "                \"x-amzn-Remapped-Content-Length\": [\n",
       "                    \"0\"\n",
       "                ],\n",
       "                \"Connection\": [\n",
       "                    \"keep-alive\"\n",
       "                ],\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"982\"\n",
       "                ],\n",
       "                \"Date\": [\n",
       "                    \"Tue, 05 Jan 2021 23:48:48 GMT\"\n",
       "                ],\n",
       "                \"X-Amzn-Trace-Id\": [\n",
       "                    \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/json\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Connection\": \"keep-alive\",\n",
       "                \"Content-Length\": \"982\",\n",
       "                \"Content-Type\": \"application/json\",\n",
       "                \"Date\": \"Tue, 05 Jan 2021 23:48:48 GMT\",\n",
       "                \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                \"x-amzn-RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\",\n",
       "                \"X-Amzn-Trace-Id\": \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "        },\n",
       "        \"StatusCode\": 200\n",
       "    }\n",
       "}
\n", "
\n", "
\n", " 11\n", "
ExecutionSucceeded-265.0Jan 05, 2021 11:48:58.393 PM
\n", "
{\n",
       "    \"output\": {\n",
       "        \"ExecutedVersion\": \"$LATEST\",\n",
       "        \"Payload\": {\n",
       "            \"item_list\": [\n",
       "                {\n",
       "                    \"itemId\": \"143\",\n",
       "                    \"score\": 0.0304744\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"174\",\n",
       "                    \"score\": 0.0299079\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"588\",\n",
       "                    \"score\": 0.0254778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"99\",\n",
       "                    \"score\": 0.0196287\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"210\",\n",
       "                    \"score\": 0.0184811\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"432\",\n",
       "                    \"score\": 0.01776\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"173\",\n",
       "                    \"score\": 0.0170072\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"172\",\n",
       "                    \"score\": 0.0163306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"195\",\n",
       "                    \"score\": 0.0146565\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"357\",\n",
       "                    \"score\": 0.0144201\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"483\",\n",
       "                    \"score\": 0.0140931\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"196\",\n",
       "                    \"score\": 0.0136761\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"79\",\n",
       "                    \"score\": 0.0114862\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"197\",\n",
       "                    \"score\": 0.0112875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"211\",\n",
       "                    \"score\": 0.0111778\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"168\",\n",
       "                    \"score\": 0.0107306\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"71\",\n",
       "                    \"score\": 0.0098636\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"28\",\n",
       "                    \"score\": 0.0097188\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"216\",\n",
       "                    \"score\": 0.009477\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"485\",\n",
       "                    \"score\": 0.0092875\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"205\",\n",
       "                    \"score\": 0.0092582\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"969\",\n",
       "                    \"score\": 0.0092435\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"479\",\n",
       "                    \"score\": 0.0090261\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"95\",\n",
       "                    \"score\": 0.0089939\n",
       "                },\n",
       "                {\n",
       "                    \"itemId\": \"318\",\n",
       "                    \"score\": 0.0089615\n",
       "                }\n",
       "            ]\n",
       "        },\n",
       "        \"SdkHttpMetadata\": {\n",
       "            \"AllHttpHeaders\": {\n",
       "                \"X-Amz-Executed-Version\": [\n",
       "                    \"$LATEST\"\n",
       "                ],\n",
       "                \"x-amzn-Remapped-Content-Length\": [\n",
       "                    \"0\"\n",
       "                ],\n",
       "                \"Connection\": [\n",
       "                    \"keep-alive\"\n",
       "                ],\n",
       "                \"x-amzn-RequestId\": [\n",
       "                    \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "                ],\n",
       "                \"Content-Length\": [\n",
       "                    \"982\"\n",
       "                ],\n",
       "                \"Date\": [\n",
       "                    \"Tue, 05 Jan 2021 23:48:48 GMT\"\n",
       "                ],\n",
       "                \"X-Amzn-Trace-Id\": [\n",
       "                    \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "                ],\n",
       "                \"Content-Type\": [\n",
       "                    \"application/json\"\n",
       "                ]\n",
       "            },\n",
       "            \"HttpHeaders\": {\n",
       "                \"Connection\": \"keep-alive\",\n",
       "                \"Content-Length\": \"982\",\n",
       "                \"Content-Type\": \"application/json\",\n",
       "                \"Date\": \"Tue, 05 Jan 2021 23:48:48 GMT\",\n",
       "                \"X-Amz-Executed-Version\": \"$LATEST\",\n",
       "                \"x-amzn-Remapped-Content-Length\": \"0\",\n",
       "                \"x-amzn-RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\",\n",
       "                \"X-Amzn-Trace-Id\": \"root=1-5ff4fadf-277351e81fc0ff3a52f433ae;sampled=0\"\n",
       "            },\n",
       "            \"HttpStatusCode\": 200\n",
       "        },\n",
       "        \"SdkResponseMetadata\": {\n",
       "            \"RequestId\": \"a4eac648-207e-4c89-a375-663521e4a3b8\"\n",
       "        },\n",
       "        \"StatusCode\": 200\n",
       "    }\n",
       "}
\n", "
\n", " \n" ], "text/plain": [ "" ] }, "execution_count": 976, "metadata": {}, "output_type": "execute_result" } ], "source": [ "recommendation_workflow_execution.list_events(html=True)\n" ] }, { "cell_type": "code", "execution_count": 977, "metadata": {}, "outputs": [], "source": [ "item_list = recommendation_workflow_execution.get_output()['Payload']['item_list']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get Recommendations" ] }, { "cell_type": "code", "execution_count": 978, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Recommendations:\n", "Sound of Music, The (1965)\n", "Raiders of the Lost Ark (1981)\n", "Beauty and the Beast (1991)\n", "Snow White and the Seven Dwarfs (1937)\n", "Indiana Jones and the Last Crusade (1989)\n", "Fantasia (1940)\n", "Princess Bride, The (1987)\n", "Empire Strikes Back, The (1980)\n", "Terminator, The (1984)\n", "One Flew Over the Cuckoo's Nest (1975)\n", "Casablanca (1942)\n", "Dead Poets Society (1989)\n", "Fugitive, The (1993)\n", "Graduate, The (1967)\n", "M*A*S*H (1970)\n", "Monty Python and the Holy Grail (1974)\n", "Lion King, The (1994)\n", "Apollo 13 (1995)\n", "When Harry Met Sally... (1989)\n", "My Fair Lady (1964)\n", "Patton (1970)\n", "Winnie the Pooh and the Blustery Day (1968)\n", "Vertigo (1958)\n", "Aladdin (1992)\n", "Schindler's List (1993)\n" ] } ], "source": [ "item_list = recommendation_workflow_execution.get_output()['Payload']['item_list']\n", "\n", "print(\"Recommendations:\")\n", "for item in item_list:\n", " np.int(item['itemId'])\n", " item_title = items.loc[items['ITEM_ID'] == np.int(item['itemId'])].values[0][-1]\n", " print(item_title)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Clean up Amazon Personalize resources" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make sure to clean up the Amazon Personalize and the state machines created blog. Login to Amazon Personalize console and delete resources such as Dataset Groups, Dataset, Solutions, Receipts, and Campaign. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Clean up State Machine resources" ] }, { "cell_type": "code", "execution_count": 979, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m[INFO] Workflow has been marked for deletion. If the workflow has running executions, it will be deleted when all executions are stopped.\u001b[0m\n", "\u001b[32m[INFO] Workflow has been marked for deletion. If the workflow has running executions, it will be deleted when all executions are stopped.\u001b[0m\n", "\u001b[32m[INFO] Workflow has been marked for deletion. If the workflow has running executions, it will be deleted when all executions are stopped.\u001b[0m\n", "\u001b[32m[INFO] Workflow has been marked for deletion. If the workflow has running executions, it will be deleted when all executions are stopped.\u001b[0m\n", "\u001b[32m[INFO] Workflow has been marked for deletion. If the workflow has running executions, it will be deleted when all executions are stopped.\u001b[0m\n", "\u001b[32m[INFO] Workflow has been marked for deletion. If the workflow has running executions, it will be deleted when all executions are stopped.\u001b[0m\n" ] } ], "source": [ "Campaign_workflow.delete()\n", "\n", "recommendation_workflow.delete()\n", "\n", "Main_workflow.delete()\n", "\n", "Create_receipe_sol_workflow.delete()\n", "\n", "DatasetImport_workflow.delete()\n", "\n", "Dataset_workflow.delete()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "conda_python3", "language": "python", "name": "conda_python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }