Manage resources of Amazon Personalize using API Gateway
Running this repository may cost you to provision AWS resources
- awscli
- Nodejs 14+
- Python 3.10+
- AWS Account and Locally configured AWS credential
Install project dependencies
$ cd infra
$ npm i
Install cdk in global context and run cdk bootstrap
if you did not initailize cdk yet.
$ npm i -g [email protected]
$ cdk bootstrap
Deploy CDK Stacks on AWS
$ cdk deploy "*" --require-approval never
APIs provided this repository are self-documented using API Gateway Models.
- Export Swagger your API specification on API Gateway Console
-
place it at swagger/swagger.json
-
Run Swagger UI using Docker
$ docker-compose up
- Visit
localhost:80
- Verify your email on Amazon SES Console
If you are not yet request increasing SES limitation, you can only send email to verified email.
-
open /infra/config/dev.toml and replace values for your environment
-
copy
dev.toml
file under infra folder with name.toml
$ cd infra
$ cp config/dev.toml .toml
-
Generate csv file by following intructions of Amazon Personalize Samples
-
Upload csv file to S3 Bucket
- Create Schema
$ http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/schema name=my-demo-schema schema={"type": "record", "name": "Interactions", "namespace": "com.amazonaws.personalize.schema", "fields": [{"name": "USER_ID", "type": "string"}, {"name": "ITEM_ID", "type": "string"}, {"name": "TIMESTAMP", "type": "long"}], "version": "1.0"}
- Invoke api to create Personalize Similar-Items campaign
$ http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/similar-items name=my-similar-items-model schema="arn:aws:personalize:ap-northeast-2:776556808198:schema/my-demo-schema" bucket="s3://demo-similar-items-67914/DEMO-similar-items.csv"
- Invoke api to get list of campaign_arn and copy your campaign arn
$ http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/campaigns
- Invoke api to get recommendations realtime
$ http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/recommend/similar-items campaign_arn=arn:aws:personalize:ap-northeast-2:929831892372:campaign/my-similar-items-model
item_id=323
- Invoke api to get recommendations in batch
$ http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/batch-inference name=my-batch-job solution_version_arn=arn:aws:personalize:ap-northeast-2:929831892372:solution/my-similar-items-model/84e322ff num_results=150 input_path="s3://demo-similar-items-67914/batch/input.json" output_path="s3://demo-similar-items-67914/batch/output/"
- Get tracking id for dataset group
$ http get http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/tracking name==user-personalization-baseline
- Put event via API Gateway
http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/events tracking_id=a6006e6f-8623-4684-bda4-33bec98aade9 session_id=user-personalization-session-1 event_type=click user_id=242 item_id=88 sent_at=1596258382
- Invoke api to remove dataset-group
$ http post https://xyxyxy.execute-api.ap-northeast-2.amazonaws.com/dev/cleanup name=my-similar-items-model
destroy provisioned cloud resources
$ cdk destroy "*"