Commit Graph

29 Commits

Author SHA1 Message Date
Praneel Panchigar d3bfec0b6b Merged in bugfix/dynamic_issuefixes-clean (pull request #813)
Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

* Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

- Add format requirements to LOB_RELATIONSHIP_INSTRUCTION for proper caching
- Strengthen LOB_RELATIONSHIP prompt with explicit pipe delimiter requirements
- Preserve all DEBUG blocks and print statements in dynamic_funcs.py and file_processing.py
- Update crosswalk mappings and gitignore
- Ensure format instructions are cached at API level to prevent missing pipe delimiters

* Merge main into bugfix/dynamic_issuefixes-clean and remove all debug print statements

* Remove redundant one_to_one_fields initialization to match main


Approved-by: Katon Minhas
2025-12-17 20:42:13 +00:00
Praneel Panchigar 7056c1c687 Merged in feature/automated-cost-logging-csv (pull request #768)
Feature/automated cost logging csv

* feat: Add usage and cost tracking with CSV export

- Add usage_tracking.py module for thread-safe token and cost tracking
- Extract actual tokens from Bedrock API responses (replaces word count estimation)
- Integrate usage tracking into llm_utils.py for all LLM invocations
- Add CSV export functionality (per-file/per-model and batch summary)
- Integrate CSV export into main.py for local runs
- Update .gitignore to exclude PRD

Phase 1: Data collection and local CSV export implemented
- Tracks all LLM calls including utility functions (date_fix, derive_term_date)
- Calculates costs per model using centralized cost constants
- Generates two CSV files: USAGE.csv and USAGE-SUMMARY.csv
- Exports to same directory as final results when write_to_s3=False

* - Removed some temporary logging code
- Removed unused imports (uuid, datetime) from llm_utils.py
- Added cache token columns (cache_creation_tokens, cache_read_tokens) to CSV exports
- Added tracking for cache warming
- Updated usage_tracking.py to track cache tokens separately in data structure

All token tracking functionality remains intact.

* Split input tokens into fresh and cache in summary section

- Add total_fresh_input_tokens and total_cache_tokens to GLOBAL_USAGE
- Update summary CSV to include split token columns for better tractability
- Add averages for fresh_input_tokens and cache_tokens
- Maintain total_input_tokens = fresh_input_tokens + cache_tokens relationship
- All calculations verified and match per-file totals correctly

* upload files functionality

* Add comprehensive unit tests for usage_tracking module

- Implement Phase 1-4 tests covering all 10 functions in usage_tracking.py
- Add 98 test cases with parametrized tests for comprehensive coverage
- Fix extract_usage_from_response to handle None input gracefully
- Add python-dotenv dependency to pyproject.toml
- Tests cover: core functions, data access, export functions, and utilities
- All tests passing (98/98)

* Add S3 upload tests for main.py and fix f-string syntax error

- Add tests/test_investment_main_s3.py with 3 test cases:
  * test_main_writes_final_and_error_to_s3: validates both final and error DataFrames uploaded when processing has errors
  * test_main_writes_only_final_when_no_errors: validates only final DataFrame uploaded when all files succeed
  * test_main_writes_usage_when_present: validates usage tracking files uploaded when usage data exists
- Tests use monkeypatching and module stubs to isolate S3 write logic without external dependencies
- Fix syntax error in src/codes/code_funcs.py: nested f-string quotes (level_dict['level_suffix'])
- All tests passing

* Add comprehensive test for usage_tracking.get_usage_dataframes S3 uploads

- Add test_usage_dataframes_written_to_s3 to validate per_file_usage_df and batch_summary_df
- Test verifies both dataframes from usage_tracking.get_usage_dataframes() are written to S3
- Validates 'usage' suffix writes per_file_usage_df with correct schema (file_name, tokens, cost)
- Validates 'usage_summary' suffix writes batch_summary_df with correct schema (totals, averages, region_mode)
- Uses pd.testing.assert_frame_equal to ensure exact dataframes are uploaded
- Fix module caching issue between tests by clearing sys.modules cache
- All 4 tests passing

* Add cleanup fixture to prevent test pollution

- Add autouse pytest fixture to clean up stubbed modules after each test
- Remove manual cache clearing from individual tests (now handled by fixture)
- Prevents our module stubs from affecting other test files in CI/CD pipeline
- Fixes Bitbucket pipeline failures where other tests couldn't find llm_utils attributes

* Refactor tests: add comprehensive io_utils coverage; disable usage_tracking suite

- Added 22 focused tests for write_local and write_s3 plus existing IO behaviors
- Introduced FakeS3Client to avoid boto3 network/credential dependency
- Added preserve_config fixture (no monkeypatch) to isolate config side effects
- Marked test_usage_tracking.py skipped per new consolidation approach
- Verified 26 tests (io_utils + investment_main) all pass locally without AWS exceptions

* Fix S3_CLIENT mocking: use mocker.patch instead of direct assignment

- Changed preserve_config fixture to NOT save/restore S3_CLIENT
- Updated all 5 write_s3 tests to use mocker.patch('src.config.S3_CLIENT', fake)
- This prevents pollution of config.S3_CLIENT across test modules
- Fixes NoCredentialsError in other tests that were importing config after our tests set FakeS3Client
- All 22 io_utils tests pass + 4 investment_main_s3 tests pass
- test_llm_utils::test_invoke_claude_local_mode now passes

* Add tests for write_s3 function

* Resolve merge conflict: keep mocker-based write_s3 tests

* Remove rogue skip mark from test_usage_tracking.py

The skip mark was incorrectly added by remote branch claiming tests were
migrated to io_utils. However, test_io_utils.py only tests io_utils functions
(read/write operations), not usage_tracking functions.

Restore the comprehensive usage_tracking tests from commit 26a556f0 which
includes 98 test cases covering all 10 functions in usage_tracking.py.

* Fix test pollution: add config cleanup fixture and restore RUN_MODE

- Add autouse fixture in test_io_utils.py to restore config values after each test
- Fix test_llm_utils.py to restore RUN_MODE after test_invoke_claude_local_mode
- Prevents config patches from leaking into subsequent tests causing NoCredentialsError

* Remove redundant test_investment_main_s3.py

- File was testing same write_s3 functionality already covered in test_io_utils.py
- Was causing module pollution by stubbing src.utils.llm_utils
- Caused test failures in other test files due to module cache issues
- Integration testing was minimal and mocked write_s3 anyway

* Merged main into feature/automated-cost-logging-csv


Approved-by: Karan Desai
Approved-by: Katon Minhas
2025-11-10 19:29:45 +00:00
Alex Galarce 55fa4f2e79 Merged in feature/reimb-primary-improvements (pull request #524)
Reimbursement Exhibit Prefiltering

* Add IDENTIFY_REIMBURSEMENT_EXHIBITS function to analyze exhibit headers for reimbursement information

* Add Zone.Identifier to .gitignore to prevent Windows zone information files from being tracked

* Add functionality to identify reimbursement exhibits

* Add functionality to identify reimbursement exhibits in run_one_to_n_prompts

* Output YAML parsing

* Refactor identify_reimbursement_exhibits to improve YAML parsing and error handling

* New reimbursement exhibit logic

* Update IDENTIFY_REIMBURSEMENT_EXHIBITS_PROMPT to return PAGE NUMBERS instead of exhibit headers

* Fix identify_reimbursement_exhibits to return page numbers as strings after YAML parsing

* Remove debugging print statement for reimbursement exhibits in run_one_to_n_prompts

* Remove commented debugging print statements in identify_reimbursement_exhibits

* Increase read_timeout in EC2 configuration from 2000 to 4000

* Merge remote-tracking branch 'origin/main' into feature/reimb-primary-improvements

* Remove debugging print statements in get_reimbursement_primary function

* mypy error

* Fix return type in identify_reimbursement_exhibits to ensure keys are returned as a list

* Merge remote-tracking branch 'origin/main' into feature/reimb-primary-improvements


Approved-by: Katon Minhas
2025-05-13 20:22:43 +00:00
VenkataKrishna Reddy Avula 576ea95b6d Merged in code-breakout-mismaps (pull request #419)
DAIP2-112 - fixed get code descriptions

* indirect proc codes added

* bug fix

* bug fix

* Merge branch 'main' into proc-code-indirect

* description mapping handling X's and 0's

* bug fix

* Merge remote-tracking branch 'origin/proc-code-indirect' into code-breakout-mismaps

* testing mismaps

* revenue codes mapping for int values

* added function to find ranges

* removed test files

* Merged main into code-breakout-mismaps

* Merge branch 'main' into code-breakout-mismaps
pulled latest changes from main

* added unit test for find containing ranges

* modified find_containing_ranges_test file

* Merged main into code-breakout-mismaps

* added embeddings to git ignore

* updated find_containing_ranges_test.py


Approved-by: Alex Galarce
Approved-by: Katon Minhas
2025-03-03 16:07:29 +00:00
Alex Galarce 48aa1d836b Merged in feature/load_crosswalks (pull request #342)
Feature/load crosswalks

* allow .json in fieldExtraction/crosswalk

* clean up gitignores, add rule to allow .jsons in crosswalk, create first crosswalk

* create mappings directory

* add to_csv functionality for MCS to check results

* Merged main into feature/load_crosswalks


Approved-by: Katon Minhas
2025-01-06 21:10:25 +00:00
Alex Galarce 56e3fdd1f8 Merged in bugfix/all_cnc_hotfixes (pull request #302)
DRAFT: Bugfix/all cnc hotfixes

* Pipeline fix - health plan state

* Update for prompt vs non-prompt fixes

* Revert utils.find_regex_matches()

* Remove prints

* Non-prompt run

* Health Plan State, IRS, NPI, LOB, Lesser, Prov 2, Default, Rate Standard, Contract Effective Date, Term Group

* Merged in bugfix/agreement_name (pull request #294)

contract title fixed

* contract title fixed

* Merged bugfix/all_cnc_hotfixes into bugfix/agreement_name


Approved-by: Katon Minhas

* All hotfixes added

* Fixed utils

* fix for clean_contract_effective_date
* Merged in default-fix (pull request #296)

moved default funcs to the top, dropped intermediate columns

* moved default funcs to the top, dropped intermediate columns


Approved-by: Katon Minhas

* quick fix to dropping extra columns

* Merged in bugfix/effective_date_meridian (pull request #297)

fixed effective date for meridian contracts

* fixed effective date for meridian contracts


Approved-by: Katon Minhas

* Default rate and Lesser fix

* Merged in hotfix/irs_npi_updated (pull request #298)

updated irs and npi hotfix funcs

* updated irs and npi hotfix funcs

* Merged bugfix/all_cnc_hotfixes into hotfix/irs_npi_updated


Approved-by: Katon Minhas

* non-functional commit - default only

* debug commit - premerge

* Batch 1 Dup File Reconciliation

* Default rate fix

* Full CNC 1A Run Config

* Standard column refactor

* Working stitching for 1A

* Merged in Alex-Galarce/cnc_hotfix_effective_date_utilspy-edited-1732659983687 (pull request #301)

Remove "license" from effective date smart chunking

* Remove "license" from effective date smart chunking
* Merged bugfix/all_cnc_hotfixes into Alex-Galarce/cnc_hotfix_effective_date_utilspy-edited-1732659983687


Approved-by: Katon Minhas

* Merged in hotfix/irs_batch2_feedback (pull request #300)

IRS fix for feedback on batch2

* IRS fix for feedback on batch2

* Merged bugfix/all_cnc_hotfixes into hotfix/irs_batch2_feedback


Approved-by: Katon Minhas

* Merged main into bugfix/all_cnc_hotfixes


Approved-by: Katon Minhas
2024-11-27 15:08:04 +00:00
Michael McGuinness 5928ee0116 Merged in feature/add-dotenv (pull request #266)
Feature/add dotenv

* transferred sensitive information to .env file from src/config.py

* replace model IDs, AWS account info

* Merge remote-tracking branch 'origin/main' into feature/add-dotenv

* add explanatory comment

* Merge remote-tracking branch 'origin/main' into feature/add-dotenv

* remove tests that were just for local


Approved-by: Katon Minhas
2024-11-14 16:35:33 +00:00
Karan Desai 1098be5cf5 Merged in feature_ac_chunking_clean (pull request #265)
grouped keywords and IRS regex chunking

* abandon old branch and rebuild

* removed print for field names, prompts

* pushing as part of  leftovers

* IRS regex chunking

* Merged in feature/chunk_term_clean (pull request #262)

chunk_log_added

* chunk_log_added

* Merge remote-tracking branch 'remotes/origin/feature_ac_chunking_clean' into feature/chunk_term_clean


Approved-by: Alex Galarce

* added function for regex based IRS chunking

* shifted regex_match_chunk function to utils

* added helper functions for regex based chunking

* replaced tin_regex function to ac_funcs

* removed prompt for irs_others

* added regex chunking for irs

* removed irs group from smart chunking

* testing functionality for regex based irs fields

* updated return N/A condition

* Merged main into feature_ac_chunking_clean

* file_processing.py edited online with Bitbucket
* added back conditional prompts

* minor fixed for PR

* remove install types

* mering clean branch

* with passed test casses

* added flag for regex based tin execution


Approved-by: Michael McGuinness
2024-11-13 17:08:19 +00:00
Katon Minhas bb279b45fd Merged in cnc_fl_main (pull request #258)
Cnc fl main

* prov type moved

* comment out invalid prov2 bc it's overly restrictive

* Update prompt template to ensure N/A rather than blanks

* Update AC multi-prompt template. Update prompts to ensure all keys are present and N/As are filled

* Update AC postprocessing

* Update clean_tin() to add N/A for values other than 10 digits

* update tin postprocessing

* Update npi postprocessing

* Add 'Filename:' to the start of all filenames

* Update group TIN/NPI postprocessing

* Update parent agreement code

* fix health plan state mapping

* Update B postprocessing

* Updated indicators, re-ordering

* Update postprocessing - all columns included and reordered

* Ensure Pages is included in AC-only output

* Remove excess print statements

* remove example_test to pass pipeline

* Fix parent agreement code for AC

* Updated postprocessing for NPI/TIN other

* Update prompts for N explicitely on AC prompt-based indicators

* Updated main and utils for more intuitive filtering

* Updated file_counting to match new main process

* update test

* Add example_test


Approved-by: Michael McGuinness
2024-11-04 22:54:31 +00:00
Michael McGuinness ee3e3eb538 Merged in feature/mergeIntoMain (pull request #249)
Merge Prep

* mergePRep


Approved-by: Katon Minhas
2024-10-28 23:39:36 +00:00
Michael McGuinness 7cb0b485ad Merged in feature/unittestframe (pull request #240)
Unit Testing Framework

* emptyframe

* fixstatic

* save

* exampletest

* rmreqs

* rmUto


Approved-by: Alex Galarce
2024-10-22 13:45:53 +00:00
Michael McGuinness 168d197349 Merged in feature/lightStaticTypes (pull request #234)
Add static type check

* artifacts

* dockerfileforall

* examplemypystep

* reqs

* baseMain

* oneperservice

* somebasicchanges

* deps

* removedeps

* removeerrs

* singlecommand

* lessargs

* 312base

* versionanderr

* pythonversion

* ithinkfinalerrs

* numpyv

* versionsandconditional

* changesets

* tryagain

* lint

* numpyagain

* init

* clearstreamlit

* forcestreamlit


Approved-by: Umang Mistry
2024-10-11 15:26:16 +00:00
Michael McGuinness 02169d8a5e add reqs 2024-09-30 12:30:30 +01:00
FaizanM2000 81f34edc8d added new postprocessing and bottom up and top down merging. also carveouts 2024-09-26 18:53:55 +01:00
FaizanM2000 4478955e24 testing top down intial test complete 2024-09-26 18:53:47 +01:00
Grzegorz Huber 2919c6ef60 [DOC-535] Snowsql test 2024-06-25 17:34:35 +02:00
Pankaj Katariya d9f217a983 Merged in dev_pkatariya (pull request #71)
Dev pkatariya

Approved-by: Umang Mistry
2024-05-23 20:53:00 +00:00
Pankaj Katariya 68b6bf9968 Added git ignore 2024-05-10 18:40:23 +05:30
Pankaj Katariya d618250b65 Merged in dev_pkatariya (pull request #65)
Dev pkatariya

Approved-by: Umang Mistry
2024-04-25 20:39:42 +00:00
Mayank Aamseek d447006548 post processing for contract_num added 2024-04-16 15:31:32 +05:30
Pankaj Katariya d0036c8c54 Resolved .gitignore conflict 2024-04-15 15:34:56 +05:30
Pankaj Katariya 76ccb574d6 Added terraform files to ignore 2024-04-12 16:56:00 +05:30
Mayank Aamseek 62750d9e57 getting results.csv 2024-04-08 11:09:01 +05:30
Mayank Aamseek a9740ab34a used BUSINESS_CONFIG table 2 2024-03-26 15:33:16 +05:30
Mayank Aamseek 959432f37a field values updated 2024-03-19 22:43:22 +05:30
Ubuntu 6bc4e625a8 debugging added 2024-03-10 07:54:31 +00:00
Mayank Aamseek 8f55d8f113 data files removed 2024-03-07 14:37:38 +05:30
Mayank Aamseek 6f856e1f96 save results 2024-03-07 14:00:37 +05:30
Justin Wolfington ec65796f94 Initial commit 2024-01-23 15:52:13 +00:00