This repository uses CodeClimate for code coverage and maintainability reporting. See Configuration Guide for setup instructions.
Note: This API was formerly known as Max CFI (Claim for Increase) API. All functionality remains the same.
/disability-max-ratings
maps a list of disabilities to their max ratings, if any.
If you're on a Mac, you can use pyenv to handle multiple python versions
brew install pyenv
pyenv install 3.12.3
pyenv global 3.12.3 # or don't do this if you want a different version available globally for your system
This project uses Poetry to manage dependencies.
Follow the directions on the Poetry website for installation.
By default, Poetry will create its own virtual environment (see here), but it will also detect and respect an existing virtual environment if you have one activated.
-
Create a virtual environment with python and activate it like so:
python -m venv ~/.virtualenvs/domain-ee # or wherever you want source ~/.virtualenvs/domain-ee/bin/activate
-
Use pyenv-virtualenv to create and activate virtual environments with
pyenv
. -
Use Poetry to explicitly create and use a virtual environment.
Make sure your python path is set up to pull from your virtualenv:
which python
# /path/to/your/virtualenv/bin/python
Use Poetry to run and install all dependencies:
poetry install
This project uses pre-commit hooks to ensure code quality. To install them, run:
poetry run pre-commit install
To run the pre-commit hooks at any time, run the following command:
poetry run pre-commit run --all-files
Using Poetry, run the following command from the root of the repository:
poetry run uvicorn src.python_src.api:app --port 8130 --reload
You can also run the service using Docker:
-
Build & Start Services
docker compose down docker compose build --no-cache docker compose up -d docker compose ps
Expected:
disability-max-ratings-api
running on port 8130 -
Check Endpoints
To check the endpoints, you can use Bruno, or use the curl commands below:
# API docs curl http://localhost:8130/docs # Health endpoint curl http://localhost:8130/health # Main endpoint curl -X POST 'http://localhost:8130/disability-max-ratings' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"diagnostic_codes": [6260]}'
Expected main endpoint response:
{ "ratings": [ { "diagnostic_code": 6260, "max_rating": 10 } ] }
-
View API documentation:
Open your web-browser and navigate to http://localhost:8130/docs.
-
Development Environment
# Run tests inside container using Poetry docker compose run --rm api poetry run pytest # Check user docker compose run --rm api id
Expected: All tests pass (>80% coverage), user should be non-root (uid=1000)
This project utilizes Bruno for request testing. The collection for the current endpoints can be imported using the collections.json file. Once imported, the requests below can be run via the Bruno application:
- Docs Endpoint
- Health Endpoint
- Disability Max Ratings Endpoint
- The
diagnostic_codes
array in the request are integers within the range of5000 - 10000
.- Any request with an any entry that falls outside the range
5000 - 10000
will yield a400
.
- Any request with an any entry that falls outside the range
- An invalid request such as missing/invalid field will result in
422
status code. - Duplicate entries in the
diagnostic_codes
array will yield a ratings array with unique entries. - An empty
diagnostic_codes
array will yield an empty ratings array. - A
diagnostic_codes
array with more than 1000 entries will yield a422
status code.
- The response contains a
ratings
array where each item contains adiagnostic_code
and the associatedmax_rating
.- The
diagnostic_code
corresponds to an entry in the requestsdiagnostic_codes
array. - The
max_rating
item is a percentage expressed as an integer in the range of0 - 100
.
- The
- Each entry in
diagnostic_codes
array of the request with an associated max rating will yield an item in theratings
array of the response body. - If any entry of the
diagnostic_codes
is not found, the responseratings
array will not contain the corresponding item.
Using Poetry, run the following command from the root of the repository:
poetry run pytest
Swagger docs can be viewed by running the server locally and navigating to http://localhost:8130/docs
.
If desired, the docs can be exported to openapi.json
by running the following command:
poetry run python src/python_src/pull_api_documentation.py
NOTE: this repository was split from abd-vro.
This repository uses Dependabot to keep dependencies up to date. Pull requests from Dependabot are automatically merged if:
- All checks pass
- The update is a minor or patch version change (major version updates require manual review)
Interested in contributing? Check out our CONTRIBUTING.md for more information.
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 can 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).