Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 010fbdf

Browse files
authored
Merge pull request #13 from aws-solutions/feature/v1.2.0
Update to version v1.2.0
2 parents b761be0 + 835fb0a commit 010fbdf

File tree

134 files changed

+1698
-559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1698
-559
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.2.0] - 2022-01-31
8+
### Added
9+
- The solution now supports batch segment jobs to get user segments with your solution version. Each user segment is
10+
sorted in descending order based on the probability that each user will interact with items in your inventory.
11+
- The solution now supports domain dataset groups.
12+
13+
### Changed
14+
- Upgraded to CDKv2.
15+
716
## [1.1.0] - 2021-11-22
817
### Added
918
- The solution now creates an Amazon EventBridge event bus, and puts messages to the bus when resources have been

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ The following procedures assumes that all the OS-level configuration has been co
293293
* [AWS Command Line Interface](https://aws.amazon.com/cli/)
294294
* [Python](https://www.python.org/) 3.9 or newer
295295
* [Node.js](https://nodejs.org/en/) 16.x or newer
296-
* [AWS CDK](https://aws.amazon.com/cdk/) 1.126.0 or newer
296+
* [AWS CDK](https://aws.amazon.com/cdk/) 2.7.0 or newer
297297
* [Amazon Corretto OpenJDK](https://docs.aws.amazon.com/corretto/) 11
298298

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

352-
build-s3-cdk-dist \
352+
build-s3-cdk-dist deploy \
353353
--source-bucket-name DIST_BUCKET_PREFIX \
354354
--solution-name SOLUTION_NAME \
355355
--version_code VERSION \

deployment/run-unit-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ virtualenv .venv
4545
source .venv/bin/activate
4646

4747
cd $source_dir
48+
pip install --upgrade pip
4849
pip install -r $source_dir/requirements-dev.txt
4950
cd -
5051

source/aws_lambda/create_batch_inference_job/handler.py

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,52 @@
1818

1919
from shared.sfn_middleware import PersonalizeResource
2020

21+
RESOURCE = "batchInferenceJob"
22+
STATUS = "batchInferenceJob.status"
23+
CONFIG = {
24+
"jobName": {
25+
"source": "event",
26+
"path": "serviceConfig.jobName",
27+
},
28+
"solutionVersionArn": {
29+
"source": "event",
30+
"path": "serviceConfig.solutionVersionArn",
31+
},
32+
"filterArn": {
33+
"source": "event",
34+
"path": "serviceConfig.filterArn",
35+
"default": "omit",
36+
},
37+
"numResults": {
38+
"source": "event",
39+
"path": "serviceConfig.numResults",
40+
"default": "omit",
41+
},
42+
"jobInput": {
43+
"source": "event",
44+
"path": "serviceConfig.jobInput",
45+
},
46+
"jobOutput": {"source": "event", "path": "serviceConfig.jobOutput"},
47+
"roleArn": {"source": "environment", "path": "ROLE_ARN"},
48+
"batchInferenceJobConfig": {
49+
"source": "event",
50+
"path": "serviceConfig.batchInferenceJobConfig",
51+
"default": "omit",
52+
},
53+
"maxAge": {
54+
"source": "event",
55+
"path": "workflowConfig.maxAge",
56+
"default": "omit",
57+
"as": "seconds",
58+
},
59+
"timeStarted": {
60+
"source": "event",
61+
"path": "workflowConfig.timeStarted",
62+
"default": "omit",
63+
"as": "iso8601",
64+
},
65+
}
66+
2167
logger = Logger()
2268
tracer = Tracer()
2369
metrics = Metrics()
@@ -26,51 +72,9 @@
2672
@metrics.log_metrics
2773
@tracer.capture_lambda_handler
2874
@PersonalizeResource(
29-
resource="batchInferenceJob",
30-
status="batchInferenceJob.status",
31-
config={
32-
"jobName": {
33-
"source": "event",
34-
"path": "serviceConfig.jobName",
35-
},
36-
"solutionVersionArn": {
37-
"source": "event",
38-
"path": "serviceConfig.solutionVersionArn",
39-
},
40-
"filterArn": {
41-
"source": "event",
42-
"path": "serviceConfig.filterArn",
43-
"default": "omit",
44-
},
45-
"numResults": {
46-
"source": "event",
47-
"path": "serviceConfig.numResults",
48-
"default": "omit",
49-
},
50-
"jobInput": {
51-
"source": "event",
52-
"path": "serviceConfig.jobInput",
53-
},
54-
"jobOutput": {"source": "event", "path": "serviceConfig.jobOutput"},
55-
"roleArn": {"source": "environment", "path": "ROLE_ARN"},
56-
"batchInferenceJobConfig": {
57-
"source": "event",
58-
"path": "serviceConfig.batchInferenceJobConfig",
59-
"default": "omit",
60-
},
61-
"maxAge": {
62-
"source": "event",
63-
"path": "workflowConfig.maxAge",
64-
"default": "omit",
65-
"as": "seconds",
66-
},
67-
"timeStarted": {
68-
"source": "event",
69-
"path": "workflowConfig.timeStarted",
70-
"default": "omit",
71-
"as": "iso8601",
72-
},
73-
},
75+
resource=RESOURCE,
76+
status=STATUS,
77+
config=CONFIG,
7478
)
7579
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
7680
"""Create a batch inference job in Amazon Personalize based on the configuration in `event`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ######################################################################################################################
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
3+
# #
4+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance #
5+
# with the License. You may obtain a copy of the License at #
6+
# #
7+
# http://www.apache.org/licenses/LICENSE-2.0 #
8+
# #
9+
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed #
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for #
11+
# the specific language governing permissions and limitations under the License. #
12+
# ######################################################################################################################
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# ######################################################################################################################
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
3+
# #
4+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance #
5+
# with the License. You may obtain a copy of the License at #
6+
# #
7+
# http://www.apache.org/licenses/LICENSE-2.0 #
8+
# #
9+
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed #
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for #
11+
# the specific language governing permissions and limitations under the License. #
12+
# ######################################################################################################################
13+
14+
from typing import Dict, Any
15+
16+
from aws_lambda_powertools import Logger, Tracer, Metrics
17+
from aws_lambda_powertools.utilities.typing import LambdaContext
18+
19+
from shared.sfn_middleware import PersonalizeResource
20+
21+
RESOURCE = "batchSegmentJob"
22+
STATUS = "batchSegmentJob.status"
23+
CONFIG = {
24+
"filterArn": {
25+
"source": "event",
26+
"path": "serviceConfig.filterArn",
27+
"default": "omit",
28+
},
29+
"jobInput": {
30+
"source": "event",
31+
"path": "serviceConfig.jobInput",
32+
},
33+
"jobName": {
34+
"source": "event",
35+
"path": "serviceConfig.jobName",
36+
},
37+
"jobOutput": {"source": "event", "path": "serviceConfig.jobOutput"},
38+
"solutionVersionArn": {
39+
"source": "event",
40+
"path": "serviceConfig.solutionVersionArn",
41+
},
42+
"numResults": {
43+
"source": "event",
44+
"path": "serviceConfig.numResults",
45+
"default": "omit",
46+
},
47+
"roleArn": {"source": "environment", "path": "ROLE_ARN"},
48+
"maxAge": {
49+
"source": "event",
50+
"path": "workflowConfig.maxAge",
51+
"default": "omit",
52+
"as": "seconds",
53+
},
54+
"timeStarted": {
55+
"source": "event",
56+
"path": "workflowConfig.timeStarted",
57+
"default": "omit",
58+
"as": "iso8601",
59+
},
60+
}
61+
62+
logger = Logger()
63+
tracer = Tracer()
64+
metrics = Metrics()
65+
66+
67+
@metrics.log_metrics
68+
@tracer.capture_lambda_handler
69+
@PersonalizeResource(
70+
resource=RESOURCE,
71+
status=STATUS,
72+
config=CONFIG,
73+
)
74+
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
75+
"""Create a batch segment job in Amazon Personalize based on the configuration in `event`
76+
:param event: AWS Lambda Event
77+
:param context: AWS Lambda Context
78+
:return: the configured batch inference job
79+
"""
80+
return event.get("resource") # return the batch inference job

source/aws_lambda/create_campaign/handler.py

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,41 @@
1818

1919
from shared.sfn_middleware import PersonalizeResource
2020

21+
RESOURCE = "campaign"
22+
STATUS = "campaign.latestCampaignUpdate.status || campaign.status"
23+
CONFIG = {
24+
"name": {
25+
"source": "event",
26+
"path": "serviceConfig.name",
27+
},
28+
"solutionVersionArn": {
29+
"source": "event",
30+
"path": "serviceConfig.solutionVersionArn",
31+
},
32+
"minProvisionedTPS": {
33+
"source": "event",
34+
"path": "serviceConfig.minProvisionedTPS",
35+
"as": "int",
36+
},
37+
"campaignConfig": {
38+
"source": "event",
39+
"path": "serviceConfig.campaignConfig",
40+
"default": "omit",
41+
},
42+
"maxAge": {
43+
"source": "event",
44+
"path": "workflowConfig.maxAge",
45+
"default": "omit",
46+
"as": "seconds",
47+
},
48+
"timeStarted": {
49+
"source": "event",
50+
"path": "workflowConfig.timeStarted",
51+
"default": "omit",
52+
"as": "iso8601",
53+
},
54+
}
55+
2156
logger = Logger()
2257
tracer = Tracer()
2358
metrics = Metrics()
@@ -26,40 +61,9 @@
2661
@metrics.log_metrics
2762
@tracer.capture_lambda_handler
2863
@PersonalizeResource(
29-
resource="campaign",
30-
config={
31-
"name": {
32-
"source": "event",
33-
"path": "serviceConfig.name",
34-
},
35-
"solutionVersionArn": {
36-
"source": "event",
37-
"path": "serviceConfig.solutionVersionArn",
38-
},
39-
"minProvisionedTPS": {
40-
"source": "event",
41-
"path": "serviceConfig.minProvisionedTPS",
42-
"as": "int",
43-
},
44-
"campaignConfig": {
45-
"source": "event",
46-
"path": "serviceConfig.campaignConfig",
47-
"default": "omit",
48-
},
49-
"maxAge": {
50-
"source": "event",
51-
"path": "workflowConfig.maxAge",
52-
"default": "omit",
53-
"as": "seconds",
54-
},
55-
"timeStarted": {
56-
"source": "event",
57-
"path": "workflowConfig.timeStarted",
58-
"default": "omit",
59-
"as": "iso8601",
60-
},
61-
},
62-
status="campaign.latestCampaignUpdate.status || campaign.status",
64+
resource=RESOURCE,
65+
config=CONFIG,
66+
status=STATUS,
6367
)
6468
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
6569
"""Create a campaign in Amazon Personalize based on the configuration in `event`

source/aws_lambda/create_dataset/handler.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@
1818

1919
from shared.sfn_middleware import PersonalizeResource
2020

21+
RESOURCE = "dataset"
22+
CONFIG = {
23+
"name": {
24+
"source": "event",
25+
"path": "serviceConfig.name",
26+
},
27+
"datasetType": {
28+
"source": "event",
29+
"path": "serviceConfig.datasetType",
30+
},
31+
"datasetGroupArn": {
32+
"source": "event",
33+
"path": "serviceConfig.datasetGroupArn",
34+
},
35+
"schemaArn": {"source": "event", "path": "serviceConfig.schemaArn"},
36+
"timeStarted": {
37+
"source": "event",
38+
"path": "workflowConfig.timeStarted",
39+
"default": "omit",
40+
"as": "iso8601",
41+
},
42+
}
43+
2144
logger = Logger()
2245
tracer = Tracer()
2346
metrics = Metrics()
@@ -26,28 +49,8 @@
2649
@metrics.log_metrics
2750
@tracer.capture_lambda_handler
2851
@PersonalizeResource(
29-
resource="dataset",
30-
config={
31-
"name": {
32-
"source": "event",
33-
"path": "serviceConfig.name",
34-
},
35-
"datasetType": {
36-
"source": "event",
37-
"path": "serviceConfig.datasetType",
38-
},
39-
"datasetGroupArn": {
40-
"source": "event",
41-
"path": "serviceConfig.datasetGroupArn",
42-
},
43-
"schemaArn": {"source": "event", "path": "serviceConfig.schemaArn"},
44-
"timeStarted": {
45-
"source": "event",
46-
"path": "workflowConfig.timeStarted",
47-
"default": "omit",
48-
"as": "iso8601",
49-
},
50-
},
52+
resource=RESOURCE,
53+
config=CONFIG,
5154
)
5255
def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict:
5356
"""Create a dataset in Amazon Personalize based on the configuration in `event`

0 commit comments

Comments
 (0)