Skip to content

Commit a9ffc25

Browse files
author
Bob Strahan
committed
Merge branch 'develop' v0.5.4
2 parents 85e524a + 095ae80 commit a9ffc25

101 files changed

Lines changed: 15008 additions & 5037 deletions

File tree

Some content is hidden

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

.github/workflows/developer-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
steps:
3030
- name: Checkout code
31-
uses: actions/checkout@v4
31+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
3232
with:
3333
fetch-depth: 0 # Fetch all history for git diff in typecheck-pr
3434

@@ -89,7 +89,7 @@ jobs:
8989
continue-on-error: false
9090

9191
- name: Upload coverage reports
92-
uses: actions/upload-artifact@v4
92+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9393
if: always() && steps.run-tests.outcome != 'skipped'
9494
with:
9595
name: test-reports
@@ -99,15 +99,15 @@ jobs:
9999
retention-days: 7
100100

101101
- name: Publish test results
102-
uses: EnricoMi/publish-unit-test-result-action@v2
102+
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2.23.0
103103
if: always() && hashFiles('lib/idp_common_pkg/test-reports/test-results.xml') != ''
104104
with:
105105
files: lib/idp_common_pkg/test-reports/test-results.xml
106106
check_name: Test Results
107107
comment_mode: off # Disable PR comments to avoid permission issues on fork PRs
108108

109109
- name: Code Coverage Report
110-
uses: irongut/CodeCoverageSummary@v1.3.0
110+
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
111111
if: always() && hashFiles('lib/idp_common_pkg/test-reports/coverage.xml') != ''
112112
with:
113113
filename: lib/idp_common_pkg/test-reports/coverage.xml

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,39 @@ SPDX-License-Identifier: MIT-0
55

66
## [Unreleased]
77

