Skip to content

Commit

Permalink
Merge pull request #13 from aws-solutions/feature/v1.2.0
Browse files Browse the repository at this point in the history
Update to version v1.2.0
  • Loading branch information
aassadza authored Jan 26, 2022
2 parents b761be0 + 835fb0a commit 010fbdf
Show file tree
Hide file tree
Showing 134 changed files with 1,698 additions and 559 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2022-01-31
### Added
- The solution now supports batch segment jobs to get user segments with your solution version. Each user segment is
sorted in descending order based on the probability that each user will interact with items in your inventory.
- The solution now supports domain dataset groups.

### Changed
- Upgraded to CDKv2.

## [1.1.0] - 2021-11-22
### Added
- The solution now creates an Amazon EventBridge event bus, and puts messages to the bus when resources have been
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ The following procedures assumes that all the OS-level configuration has been co
* [AWS Command Line Interface](https://aws.amazon.com/cli/)
* [Python](https://www.python.org/) 3.9 or newer
* [Node.js](https://nodejs.org/en/) 16.x or newer
* [AWS CDK](https://aws.amazon.com/cdk/) 1.126.0 or newer
* [AWS CDK](https://aws.amazon.com/cdk/) 2.7.0 or newer
* [Amazon Corretto OpenJDK](https://docs.aws.amazon.com/corretto/) 11

> **Please ensure you test the templates before updating any production deployments.**
Expand Down Expand Up @@ -349,7 +349,7 @@ export SOLUTION_NAME=my-solution-name
export VERSION=my-version
export REGION_NAME=my-region

build-s3-cdk-dist \
build-s3-cdk-dist deploy \
--source-bucket-name DIST_BUCKET_PREFIX \
--solution-name SOLUTION_NAME \
--version_code VERSION \
Expand Down
1 change: 1 addition & 0 deletions deployment/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ virtualenv .venv
source .venv/bin/activate

cd $source_dir
pip install --upgrade pip
pip install -r $source_dir/requirements-dev.txt
cd -

Expand Down
94 changes: 49 additions & 45 deletions source/aws_lambda/create_batch_inference_job/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,52 @@

from shared.sfn_middleware import PersonalizeResource

RESOURCE = "batchInferenceJob"
STATUS = "batchInferenceJob.status"
CONFIG = {
"jobName": {
"source": "event",
"path": "serviceConfig.jobName",
},
"solutionVersionArn": {
"source": "event",
"path": "serviceConfig.solutionVersionArn",
},
"filterArn": {
"source": "event",
"path": "serviceConfig.filterArn",
"default": "omit",
},
"numResults": {
"source": "event",
"path": "serviceConfig.numResults",
"default": "omit",
},
"jobInput": {
"source": "event",
"path": "serviceConfig.jobInput",
},
"jobOutput": {"source": "event", "path": "serviceConfig.jobOutput"},
"roleArn": {"source": "environment", "path": "ROLE_ARN"},
"batchInferenceJobConfig": {
"source": "event",
"path": "serviceConfig.batchInferenceJobConfig",
"default": "omit",
},
"maxAge": {
"source": "event",
"path": "workflowConfig.maxAge",
"default": "omit",
"as": "seconds",
},
"timeStarted": {
"source": "event",
"path": "workflowConfig.timeStarted",
"default": "omit",
"as": "iso8601",
},
}

logger = Logger()
tracer = Tracer()
metrics = Metrics()
Expand All @@ -26,51 +72,9 @@
@metrics.log_metrics
@tracer.capture_lambda_handler
@PersonalizeResource(
resource="batchInferenceJob",
status="batchInferenceJob.status",
config={
"jobName": {
"source": "event",
"path": "serviceConfig.jobName",
},
"solutionVersionArn": {
"source": "event",
"path": "serviceConfig.solutionVersionArn",
},
"filterArn": {
"source": "event",
"path": "serviceConfig.filterArn",
"default": "omit",
},
"numResults": {
"source": "event",
"path": "serviceConfig.numResults",
"default": "omit",
},
"jobInput": {
"source": "event",
"path": "serviceConfig.jobInput",
},
"jobOutput": {"source": "event", "path": "serviceConfig.jobOutput"},
"roleArn": {"source": "environment", "path": "ROLE_ARN"},
"batchInferenceJobConfig": {
"source": "event",
"path": "serviceConfig.batchInferenceJobConfig",
"default": "omit",
},
"maxAge": {
"source": "event",
"path": "workflowConfig.maxAge",
"default": "omit",
"as": "seconds",
},
"timeStarted": {
"source": "event",
"path": "workflowConfig.timeStarted",
"default": "omit",
"as": "iso8601",
},
},
resource=RESOURCE,
status=STATUS,
config=CONFIG,
)
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
"""Create a batch inference job in Amazon Personalize based on the configuration in `event`
Expand Down
12 changes: 12 additions & 0 deletions source/aws_lambda/create_batch_segment_job/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ######################################################################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance #
# with the License. You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed #
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for #
# the specific language governing permissions and limitations under the License. #
# ######################################################################################################################
80 changes: 80 additions & 0 deletions source/aws_lambda/create_batch_segment_job/handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ######################################################################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance #
# with the License. You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed #
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for #
# the specific language governing permissions and limitations under the License. #
# ######################################################################################################################

from typing import Dict, Any

from aws_lambda_powertools import Logger, Tracer, Metrics
from aws_lambda_powertools.utilities.typing import LambdaContext

from shared.sfn_middleware import PersonalizeResource

RESOURCE = "batchSegmentJob"
STATUS = "batchSegmentJob.status"
CONFIG = {
"filterArn": {
"source": "event",
"path": "serviceConfig.filterArn",
"default": "omit",
},
"jobInput": {
"source": "event",
"path": "serviceConfig.jobInput",
},
"jobName": {
"source": "event",
"path": "serviceConfig.jobName",
},
"jobOutput": {"source": "event", "path": "serviceConfig.jobOutput"},
"solutionVersionArn": {
"source": "event",
"path": "serviceConfig.solutionVersionArn",
},
"numResults": {
"source": "event",
"path": "serviceConfig.numResults",
"default": "omit",
},
"roleArn": {"source": "environment", "path": "ROLE_ARN"},
"maxAge": {
"source": "event",
"path": "workflowConfig.maxAge",
"default": "omit",
"as": "seconds",
},
"timeStarted": {
"source": "event",
"path": "workflowConfig.timeStarted",
"default": "omit",
"as": "iso8601",
},
}

logger = Logger()
tracer = Tracer()
metrics = Metrics()


@metrics.log_metrics
@tracer.capture_lambda_handler
@PersonalizeResource(
resource=RESOURCE,
status=STATUS,
config=CONFIG,
)
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
"""Create a batch segment job in Amazon Personalize based on the configuration in `event`
:param event: AWS Lambda Event
:param context: AWS Lambda Context
:return: the configured batch inference job
"""
return event.get("resource") # return the batch inference job
72 changes: 38 additions & 34 deletions source/aws_lambda/create_campaign/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,41 @@

from shared.sfn_middleware import PersonalizeResource

RESOURCE = "campaign"
STATUS = "campaign.latestCampaignUpdate.status || campaign.status"
CONFIG = {
"name": {
"source": "event",
"path": "serviceConfig.name",
},
"solutionVersionArn": {
"source": "event",
"path": "serviceConfig.solutionVersionArn",
},
"minProvisionedTPS": {
"source": "event",
"path": "serviceConfig.minProvisionedTPS",
"as": "int",
},
"campaignConfig": {
"source": "event",
"path": "serviceConfig.campaignConfig",
"default": "omit",
},
"maxAge": {
"source": "event",
"path": "workflowConfig.maxAge",
"default": "omit",
"as": "seconds",
},
"timeStarted": {
"source": "event",
"path": "workflowConfig.timeStarted",
"default": "omit",
"as": "iso8601",
},
}

logger = Logger()
tracer = Tracer()
metrics = Metrics()
Expand All @@ -26,40 +61,9 @@
@metrics.log_metrics
@tracer.capture_lambda_handler
@PersonalizeResource(
resource="campaign",
config={
"name": {
"source": "event",
"path": "serviceConfig.name",
},
"solutionVersionArn": {
"source": "event",
"path": "serviceConfig.solutionVersionArn",
},
"minProvisionedTPS": {
"source": "event",
"path": "serviceConfig.minProvisionedTPS",
"as": "int",
},
"campaignConfig": {
"source": "event",
"path": "serviceConfig.campaignConfig",
"default": "omit",
},
"maxAge": {
"source": "event",
"path": "workflowConfig.maxAge",
"default": "omit",
"as": "seconds",
},
"timeStarted": {
"source": "event",
"path": "workflowConfig.timeStarted",
"default": "omit",
"as": "iso8601",
},
},
status="campaign.latestCampaignUpdate.status || campaign.status",
resource=RESOURCE,
config=CONFIG,
status=STATUS,
)
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
"""Create a campaign in Amazon Personalize based on the configuration in `event`
Expand Down
47 changes: 25 additions & 22 deletions source/aws_lambda/create_dataset/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@

from shared.sfn_middleware import PersonalizeResource

RESOURCE = "dataset"
CONFIG = {
"name": {
"source": "event",
"path": "serviceConfig.name",
},
"datasetType": {
"source": "event",
"path": "serviceConfig.datasetType",
},
"datasetGroupArn": {
"source": "event",
"path": "serviceConfig.datasetGroupArn",
},
"schemaArn": {"source": "event", "path": "serviceConfig.schemaArn"},
"timeStarted": {
"source": "event",
"path": "workflowConfig.timeStarted",
"default": "omit",
"as": "iso8601",
},
}

logger = Logger()
tracer = Tracer()
metrics = Metrics()
Expand All @@ -26,28 +49,8 @@
@metrics.log_metrics
@tracer.capture_lambda_handler
@PersonalizeResource(
resource="dataset",
config={
"name": {
"source": "event",
"path": "serviceConfig.name",
},
"datasetType": {
"source": "event",
"path": "serviceConfig.datasetType",
},
"datasetGroupArn": {
"source": "event",
"path": "serviceConfig.datasetGroupArn",
},
"schemaArn": {"source": "event", "path": "serviceConfig.schemaArn"},
"timeStarted": {
"source": "event",
"path": "workflowConfig.timeStarted",
"default": "omit",
"as": "iso8601",
},
},
resource=RESOURCE,
config=CONFIG,
)
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
"""Create a dataset in Amazon Personalize based on the configuration in `event`
Expand Down
Loading

0 comments on commit 010fbdf

Please sign in to comment.