Local Development Environment
This chapter provides everything you need to know to set up a local development environment to work on Haztrak.
If you find something missing or inaccurate, please submit an issue here
Contents
- Set up with Docker Compose
- Fixtures
- Using RCRAInfo interfacing features
- Development Configs
- Developing without Docker
Docker Compose
- The easiest way to set up a local development environment is to
use docker compose
- You can use one of our config file to inject the environment variables needed to configure Haztrak ( see docker composes' documentation on environment files).
- You can either use the
--env-file
flag
docker compose --env-file configs/.env.dev up --build
or copy the config file to the project root as a .env
file, modify it if needed, and docker will apply it by default.
cp ./configs/.env.dev .env
docker compose up --build
You may find that after some changes (e.g., to the database) you need to rebuild the containers
instead of restarting them.
In that case, use the --build
flag, or you'll be running the last built image instead of the
Dockerfile's build target
that we've specified in
the docker-compose.yaml file.
After all containers are successfully running (you can inspect with docker ps
),
visit localhost:8080
Fixtures (logging in)
- On start, fixtures will be loaded to the database, including 2 users to aid local development.
username | password |
---|---|
testuser1 | password1 |
admin | password1 |
- The admin user has superuser privileges and can also log in to the django admin portal.
Fixtures will also load a couple of sites.
VATESTGEN001
- a preproduction site hazardous waste generatorMOCKTRANS001
- a mock transporter siteMOCKTRANS002
- a mock transporter siteMOCKTSDF001
- a mock TSDF site
By Default, testuser1
only has access to VATESTGEN001
, the mock sites can be used to draft electronic manifests.
RCRAInfo API credentials
Haztrak's docker-compose file will load fixtures, however this data is limited. If you'd like to start using features that push/pull information from RCRAInfo/e-Manifest, you will need API credentials to the appropriate RCRAInfo deployment (e.g., 'preproduction').
For development, **ONLY USE THE PREPRODUCTION ** environment. See Haztrak's config documentation.
The general steps for obtaining an API ID and key (in preprod) are as follows.
-
Register for an account in RCRAInfo (PreProduction)
-
Request access to one fo the test site EPA IDs (e.g., VATESTGEN001)
- You'll need 'Site Manager' level access to obtain API credentials
- Await approval, or contact EPA via the "Feedback/Report an issue".
-
Login after approval, generate your API Key.
For additional information on obtaining API credentials, see the USEPA/e-Manifest GitHub repository
Development Configs
Haztrak includes a couple configs to help ensure contributions use a consistent style guide. Most popular IDEs have a plugin to support these configs.
- pre-commit
- pre-commit hooks are set to run a number of linting and formatting checks before commits on any branch is accepted.
pip install -r server/requirements_dev.txt pre-commit install
- .editorconfig
- Universal IDE configs for formatting files, most IDEs will have a plugin you can install that will apply these configs.
- runhaz.sh
- A bash script to help with development
- See usage with
$ ./runhaz.sh -h
- Prettier
- Prettier is used to autoformat source files, specifically the most of our non-python files. If you're using an IDE, it will likely have a prettier plugin available.
- The configs are found in .prettierrc.json and .prettierignore
- Black
- Black is a Python formatter from the Python Software Foundation. It's very opinionated and largely unconfigurable.
- Ruff
- ruff is a Python linter and (recently) formatter. It provides a fast and pleasant developer experience.
- MyPy
- Haztrak is (currently in the process) incrementally adopting type hints. MyPy is a static type checker for Python.
Local Development Without Docker
While it is possible, local development without containerization (docker) is not supported.