8+
## [0.5.4]
9+
10+
### Added
11+
12+
- **MLflow Experiment Tracking Integration** — Optional integration with Amazon SageMaker MLflow for automated test run logging. When enabled (`EnableMLflow=true`), every Test Studio run automatically logs metrics (accuracy, cost, field-level scores), configuration parameters (model IDs, temperatures, inference settings), and artifacts (full config snapshots, class definitions, cost breakdowns) to an MLflow tracking server. Fire-and-forget async invocation — never blocks or delays test results. Zero resources created when disabled. See `docs/mlflow-integration.md`.
13+
14+
- **BDA Blueprint Optimization** — Automatically improves BDA extraction accuracy using the `InvokeBlueprintOptimizationAsync` API. When discovery includes a ground truth file and `enable_blueprint_optimization: true` is set, the system optimizes the BDA blueprint by comparing extraction results against ground truth, evaluates before/after metrics, and updates the blueprint schema if improved. Disabled by default. See `docs/discovery.md` — Blueprint Optimization section.
15+
16+
- **idp_common API Reference & Documentation** — Added `docs/idpcommon-api-reference.md` covering all 22 modules, created 6 missing module READMEs (discovery, schema, image, s3, utils, metrics), updated core data model docs to match current code, fixed `IDPConfig` lazy-loading bug in `__init__.py`, and integrated into docs-site sidebar.
17+
18+
- **Consolidated publish and headless deploy into `idp-cli`** — All build/publish/deploy functionality now available through the CLI, deprecating standalone scripts:
19+
- `publish.py` and `publish.sh` are deprecated — use `idp-cli publish` instead. `publish.py` remains as a thin backward-compatibility wrapper. `publish.sh` has been removed.
20+
- `scripts/generate_govcloud_template.py` is deprecated — use `idp-cli publish --headless` or `idp-cli deploy --headless` instead. The script remains as a thin wrapper.
21+
- New `--template-file` option on `idp-cli deploy` for deploying from a local CloudFormation template file produced by a previous `idp-cli publish`.
22+
- `idp-cli deploy --headless` (without `--from-code`) now downloads the published template, transforms to headless with GovCloud config defaults, uploads to S3, and deploys — all in one command.
23+
24+
### Fixed
25+
26+
- **HITL review start overwrites document sections** — Fixed the Start Review action to update only the Review Status and Review Owner fields, preserving all existing document sections and other fields.
27+
28+
- **Evaluation schema error for free-form objects** — Stickler mapper now detects and skips unevaluable object schemas (e.g., objects with `additionalProperties` but no defined `properties`, and arrays of such objects) instead of raising validation errors.
29+
30+
- **Full document reprocess not re-running OCR** — Fixed bug where clicking "Reprocess" in the UI reused stale OCR results from the previous run instead of re-executing OCR with the current configuration. The reprocess resolver now deletes previous output data from S3 before queuing, preventing the OCR function's retry-safe recovery from reinstalling old results.
31+
32+
- **Agentic extraction timeout on long documents** — Fixed repeated Lambda timeouts when agentic extraction exceeds the 15-minute limit on large documents (e.g., 25-page brokerage statements with 600+ holdings). Added incremental S3 checkpointing that saves extraction state after each tool call — covers both the extraction tools path (`extraction_tool`, `apply_json_patches`, `make_buffer_data_final_extraction`) and the buffer tools path (`patch_buffer_data`) that the agent uses for very large batched extractions. The checkpoint format tracks which state was saved (`current_extraction` vs `intermediate_extraction` buffer) so the correct resume path is used. On Step Function retry, the Lambda loads the checkpoint and the agent resumes from where it left off rather than restarting from scratch. No CloudFormation or Step Function changes required — the existing `Sandbox.Timedout` retry mechanism now makes incremental progress. Only active when agentic extraction is enabled; standard extraction is unaffected.
33+
34+
- **Agentic extraction fails on Bedrock InternalServerException without retrying** — Fixed `InternalServerException` errors (transient Bedrock server-side errors) causing immediate Lambda failure after only botocore's fast 7 retries, bypassing the application-level retry decorator (50 retries with 5s→1800s exponential backoff). Root cause: `InternalServerException` and `InternalServerError` were missing from all three retry layers — the `async_exponential_backoff_retry` decorator's `DEFAULT_RETRYABLE_ERRORS` set (`bedrock_utils.py`), the `BedrockClient._invoke_with_retry()` retryable errors list (`bedrock/client.py`), and the Step Functions ExtractionStep Retry `ErrorEquals` list (`workflow.asl.json`). All three layers now include these transient errors, providing proper exponential backoff retry at the application level and Lambda-level retry via Step Functions as a safety net.
35+
36+
### Templates
37+
- us-west-2: `https://s3.us-west-2.amazonaws.com/aws-ml-blog-us-west-2/artifacts/genai-idp/idp-main_0.5.4.yaml`
38+
- us-east-1: `https://s3.us-east-1.amazonaws.com/aws-ml-blog-us-east-1/artifacts/genai-idp/idp-main_0.5.4.yaml`
39+
- eu-central-1: `https://s3.eu-central-1.amazonaws.com/aws-ml-blog-eu-central-1/artifacts/genai-idp/idp-main_0.5.4.yaml`
40+
841
## [0.5.3]
942

1043
### Added

CLAUDE.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ python3 publish.py idp-1234567890 idp us-east-1
2424
# With verbose output for debugging build failures
2525
python3 publish.py idp-1234567890 idp us-east-1 --verbose
2626

