Skip to content

Commit 1469889

Browse files
author
Bob Strahan
committed
provide tracking table to classification function for caching
1 parent 0f903a4 commit 1469889

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

patterns/pattern-2/src/classification_function/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def handler(event, context):
5454
metrics.put_metric('BedrockRequestsTotal', total_pages)
5555

5656
# Initialize classification service with DynamoDB caching
57-
cache_table = os.environ.get('CONFIGURATION_TABLE_NAME')
57+
cache_table = os.environ.get('TRACKING_TABLE')
5858
service = classification.ClassificationService(
5959
region=region,
6060
max_workers=MAX_WORKERS,

patterns/pattern-2/template.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Parameters:
2020
OutputBucket:
2121
Type: String
2222

23+
TrackingTable:
24+
Type: String
25+
2326
CustomerManagedEncryptionKeyArn:
2427
Type: String
2528

@@ -540,6 +543,7 @@ Resources:
540543
Variables:
541544
METRIC_NAMESPACE: !Ref StackName
542545
MAX_WORKERS: 20
546+
TRACKING_TABLE: !Ref TrackingTable
543547
CONFIGURATION_BUCKET: !Ref ConfigurationBucket
544548
CONFIGURATION_TABLE_NAME: !Ref ConfigurationTable
545549
LOG_LEVEL: !Ref LogLevel
@@ -554,6 +558,8 @@ Resources:
554558
BucketName: !Ref OutputBucket
555559
- S3ReadPolicy:
556560
BucketName: !Ref InputBucket
561+
- DynamoDBCrudPolicy:
562+
TableName: !Ref TrackingTable
557563
- S3ReadPolicy:
558564
BucketName: !Ref ConfigurationBucket
559565
- DynamoDBCrudPolicy:

patterns/pattern-3/src/classification_function/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def handler(event, context):
5959
config_with_endpoint["sagemaker_endpoint_name"] = os.environ['SAGEMAKER_ENDPOINT_NAME']
6060

6161
# Initialize classification service with SageMaker backend and DynamoDB caching
62-
cache_table = os.environ.get('CONFIGURATION_TABLE_NAME')
62+
cache_table = os.environ.get('TRACKING_TABLE')
6363
service = classification.ClassificationService(
6464
region=region,
6565
max_workers=MAX_WORKERS,

patterns/pattern-3/template.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Parameters:
2020
OutputBucket:
2121
Type: String
2222

23+
TrackingTable:
24+
Type: String
25+
2326
CustomerManagedEncryptionKeyArn:
2427
Type: String
2528

@@ -468,6 +471,7 @@ Resources:
468471
Variables:
469472
METRIC_NAMESPACE: !Ref StackName
470473
MAX_WORKERS: 20
474+
TRACKING_TABLE: !Ref TrackingTable
471475
SAGEMAKER_ENDPOINT_NAME: !GetAtt SAGEMAKERCLASSIFIERSTACK.Outputs.EndpointName
472476
CONFIGURATION_TABLE_NAME: !Ref ConfigurationTable
473477
APPSYNC_API_URL: !Ref AppSyncApiUrl
@@ -481,6 +485,8 @@ Resources:
481485
BucketName: !Ref OutputBucket
482486
- S3ReadPolicy:
483487
BucketName: !Ref InputBucket
488+
- DynamoDBCrudPolicy:
489+
TableName: !Ref TrackingTable
484490
- S3ReadPolicy:
485491
BucketName: !Ref ConfigurationBucket
486492
- DynamoDBCrudPolicy:

template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ Resources:
719719
InputBucket: !Ref InputBucket
720720
ConfigurationBucket: !Ref ConfigurationBucket
721721
OutputBucket: !Ref OutputBucket
722+
TrackingTable: !Ref TrackingTable
722723
CustomerManagedEncryptionKeyArn: !GetAtt CustomerManagedEncryptionKey.Arn
723724
LogRetentionDays: !Ref LogRetentionDays
724725
LogLevel: !Ref LogLevel
@@ -749,6 +750,7 @@ Resources:
749750
InputBucket: !Ref InputBucket
750751
ConfigurationBucket: !Ref ConfigurationBucket
751752
OutputBucket: !Ref OutputBucket
753+
TrackingTable: !Ref TrackingTable
752754
CustomerManagedEncryptionKeyArn: !GetAtt CustomerManagedEncryptionKey.Arn
753755
LogRetentionDays: !Ref LogRetentionDays
754756
LogLevel: !Ref LogLevel

0 commit comments

Comments
 (0)