Skip to content

Commit b029132

Browse files
author
Taniya Mathur
committed
Merge branch 'develop' into feature/automate-dsr-checks
2 parents 2cb3d98 + bc28967 commit b029132

File tree

10 files changed

+2435
-19
lines changed

10 files changed

+2435
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ build.toml
44
model.tar.gz
55
.checksum
66
.checksums/
7+
.build_checksum
8+
.lib_checksum
79
.vscode/
810
.DS_Store
911
dist/

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ developer_tests:
2828
- apt-get update -y
2929
- apt-get install make -y
3030
- pip install ruff
31+
# Install dependencies needed by publish.py for test imports
32+
- pip install typer rich boto3
3133
# Install test dependencies
3234
- cd lib/idp_common_pkg && pip install -e ".[test]" && cd ../..
3335

CHANGELOG.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,72 @@ SPDX-License-Identifier: MIT-0
77

88
### Added
99

10+
- **Modern Python-Based Publishing System**
11+
- **Complete Rewrite**: Replaced legacy `publish.sh` bash script (583 lines) with modern `publish.py` Python script (1,294 lines)
12+
- **Enhanced User Experience**: Rich console interface with progress bars, spinners, and colored output using Rich library
13+
- **Concurrent Processing**: Multi-threaded artifact building and uploading for significantly improved performance
14+
- **Cross-Platform Support**: Native support for Linux, macOS, and Windows environments
15+
- **Intelligent Caching**: Advanced checksum-based build optimization to skip unnecessary rebuilds
16+
- **Robust Error Handling**: Comprehensive error handling with detailed error messages and recovery suggestions
17+
- **Resource Management**: Automatic cleanup of temporary files and proper resource management
18+
- **CLI Interface**: Modern command-line interface using Typer with clear help documentation and parameter validation
19+
- **Key Features**:
20+
- Parallel S3 uploads with thread-safe progress tracking
21+
- CloudFormation template validation and processing
22+
- Automatic bucket creation with proper permissions and lifecycle policies
23+
- Build artifact optimization with dependency tracking
24+
- Comprehensive logging and debugging capabilities
25+
- Memory-efficient processing for large artifacts
26+
27+
- **Comprehensive Unit Test Suite for Publishing System**
28+
- **Extensive Test Coverage**: 1,621 lines of unit tests covering 95%+ of publish.py functionality
29+
- **Testing Framework**: Uses pytest with proper unit test markers (`@pytest.mark.unit`) following project testing standards
30+
- **Mock Integration**: Comprehensive mocking of AWS services (S3, CloudFormation) for isolated unit testing without external dependencies
31+
- **Cross-Platform Testing**: Tests for Linux, macOS, and Windows-specific functionality and edge cases
32+
- **Error Scenario Coverage**: Tests for network failures, permission errors, malformed templates, and concurrent access scenarios
33+
- **Performance Testing**: Tests for concurrent operations, memory usage, and resource cleanup
34+
- **Key Test Categories**:
35+
- IDPPublisher initialization and configuration
36+
- S3 operations (bucket creation, uploads, permissions)
37+
- CloudFormation template processing and validation
38+
- Build system integration and checksum validation
39+
- Error handling and recovery mechanisms
40+
- Concurrent publishing workflows and thread safety
41+
42+
- **Windows Development Environment Setup**
43+
- **Automated Setup Script**: New `scripts/dev_setup.bat` (570 lines) for complete Windows development environment configuration
44+
- **Comprehensive Installation**: Automated installation of all required development tools and dependencies
45+
- **Tool Installation**:
46+
- AWS CLI with proper configuration
47+
- Python 3.13 (required for compatibility with latest dependencies)
48+
- Node.js for React UI development
49+
- Git for version control
50+
- Docker for containerized development
51+
- AWS SAM CLI for serverless application development
52+
- Python dependencies (boto3, numpy 2.3.2, typer, rich)
53+
- **Environment Configuration**: Automatic AWS credentials setup and project cloning with dependency installation
54+
- **Administrator Privileges**: Proper handling of Windows administrator requirements for system-level installations
55+
- **Error Handling**: Comprehensive error checking and user guidance throughout the setup process
56+
1057
- **OCR Service Default Image Sizing for Resource Optimization**
1158
- Implemented automatic default image size limits (951×1268) when no image sizing configuration is provided
1259
- **Key Benefits**: Reduction in vision model token consumption, prevents OutOfMemory errors during concurrent processing, improves processing speed and reduces bandwidth usage
1360

61+
### Changed
62+
63+
- **Publishing Workflow Modernization**
64+
- Migrated from bash-based to Python-based publishing system for better maintainability and cross-platform support
65+
- Improved build performance through intelligent caching and concurrent processing
66+
- Enhanced developer experience with rich console output and clear progress indicators
67+
- Better error diagnostics and troubleshooting capabilities
68+
69+
### Technical Improvements
70+
71+
- **Build System Optimization**: Checksum-based incremental builds reduce unnecessary processing time
72+
- **Memory Management**: Efficient handling of large artifacts and proper resource cleanup
73+
- **Thread Safety**: Concurrent operations with proper synchronization and error handling
74+
- **Code Quality**: Comprehensive unit testing ensures reliability and maintainability of the publishing system
75+
1476

