Skip to content

Commit 18c060e

Browse files
author
Taniya Mathur
committed
Add global pattern configuration and fix CLI smoketest path issues
Ensure stack cleanup happens on both success and failure
1 parent 168847c commit 18c060e

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

scripts/sdlc/idp-cli/src/idp_cli/cli/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
33

4+
# Global pattern configuration - modify these to control which patterns are deployed/tested
5+
DEPLOY_PATTERNS = {
6+
"p1": "Pattern1 - Packet or Media processing with Bedrock Data Automation (BDA)",
7+
# "p2": "Pattern2 - Packet processing with Textract and Bedrock",
8+
# "p3": "Pattern3 - Packet processing with Textract, SageMaker(UDOP), and Bedrock"
9+
}
10+
411
import os
512
import sys
613
from idp_cli.service.install_service import InstallService

scripts/sdlc/idp-cli/src/idp_cli/service/install_service.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,8 @@ def install(self, admin_email: str):
363363
Args:
364364
admin_email: Email address for the admin user
365365
"""
366-
patterns = {
367-
"p1": "Pattern1 - Packet or Media processing with Bedrock Data Automation (BDA)",
368-
"p2": "Pattern2 - Packet processing with Textract and Bedrock"
369-
}
366+
from idp_cli.cli.main import DEPLOY_PATTERNS
367+
patterns = DEPLOY_PATTERNS
370368

371369
def deploy_pattern(suffix, pattern_name):
372370
stack_name = f"{self.cfn_prefix}-{suffix}"

scripts/sdlc/idp-cli/src/idp_cli/service/smoketest_idp_cli_service.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def do_smoketest(self):
3636

3737
# Deploy stack using idp-cli deploy
3838
logger.info(f"Deploying stack {self.stack_name}...")
39+
# Use pattern-2 specifically for CLI smoketest
3940
subprocess.run([
4041
"idp-cli", "deploy",
4142
"--stack-name", self.stack_name,
@@ -49,7 +50,7 @@ def do_smoketest(self):
4950

5051
# Run inference using IDP CLI with custom batch ID
5152
logger.info(f"Running inference with batch ID: {batch_id}...")
52-
samples_path = os.path.join(self.cwd, "samples/")
53+
samples_path = "samples/"
5354
subprocess.run([
5455
"idp-cli", "run-inference",
5556
"--stack-name", self.stack_name,
@@ -84,17 +85,20 @@ def do_smoketest(self):
8485
raise Exception("Expected content 'ANYTOWN, USA 12345' not found in result.json")
8586

8687
logger.info("✅ IDP CLI smoketest completed successfully!")
87-
88-
# Always cleanup test deployment
89-
logger.info(f"Cleaning up deployment {self.stack_name}...")
90-
subprocess.run([
91-
"idp-cli", "delete",
92-
"--stack-name", self.stack_name,
93-
"--force"
94-
], check=True, cwd=self.cwd)
95-
9688
return True
9789

9890
except Exception as e:
9991
logger.exception(f"Error during IDP CLI smoketest: {str(e)}")
10092
return False
93+
finally:
94+
# Always cleanup test deployment regardless of success/failure
95+
try:
96+
logger.info(f"Cleaning up deployment {self.stack_name}...")
97+
subprocess.run([
98+
"idp-cli", "delete",
99+
"--stack-name", self.stack_name,
100+
"--force"
101+
], check=True, cwd=self.cwd)
102+
logger.info("✅ Cleanup completed successfully!")
103+
except Exception as cleanup_error:
104+
logger.error(f"Failed to cleanup deployment {self.stack_name}: {cleanup_error}")

scripts/sdlc/idp-cli/src/idp_cli/service/smoketest_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ def __init__(self,
1616
file_path: str,
1717
verify_string: str):
1818

19+
from idp_cli.cli.main import DEPLOY_PATTERNS
20+
1921
self.stack_name_prefix = stack_name_prefix
20-
self.stack_names = [f"{stack_name_prefix}-p1", f"{stack_name_prefix}-p2"]
22+
self.stack_names = [f"{stack_name_prefix}-{suffix}" for suffix in DEPLOY_PATTERNS.keys()]
2123
self.file_path = file_path
2224
self.verify_string = verify_string
2325

0 commit comments

Comments
 (0)