27-
# Legacy build script
28-
./publish.sh <cfn_bucket_basename> <cfn_prefix> <region>
2927
```
3028

3129
The build process:
3230
- Checks system dependencies (AWS CLI, SAM CLI, Docker, Python 3.12+, Node.js 22.12+)
3331
- Builds CloudFormation templates and assets using SAM
34-
- Pattern-2 functions are built as container images; Pattern-1 and Pattern-3 use ZIP-based Lambdas
32+
- All pattern functions are built within the unified pattern directory
3533
- Uploads artifacts to S3 bucket named `<cfn_bucket_basename>-<region>`
3634

3735
### Code Quality & Linting
@@ -91,8 +89,10 @@ pytest -m "integration"
9189
The IDP CLI is used for programmatic deployment and batch processing:
9290

9391
```bash
94-
# Install CLI
92+
# Install all packages into current Python environment
9593
make setup
94+
# Or create an isolated .venv first
95+
make setup-venv
9696

9797
# Deploy a new stack
9898
idp-cli deploy \
@@ -106,7 +106,7 @@ idp-cli deploy \
106106
idp-cli deploy \
107107
--stack-name my-idp-stack \
108108
--pattern pattern-2 \
109-
--custom-config ./config_library/pattern-2/bank-statement-sample/config.yaml \
109+
--custom-config ./config_library/unified/bank-statement-sample/config.yaml \
110110
--wait
111111

112112
# Process documents in batch
@@ -125,7 +125,7 @@ idp-cli download-results \
125125
### Local Lambda Testing
126126

