Praneel Panchigar a0c7e7a738 Merged in bugfix/dynamic_issues_feb12 (pull request #882)
Bugfix/dynamic issues feb12

* prompt changes reverted

* fix pipeline issues

* fix pipeline issues

* fix pipeline issues

* fixed formatting

* fixed formatting

* Merge branch 'DEV' into Optimize/DAIP2-1474-restructure-postprocess

* Merge branch 'DEV' into Optimize/DAIP2-1474-restructure-postprocess

* save dashboard and cc output separately

* save dashboard output in s3

* pipeline error fixed

* json list through postprocessing

* Merged DEV into Optimize/DAIP2-1474-restructure-postprocess

* Merge remote-tracking branch 'origin/Optimize/DAIP2-1474-restructure-postprocess' into feature/new_output_format

* Restructure output file organization and add standard field sanitization

Output Structure Changes:
- Reorganize output files into hierarchical directory structure:
  - full_outputs/cc_results/ for consolidated CC results
  - full_outputs/dashboard_results/ for consolidated dashboard results
  - full_outputs/ for error files
  - automation_qa-qc/ for QC/QA validated results and statistics
  - parent-child/ for parent-child mapping outputs
  - tracking/ for usage and cost tracking data
  - individual/ for per-file CC results (dashboard individual files removed)
- Update file naming conventions to match new structure
- Remove QC/QA processing for error files (error files are saved without validation)

Post-Processing Changes:
- Add standard N/A value cleaning: remove placeholder values (N/A, UNKNOWN, etc.)
  when they are the only value in a cell (applies before CC/dashboard split)
- Normalize all _IND fields to contain only 'Y' or 'N' values (no blanks)
- Ensure standard cleaning runs before splitting into CC …
* Ran Black for CI

* Refactor file splitting logic and add comprehensive tests

- Refactored splitting logic in io_utils.py:
  - Consolidated repeated splitting code into two focused helper functions:
    - _write_local_split_files() for local file writing with splitting
    - _write_s3_split_files() for S3 file writing with splitting
  - Both helpers use shared split_dataframe_by_filename() function

- Added MAX_ROWS_PER_SPLIT configuration (default: 70000) in config.py

- Added comprehensive test coverage for splitting logic:
  - Tests for split_dataframe_by_filename() with various scenarios
  - Tests for local and S3 write operations with single and multiple splits
  - Tests for cc_results_full, dashboard_results_full, and qc_qa_cc_full output types
  - Fixed existing test failures (write_s3 error handling, path assertions)

- Improved code maintainability and readability

* Fix failing tests in test_postprocess.py

- Updated standard_postprocess tests to use actual columns from FIELD_FORMAT_MAPPING
  (PAYER_NAME, CONTRACT_TITLE) instead of custom test columns that get dropped
- Added FILE_NAME column to all file structure test DataFrames (required for splitting logic)
- Added MAX_ROWS_PER_SPLIT mock configuration for splitting tests
- Fixed patch decorators for S3 tests to properly mock logging

All 41 tests now passing.

* Black for CI

* Blank [] and ['[]'] in output instead of displaying them

- Add placeholder patterns in clean_na_values for [], ['[]'], ["[]"]
- Update format_as_json_list to return blank for empty lists instead of []
- Filter out empty-list placeholder items from list values in format_as_json_list
- Add tests for clean_na_values empty list handling and format_as_json_list

Co-authored-by: Cursor <cursoragent@cursor.com>

* Merged DEV into feature/new_output_format

* feat: dynamic primary debug improvements and LOB partial 1:1 escalation

- Add per-exhibit debug summary for dynamic primary discovery (page, values, raw LLM)
- Pass exhibit_page to dynamic_primary for debug; mark debug-only params for removal
- Fix 1:1 escalation skip: use base_field for PROGRAM/PRODUCT/NETWORK when LOB detected
- Pass LOB to 1:1 when empty in any row (partial detection from stripped headers)
- Add debug exhibit text preview; mark check_and_combine_exhibit_inheritance for deletion
- prompt_dynamic_primary returns (answer, raw); remove per-field prints

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: pass PROGRAM and PRODUCT to 1:1 when partial LOB

When LOB is empty in some rows (partial detection), pass LOB, PROGRAM, and
PRODUCT to 1:1 for contract-level extraction. Merge fills only empty cells
so 1:N values are preserved. Skip PROGRAM/PRODUCT/NETWORK only when full LOB.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Removed debug print blocks

* Merge origin/DEV into bugfix/dynamic_issues_feb12

Resolved conflicts:
- runner.py: Use RUN_DASHBOARD_POSTPROCESSING for conditional dashboard; parent-child output_dir and S3 upload
- main.py: Use RUN_DASHBOARD_POSTPROCESSING for conditional dashboard
- postprocess.py: Optional dashboard postprocessing when RUN_DASHBOARD_POSTPROCESSING is True

Co-authored-by: Cursor <cursoragent@cursor.com>


Approved-by: Katon Minhas
2026-02-13 21:44:46 +00:00
2026-02-06 14:25:04 -05:00

Field Extraction Pipeline

Contract field extraction using LLMs.

Setup

Install uv (if not already installed)

# Ubuntu/WSL (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.bashrc  # or restart terminal

# macOS
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows (PowerShell - native, not WSL)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Verify installation: uv --version

Install dependencies

uv sync

Running the Code

Use uv run with Python's module flag from the project root:

# Run the default SaaS pipeline
uv run python -m src.pipelines.saas.main

# Run with unified runner (supports client selection)
uv run python -m src.pipelines.runner --client saas --input-dir /path/to/input

# Run with specific client
uv run python -m src.pipelines.runner --client clover --input-dir /path/to/input

Note: Always use uv run to ensure correct virtual environment. Always use -m flag for proper imports.

Development

Before pushing, always run these checks to avoid breaking the CI pipeline:

# Format code
uv run black src/

# Type checking
uv run mypy src/

# Run tests
uv run pytest

All checks must pass before merging to main.

Project Structure

├── src/
│   ├── pipelines/              # Pipeline implementations
│   │   ├── runner.py           # Unified CLI entry point with client routing
│   │   ├── saas/               # Default SaaS pipeline
│   │   │   └── main.py         # Main entry point for SaaS
│   │   ├── shared/             # Shared pipeline components
│   │   │   ├── preprocessing/  # Document preprocessing
│   │   │   ├── extraction/     # Field extraction logic
│   │   │   └── postprocessing/ # Result postprocessing
│   │   └── clients/            # Client-specific overrides
│   │       └── clover/         # Clover client customizations
│   ├── core/                   # Core utilities (registry, fieldset)
│   ├── constants/              # Constants, mappings, and field definitions
│   │   ├── mappings/           # Crosswalk JSON files
│   │   └── lists/              # Lookup lists
│   ├── prompts/                # LLM prompt templates
│   ├── utils/                  # Shared utilities (IO, string, logging, etc.)
│   ├── codes/                  # Medical code extraction utilities
│   ├── crosswalk/              # Crosswalk mapping logic
│   ├── embeddings/             # Pre-computed embeddings for code matching
│   ├── qc_qa/                  # QC/QA validation pipeline
│   ├── parent_child/           # Parent-child relationship mapping
│   ├── document_classification/ # Document type classification (DTC)
│   └── tests/                  # Unit tests
├── documentation/              # Project documentation
├── outputs/                    # Pipeline output files (gitignored)
├── logs/                       # Log files (gitignored)
└── pyproject.toml              # Project dependencies (uv/pip)

Branching

Naming Conventions

Type Pattern Use Case Example
Feature feature/<ticket>-<description> New functionality feature/PROJ-123-add-export-csv
Bugfix bugfix/<ticket>-<description> Bug fixes bugfix/PROJ-456-fix-null-handling
Hotfix hotfix/<ticket>-<description> Urgent production fixes hotfix/PROJ-789-critical-parse-error
Test test/<description> Testing/experimentation test/lesser-table-caching-refactor
Release release/<version> Release preparation release/v1.2.0

Branch Guidelines

  • Use lowercase with hyphens (kebab-case) for descriptions
  • Include ticket number when applicable (e.g., JIRA, GitHub issue)
  • Keep branch names concise but descriptive
  • Delete branches after merging

Workflow

  1. Create branch from main
  2. Make changes and commit with clear messages
  3. Run checks before pushing: uv run black src/ && uv run mypy src/ && uv run pytest
  4. Create PR to main
  5. Ensure all CI checks pass
  6. Get code review approval
  7. Squash and merge
S
Description
AARETE DoczyAI pipelines mirror.
Readme 642 MiB
Languages
Python 80.5%
Jupyter Notebook 13%
HCL 3.1%
HTML 1.6%
PLpgSQL 1.5%
Other 0.2%