1577

1678

docs/deployment.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ You need to have the following packages installed on your computer:
2626
3. [sam (AWS SAM)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)
2727
4. python 3.11 or later
2828
5. A local Docker daemon
29+
6. Python packages for publish.py: `pip install boto3 typer rich botocore`
2930

3031
For guidance on setting up a development environment, see: [Development Environment Setup Guide on Linux](./setup-development-env-linux.md) or [Development Environment Setup Guide on MacOS](./setup-development-env-macos.md)
3132

@@ -40,28 +41,53 @@ To build and publish your own template to your own S3 bucket:
4041
* `cfn_bucket_basename`: A prefix added to the beginning of the bucket name (e.g. `idp-1234567890` to ensure global uniqueness)
4142
* `cfn_prefix`: A prefix added to CloudFormation resources (e.g. `idp` or `idp-dev`)
4243

43-
Navigate into the project root directory and, in a bash shell, run:
44+
Navigate into the project root directory and run:
45+
46+
#### Using publish.py (Recommended)
4447

4548
```bash
46-
./publish.sh <cfn_bucket_basename> <cfn_prefix> <region e.g. us-east-1>
49+
python3 publish.py <cfn_bucket_basename> <cfn_prefix> <region> [--verbose]
4750
```
4851

49-
This script:
50-
- Checks your system dependencies for required packages
51-
- Creates CloudFormation templates and asset zip files
52-
- Publishes the templates and required assets to an S3 bucket in your account
53-
- The bucket will be named `<cfn_bucket_basename>-<region>` (created if it doesn't exist)
52+
**Parameters:**
53+
- `cfn_bucket_basename`: A prefix for the S3 bucket name (e.g., `idp-1234567890`)
54+
- `cfn_prefix`: S3 prefix for artifacts (e.g., `idp`)
55+
- `region`: AWS region for deployment (e.g., `us-east-1`)
56+
- `--verbose` or `-v`: (Optional) Enable detailed error output for debugging build failures
5457

5558
Example:
5659
```bash
57-
./publish.sh idp-1234567890 idp us-east-1
60+
python3 publish.py idp-1234567890 idp us-east-1
61+
```
62+
63+
**Troubleshooting Build Issues:**
64+
If the build fails, use the `--verbose` flag to see detailed error messages:
65+
```bash
66+
python3 publish.py idp-1234567890 idp us-east-1 --verbose
5867
```
5968

60-
Optional: Add a final parameter `public` if you want to make the published artifacts publicly accessible:
69+
This will show:
70+
- Exact SAM build commands being executed
71+
- Complete error output from failed builds
72+
- Python version compatibility issues
73+
- Missing dependencies or configuration problems
74+
75+
#### Using publish.sh (Legacy)
76+
6177
```bash
62-
./publish.sh idp-1234567890 idp us-east-1 public
78+
./publish.sh <cfn_bucket_basename> <cfn_prefix> <region>
6379
```
64-
Note: Your bucket and account must be configured not to Block Public Access using new ACLs.
80+
81+
Example:
82+
```bash
83+
./publish.sh idp-1234567890 idp us-east-1
84+
```
85+
86+
Both scripts:
87+
- Check your system dependencies for required packages
88+
- Create CloudFormation templates and asset zip files
89+
- Publish the templates and required assets to an S3 bucket in your account
90+
- The bucket will be named `<cfn_bucket_basename>-<region>` (created if it doesn't exist)
6591

6692
When completed, the script displays:
6793
- The CloudFormation template's S3 URL

docs/setup-development-env-linux.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,50 @@ Host genai-idp-dev
112112
### Refer this link for AWS configure
113113
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html
114114

115-
# Step 6: Run Publish Script
116-
## Test Build Process
115+
# Step 6: Install Python Dependencies for publish.py
116+
117+
## Install Required Python Packages
118+
```bash
119+
pip install boto3 typer rich botocore
120+
```
121+
122+
# Step 7: Run Publish Script
123+
124+
## Using publish.py (Recommended)
125+
126+
### Test publish script help
127+
```bash
128+
python3 publish.py --help
129+
```
130+
131+
### Test build using publish.py
132+
```bash
133+
python3 publish.py bucket_name build-test us-east-1
134+
```
135+
136+
### Troubleshooting Build Issues
137+
If the build fails, use the `--verbose` flag to see detailed error messages:
138+
```bash
139+
python3 publish.py bucket_name build-test us-east-1 --verbose
140+
```
141+
142+
The verbose flag will show:
143+
- Exact SAM build commands being executed
144+
- Complete error output from failed builds
145+
- Python version compatibility issues
146+
- Missing dependencies or configuration problems
147+
148+
## Using publish.sh (Legacy)
149+
117150
### Test publish script help
151+
```bash
118152
./publish.sh --help
153+
```
119154

120-
### Test build (this will take 10-15 minutes)
155+
### Test build using publish.sh
156+
```bash
121157
./publish.sh bucket_name build-test us-east-1
158+
```
122159

123160
# Step 7: Cline & Q Developer installation
124161
### Cline

docs/setup-development-env-macos.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,55 @@ EOF
242242
- SAM CLI: run `sam --version`.
243243
- Docker: launch Docker.app, then run `docker version` in Terminal.
244244

245-
## **12) Configure AWS CLI**
245+
## **12) Install Python Dependencies for publish.py**
246+
247+
Install the required Python packages for the publish.py script:
248+
249+
```bash
250+
pip install boto3 typer rich botocore
251+
```
252+
253+
## **13) Configure AWS CLI**
246254
### Refer this link for AWS configure
247255
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html
248-
# Troubleshooting Tips
256+
257+
## **14) Run Publish Script**
258+
259+
### Using publish.py (Recommended)
260+
261+
Test publish script help:
262+
```bash
263+
python3 publish.py --help
264+
```
265+
266+
Test build using publish.py:
267+
```bash
268+
python3 publish.py bucket_name build-test us-east-1
269+
```
270+
271+
**Troubleshooting Build Issues:**
272+
If the build fails, use the `--verbose` flag to see detailed error messages:
273+
```bash
274+
python3 publish.py bucket_name build-test us-east-1 --verbose
275+
```
276+
277+
The verbose flag will show:
278+
- Exact SAM build commands being executed
279+
- Complete error output from failed builds
280+
- Python version compatibility issues
281+
- Missing dependencies or configuration problems
282+
283+
### Using publish.sh (Legacy)
284+
285+
Test publish script help:
286+
```bash
287+
./publish.sh --help
288+
```
289+
290+
Test build using publish.sh:
291+
```bash
292+
./publish.sh bucket_name build-test us-east-1
293+
```
249294

250295
- If `brew` is not found, add it to PATH:
251296
```bash
@@ -258,7 +303,7 @@ eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shell
258303

259304
- Docker needs to be running before `docker` commands succeed. Launch Docker.app and wait for the whale icon to be steady.
260305

261-
## Cline & Q Developer installation
306+
# Troubleshooting Tips
262307
### Cline
263308
What it is: An AI coding assistant that runs as a VS Code extension, powered by various LLMs (Claude, GPT, etc.)
264309

docs/troubleshooting.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,53 @@ Test system capacity and identify bottlenecks:
198198
2. Start with low document rates and increase gradually
199199
3. Monitor CloudWatch metrics for saturation points
200200
4. Identify bottlenecks and optimize configuration
201+
202+
## Build and Deployment Issues
203+
204+
### Publishing Script Failures
205+
206+
| Issue | Resolution |
207+
|-------|------------|
208+
| **Generic "Failed to build" error** | Use `--verbose` flag to see detailed error messages: `python3 publish.py bucket prefix region --verbose` |
209+
| **Python version mismatch** | Ensure Python 3.13 is installed and available in PATH. Check with `python3 --version` |
210+
| **SAM build fails** | Verify SAM CLI is installed and up to date. Check Docker is running if using containerized builds |
211+
| **Missing dependencies** | Install required packages: `pip install boto3 typer rich botocore` |
212+
| **Permission errors** | Verify AWS credentials are configured and have necessary S3/CloudFormation permissions |
213+
214+
### Common Build Error Messages
215+
216+
**Python Runtime Error:**
217+
```
218+
Error: PythonPipBuilder:Validation - Binary validation failed for python, searched for python in following locations: [...] which did not satisfy constraints for runtime: python3.13
219+
```
220+
**Resolution:** Install Python 3.13 and ensure it's in your PATH, or use the `--use-container` flag for containerized builds.
221+
222+
**Docker Not Running:**
223+
```
224+
Error: Running AWS SAM projects locally requires Docker
225+
```
226+
**Resolution:** Start Docker daemon before running the publish script.
227+
228+
**AWS Credentials Not Found:**
229+
```
230+
Error: Unable to locate credentials
231+
```
232+
**Resolution:** Configure AWS credentials using `aws configure` or set environment variables.
233+
234+
### Verbose Mode Usage
235+
236+
For detailed debugging information, always use the `--verbose` flag when troubleshooting build issues:
237+
238+
```bash
239+
# Standard usage
240+
python3 publish.py my-bucket idp us-east-1
241+
242+
# Verbose mode for troubleshooting
243+
python3 publish.py my-bucket idp us-east-1 --verbose
244+
```
245+
246+
Verbose mode provides:
247+
- Exact SAM build commands being executed
248+
- Complete stdout/stderr from failed operations
249+
- Python environment and dependency information
250+
- Detailed error traces and stack traces

0 commit comments

Comments
 (0)