Skip to content

Commit 9767358

Browse files
author
Bob Strahan
committed
Merge branch 'develop' v0.3.0
2 parents d4dbd20 + 961ec53 commit 9767358

File tree

3 files changed

+62
-38
lines changed

3 files changed

+62
-38
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Gen AI Intelligent Document Processing (GenAIIDP)
22

3-
Copyright © Amazon.com and Affiliates: This deliverable is considered Developed Content as defined in the AWS Service Terms and the SOW between the parties
3+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
SPDX-License-Identifier: MIT-0
45

56
## Table of Contents
67

@@ -9,7 +10,7 @@ Copyright © Amazon.com and Affiliates: This deliverable is considered Developed
910
- [Architecture Overview](#architecture-overview)
1011
- [Quick Start](#quick-start)
1112
- [Processing Your First Document](#processing-your-first-document)
12-
- [Updating an Existing Deployment](#updating-an-existing-deployment)
13+
- [Updating an Existing Deployment](#updating-an-existing-deployment)
1314
- [Detailed Documentation](#detailed-documentation)
1415
- [Core Documentation](#core-documentation)
1516
- [Processing Patterns](#processing-patterns)
@@ -83,7 +84,7 @@ After deployment, you can quickly process a document and view results:
8384

8485
See the [Deployment Guide](./docs/deployment.md#testing-the-solution) for more detailed testing instructions.
8586

86-
### Updating an Existing Deployment
87+
## Updating an Existing Deployment
8788

8889
To update an existing GenAIIDP stack to a new version:
8990

publish.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,27 @@ function build_and_package_template() {
289289
fi
290290
}
291291

292+
# Generate list of configuration files for explicit copying
293+
function generate_config_file_list() {
294+
local config_dir="config_library"
295+
local file_list=""
296+
297+
# Find all files in config_library, excluding .checksum files
298+
while IFS= read -r -d '' file; do
299+
# Get relative path from config_library directory
300+
relative_path="${file#$config_dir/}"
301+
# Skip .checksum files
302+
if [[ "$relative_path" != ".checksum" && "$relative_path" != *"/.checksum" ]]; then
303+
if [[ -n "$file_list" ]]; then
304+
file_list="$file_list,"
305+
fi
306+
file_list="$file_list\"$relative_path\""
307+
fi
308+
done < <(find "$config_dir" -type f -print0)
309+
310+
echo "[$file_list]"
311+
}
312+
292313
# Upload configuration library to S3
293314
function upload_config_library() {
294315
local config_dir="config_library"
@@ -386,8 +407,8 @@ function build_main_template() {
386407
local BUILD_DATE_TIME=$(date -u +"%Y-%m-%d %H:%M:%S")
387408
local CONFIG_LIBRARY_HASH=$(calculate_hash "config_library")
388409

389-
# Define configuration S3 base path
390-
local CONFIG_BASE_PATH="s3://${BUCKET}/${PREFIX_AND_VERSION}/config_library"
410+
# Generate configuration file list for explicit copying
411+
local CONFIG_FILE_LIST=$(generate_config_file_list)
391412

392413
echo "Inline edit main template to replace:"
393414
echo " <VERSION> with: $VERSION"
@@ -397,8 +418,8 @@ function build_main_template() {
397418
echo " <ARTIFACT_PREFIX_TOKEN> with prefix: $PREFIX_AND_VERSION"
398419
echo " <WEBUI_ZIPFILE_TOKEN> with filename: $webui_zipfile"
399420
echo " <HASH_TOKEN> with: $HASH"
400-
echo " <CONFIG_BASE_PATH_TOKEN> with: $CONFIG_BASE_PATH"
401421
echo " <CONFIG_LIBRARY_HASH_TOKEN> with: $CONFIG_LIBRARY_HASH"
422+
echo " <CONFIG_FILES_LIST_TOKEN> with file list: $CONFIG_FILE_LIST"
402423

403424
# Use a more reliable approach for multiple sed replacements
404425
sed -e "s|<VERSION>|$VERSION|g" \
@@ -408,8 +429,8 @@ function build_main_template() {
408429
-e "s|<ARTIFACT_PREFIX_TOKEN>|$PREFIX_AND_VERSION|g" \
409430
-e "s|<WEBUI_ZIPFILE_TOKEN>|$webui_zipfile|g" \
410431
-e "s|<HASH_TOKEN>|$HASH|g" \
411-
-e "s|<CONFIG_BASE_PATH_TOKEN>|$CONFIG_BASE_PATH|g" \
412432
-e "s|<CONFIG_LIBRARY_HASH_TOKEN>|$CONFIG_LIBRARY_HASH|g" \
433+
-e "s|<CONFIG_FILES_LIST_TOKEN>|$CONFIG_FILE_LIST|g" \
413434
.aws-sam/packaged.yaml > .aws-sam/${MAIN_TEMPLATE}
414435

415436
# Upload and validate main template
@@ -500,4 +521,4 @@ set_public_acls
500521
print_outputs "$TEMPLATE_URL"
501522

502523
echo "Done"
503-
exit 0
524+
exit 0

template.yaml

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -543,40 +543,41 @@ Resources:
543543
target_bucket = event['ResourceProperties']['TargetBucket']
544544
target_prefix = event['ResourceProperties'].get('TargetPrefix', '')
545545
546+
file_list = event['ResourceProperties'].get('FileList', [])
547+
546548
s3_client = boto3.client('s3')
547549
548550
if event['RequestType'] == 'Create' or event['RequestType'] == 'Update':
549-
# List all objects in the source bucket with the given prefix
550-
paginator = s3_client.get_paginator('list_objects_v2')
551-
pages = paginator.paginate(Bucket=source_bucket, Prefix=source_prefix)
552-
551+
# Copy files explicitly from the provided list
553552
copied_count = 0
554-
for page in pages:
555-
if 'Contents' in page:
556-
for obj in page['Contents']:
557-
source_key = obj['Key']
558-
# Remove the source prefix and add to target bucket with target prefix
559-
relative_key = source_key[len(source_prefix):].lstrip('/')
560-
561-
# Skip if this is just the prefix directory
562-
if not relative_key:
563-
continue
564-
565-
# Construct target key with optional target prefix
566-
if target_prefix:
567-
target_key = f"{target_prefix}/{relative_key}"
568-
else:
569-
target_key = relative_key
570-
571-
logger.info(f"Copying {source_bucket}/{source_key} to {target_bucket}/{target_key}")
572-
573-
copy_source = {'Bucket': source_bucket, 'Key': source_key}
574-
s3_client.copy_object(
575-
CopySource=copy_source,
576-
Bucket=target_bucket,
577-
Key=target_key
578-
)
579-
copied_count += 1
553+
554+
for relative_file_path in file_list:
555+
# Skip empty entries
556+
if not relative_file_path.strip():
557+
continue
558+
559+
# Construct source key
560+
source_key = f"{source_prefix}/{relative_file_path}"
561+
562+
# Construct target key with optional target prefix
563+
if target_prefix:
564+
target_key = f"{target_prefix}/{relative_file_path}"
565+
else:
566+
target_key = relative_file_path
567+
568+
logger.info(f"Copying {source_bucket}/{source_key} to {target_bucket}/{target_key}")
569+
570+
try:
571+
copy_source = {'Bucket': source_bucket, 'Key': source_key}
572+
s3_client.copy_object(
573+
CopySource=copy_source,
574+
Bucket=target_bucket,
575+
Key=target_key
576+
)
577+
copied_count += 1
578+
except Exception as copy_error:
579+
logger.warning(f"Failed to copy {source_key}: {str(copy_error)}")
580+
# Continue with other files instead of failing the entire operation
580581
581582
logger.info(f"Successfully copied {copied_count} configuration files")
582583
cfnresponse.send(event, context, cfnresponse.SUCCESS, {
@@ -633,6 +634,7 @@ Resources:
633634
TargetBucket: !Ref ConfigurationBucket
634635
TargetPrefix: "config_library"
635636
ConfigLibraryHash: "<CONFIG_LIBRARY_HASH_TOKEN>"
637+
FileList: <CONFIG_FILES_LIST_TOKEN>
636638

637639
##########################################################################
638640
# Nested stack for selected options

0 commit comments

Comments
 (0)