127127
```bash
128-
cd patterns/pattern-2/
128+
cd patterns/unified/
129129
sam build
130130
sam local invoke OCRFunction -e ../../testing/OCRFunction-event.json --env-vars ../../testing/env.json
131131
```
@@ -153,30 +153,26 @@ The solution uses a modular architecture with the main template (`template.yaml`
153153
- Authentication (Cognito User Pool, Identity Pool)
154154
- AppSync GraphQL API (for UI-backend communication)
155155

156-
**Pattern Stacks** (`patterns/pattern-*/template.yaml`) - Pattern-specific resources:
157-
- Step Functions State Machine
158-
- Pattern-specific Lambda Functions (OCR, Classification, Extraction)
159-
- Pattern-specific CloudWatch Dashboard
160-
- Model Endpoints and Configurations
156+
**Unified Pattern Stack** (`patterns/unified/template.yaml`) - Processing resources:
157+
- Step Functions State Machine (BDA branch + Pipeline branch + shared tail)
158+
- Lambda Functions (OCR, Classification, Extraction, Assessment, Summarization, Evaluation, etc.)
159+
- CloudWatch Dashboard
161160

162-
### Processing Patterns
161+
### Processing Modes
163162

164-
1. **Pattern 1: Bedrock Data Automation (BDA)**
163+
The unified architecture supports two processing modes, controlled by the `use_bda` configuration flag:
164+
165+
1. **BDA Mode** (formerly Pattern 1)
165166
- Uses AWS Bedrock Data Automation for end-to-end processing
166167
- Handles packet or media documents with integrated OCR, classification, and extraction
167-
- Location: `patterns/pattern-1/`
168168

169-
2. **Pattern 2: Textract + Bedrock**
169+
2. **Pipeline Mode** (formerly Pattern 2)
170170
- OCR with Amazon Textract
171171
- Classification with Bedrock (page-level or holistic)
172172
- Extraction with Bedrock
173173
- Supports few-shot examples
174-
- Location: `patterns/pattern-2/`
175174

176-
3. **Pattern 3: Textract + UDOP + Bedrock**
177-
- OCR with Amazon Textract
178-
- Classification with UDOP model on SageMaker
179-
- Extraction with Bedrock
175+
> **Note**: The separate `patterns/pattern-1/`, `patterns/pattern-2/`, and `patterns/pattern-3/` directories have been removed. All processing is now in `patterns/unified/`. See [pattern-1.md](docs/pattern-1.md) and [pattern-2.md](docs/pattern-2.md) for historical reference.
180176
181177
### Document Processing Flow
182178

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ The project uses `make` to simplify common development tasks. Run `make` or `mak
127127

128128
| Command | Description |
129129
|---------|-------------|
130-
| `make setup` | Create virtual environment and install all packages in development mode |
130+
| `make setup` | Install all packages into your current Python environment (no venv) |
131+
| `make setup-venv` | Create `.venv` virtual environment and install all packages into it |
131132

132133
### Code Quality
133134

Dockerfile.optimized

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ENV UV_LINK_MODE=copy
2222
# Build argument for function path
2323
ARG FUNCTION_PATH
2424
ARG INSTALL_IDP_COMMON=true
25+
ARG INSTALL_GIT=false
2526

2627
# Create working directory
2728
WORKDIR /build
@@ -44,6 +45,10 @@ RUN --mount=from=uv,source=/uv,target=/bin/uv \
4445
# Final stage - minimal runtime
4546
FROM public.ecr.aws/lambda/python:3.12-arm64
4647

48+
# Conditionally install git (required for mlflow/gitpython)
49+
ARG INSTALL_GIT=false
50+
RUN if [ "$INSTALL_GIT" = "true" ]; then dnf install -y git && dnf clean all; fi
51+
4752
# Copy the runtime dependencies from the builder stage
4853
COPY --from=builder ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT}
4954

Makefile

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,33 @@ help: ## Show this help message
4343
all: lint test ## Run lint + test (default)
4444

4545
##@ Setup
46-
setup: ## Create venv and install all packages in development mode
46+
setup: ## Install all packages into current Python environment (no venv)
47+
@# Always use the current shell's pip, ignoring .venv even if it exists
48+
@SETUP_PIP=$$(python3 -m pip --version >/dev/null 2>&1 && echo "python3 -m pip" || echo "pip3"); \
49+
SETUP_PYTHON=$$(command -v python3 2>/dev/null || echo python); \
50+
echo "Installing packages into current Python environment..."; \
51+
echo "Python: $$($$SETUP_PYTHON --version) at $$(which $$SETUP_PYTHON)"; \
52+
echo "Pip: $$SETUP_PIP"; \
53+
echo ""; \
54+
echo "Upgrading pip..."; \
55+
$$SETUP_PIP install --upgrade pip && \
56+
echo "Installing idp_common package with all dependencies (including test)..." && \
57+
$$SETUP_PIP install -e "lib/idp_common_pkg[all,dev,test]" && \
58+
echo "Installing idp-cli package..." && \
59+
$$SETUP_PIP install -e lib/idp_cli_pkg && \
60+
echo "Installing idp_sdk package..." && \
61+
$$SETUP_PIP install -e lib/idp_sdk && \
62+
echo "Installing idp_mcp_connector package..." && \
63+
$$SETUP_PIP install -e lib/idp_mcp_connector_pkg && \
64+
echo "Installing capacity planning test dependencies..." && \
65+
$$SETUP_PIP install -r src/lambda/calculate_capacity/requirements-test.txt && \
66+
echo "Installing cfn-lint for CloudFormation template validation..." && \
67+
$$SETUP_PIP install cfn-lint && \
68+
echo "" && \
69+
echo -e "$(GREEN)✅ Setup complete! idp_common, idp-cli, idp_sdk, idp_mcp_connector, and test dependencies are now installed.$(NC)" && \
70+
echo -e "$(YELLOW) Tip: Use 'make setup-venv' instead to install into an isolated virtual environment.$(NC)"
71+
72+
setup-venv: ## Create .venv and install all packages into it
4773
@echo "Creating virtual environment in $(VENV_DIR)..."
4874
@PYENV_PYTHON=$$(pyenv which python 2>/dev/null); \
4975
SYS_PYTHON=$$(command -v python3 2>/dev/null); \
@@ -66,6 +92,8 @@ setup: ## Create venv and install all packages in development mode
6692
$(VENV_DIR)/bin/pip install -e lib/idp_mcp_connector_pkg
6793
@echo "Installing capacity planning test dependencies..."
6894
$(VENV_DIR)/bin/pip install -r src/lambda/calculate_capacity/requirements-test.txt
95+
@echo "Installing cfn-lint for CloudFormation template validation..."
96+
$(VENV_DIR)/bin/pip install cfn-lint
6997
@echo ""
7098
@echo -e "$(GREEN)✅ Setup complete! Virtual environment created at $(VENV_DIR)$(NC)"
7199
@echo -e "$(GREEN) idp_common, idp-cli, idp_sdk, idp_mcp_connector, and test dependencies are now installed.$(NC)"
@@ -343,10 +371,7 @@ docs-deploy: docs-build ## Deploy docs to GitHub Pages (from local build)
343371

344372
##@ Security (DSR)
345373
dsr: ## Run full DSR workflow (setup → scan → optional fix)
346-
@if [ ! -f .dsr/dsr ]; then \
347-
echo "DSR not found, running setup..."; \
348-
$(MAKE) dsr-setup; \
349-
fi
374+
@$(MAKE) dsr-setup
350375
@$(MAKE) dsr-scan
351376
@echo ""
352377
@echo "Do you want to run DSR fix? (y/N):"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ For detailed deployment and testing instructions, see the [Deployment Guide](./d
187187
- [Assessment](./docs/assessment.md) - Extraction confidence evaluation using LLMs
188188
- [Rule Validation](./docs/rule-validation.md) - Business rule validation and compliance checking
189189
- [Evaluation Framework](./docs/evaluation.md) - Accuracy assessment system with analytics database and reporting
190+
- [MLflow Experiment Tracking](./docs/mlflow-integration.md) - Optional MLflow integration for tracking metrics, model parameters, and prompts across test runs
190191
- [Knowledge Base](./docs/knowledge-base.md) - Document knowledge base query feature
191192
- [Monitoring](./docs/monitoring.md) - Monitoring and logging capabilities
192193
- [IDP Accelerator Help Chat Bot](./docs/code-intelligence.md) - Chat bot for asking question about the IDP code base and features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.3
1+
0.5.4

docs-site/astro.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default defineConfig({
5454
{ label: "Web UI", slug: "web-ui" },
5555
{ label: "IDP CLI", slug: "idp-cli" },
5656
{ label: "IDP SDK", slug: "idp-sdk" },
57+
{ label: "idp_common API Reference", slug: "idpcommon-api-reference" },
5758
{ label: "Demo Videos", slug: "demo-videos" },
5859
{ label: "Troubleshooting", slug: "troubleshooting" },
5960
{ label: "Error Analyzer", slug: "error-analyzer" },
@@ -97,6 +98,7 @@ export default defineConfig({
9798
slug: "evaluation-enhanced-reporting",
9899
},
99100
{ label: "Test Studio", slug: "test-studio" },
101+
{ label: "MLflow Experiment Tracking", slug: "mlflow-integration" },
100102
],
101103
},
102104
{

docs/assessment-bounding-boxes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The Assessment Service now supports **optional bounding box extraction** as part
2020
### Core Capabilities
2121

2222
- **Optional Feature**: Disabled by default, enabled via configuration
23-
- **UI Compatible**: Outputs geometry format compatible with existing pattern-1 UI
23+
- **UI Compatible**: Outputs geometry format compatible with existing BDA mode UI
2424
- **Multi-page Support**: Handles bounding boxes across multiple document pages
2525
- **Error Resilient**: Gracefully handles invalid or incomplete bounding box data
2626
- **Coordinate Normalization**: Converts from 0-1000 scale to 0-1 normalized coordinates
@@ -325,7 +325,7 @@ if explainability_info:
325325

326326
## Integration with UI
327327

328-
The geometry format is fully compatible with the existing pattern-1 UI:
328+
The geometry format is fully compatible with the existing BDA mode UI:
329329

330330
- **Coordinate System**: Normalized 0-1 coordinates
331331
- **Bounding Box Format**: `{top, left, width, height}`

0 commit comments

Comments
 (0)