/contention-classification/va-gov-claim-classifier
maps contention text and diagnostic codes from 526 submission to contention classification codes as defined in the Benefits Reference Data API.
This service can be run standalone using Poetry for dependency management or using Docker.
Mac Users: you can use pyenv to handle multiple python versions
brew install pyenv
pyenv install 3.12.3 #Installs latest version of python 3.12.3
pyenv global 3.12.3 # or don't do this if you want a different version available globally for your system
Mac Users: If python path hasn't been setup, you can put the following in your ~/.zshrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PATH"
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi" #Initalize pyenv in current shell session
This project uses Poetry to manage dependencies.
Follow the directions on the Poetry website for installation:
curl -sSL https://install.python-poetry.org | python3 -
Use Poetry to install all dependencies:
poetry install
poetry run pre-commit install
To run the pre-commit hooks manually:
poetry run pre-commit run --all-files
Using Poetry, run the FastAPI server:
poetry run uvicorn python_src.api:app --port 8120 --reload
Using Poetry, run the test suite:
poetry run pytest
For test coverage report:
poetry run pytest --cov=src --cov-report=term-missing
This application can also be run with Docker using the following commands.
docker compose down
docker compose build --no-cache
docker compose up -d
With the application running using either Docker or Python, tests requests can be sent using the following curl commands.
To test the health of the application or to check if the application is running at the contention-classification/health
endpoint:
curl -X 'GET' 'http://localhost:8120/health'
To test the classification provided at the contention-classification/va-gov-claim-classifier
endpoint:
curl -X 'POST' 'http://localhost:8120/va-gov-claim-classifier' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
"claim_id": 44,
"form526_submission_id": 55,
"contentions": [
{
"contention_text": "PTSD (post-traumatic stress disorder)",
"contention_type": "NEW"
},
{
"contention_text": "acl tear, right",
"contention_type": "NEW"
},
{
"contention_text": "",
"contention_type": "INCREASE",
"diagnostic_code": 5012
}
]
}'
To test the classification provided by the experimental endpoint at contention-classification/expanded-contention-classification
:
curl -X 'POST' 'http://localhost:8120/expanded-contention-classification' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
"claim_id": 44,
"form526_submission_id": 55,
"contentions": [
{
"contention_text": "PTSD (post-traumatic stress disorder)",
"contention_type": "NEW"
},
{
"contention_text": "acl tear, right",
"contention_type": "NEW"
},
{
"contention_text": "",
"contention_type": "INCREASE",
"diagnostic_code": 5012
}
]
}'
An alternative to the above curl
commands is to use a local testing application like Bruno or Postman. Different JSON request bodies can be set up for testing each of the above endpoints and tests can be saved using Collections within these tools.
API Documentation is automatically created by FastAPI. This can be viewed by visiting localhost:8120/docs
while the application is running.
For exporting the open API spec:
poetry run python src/python_src/pull_api_documentation.py
Images are built and pushed to ECR using the build_and_push_to_ecr.yml workflow which is triggered in one of two ways:
- Automatically: when pushed when changes are pushed to the
main
branch, which should only be done when a Pull Request is merged into themain
branch - Manually: by triggering the action in Github
This workflow is not triggered when changes are pushed to any branch other than the main
branch.
The image is released to the VA Platform using the release.yml workflow which is triggered when a new image is pushed to ECR.
This workflow will deploy the latest image to the VA Platform automatically for the dev
and staging
environments.
The sandbox
and prod
environments must be deployed manually by triggering the action in Github and selecting the desired environment(s).
Note that manually triggering the deployment will deploy the most recent commit hash to the selected environment(s).