Python Weather Stations to TIM message translator that is designed to pull messages from the CDOT Weather Stations feed and translate to TIM messages.
Information on the CDOT Data Feeds, including how to generate an API key for access, can be found here
Documentation for the CDOT Weather Stations feed can be found here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
This project supports Python >= 3.10. Packages required to run the translator can be installed via pip
pip install -r requirements.txtAlternatively, if you are running VSCode there is a task available to run this on your behalf. This can be accessed under Task Explorer -> vscode -> pipinstall.
The scripts also require access to the CDOT Postgres database. This can be accessed by setting the environment variables in the .env file. The .env file is not included in the repository for security reasons, however a sample.env file has been provided to show structure required.
In addition to the environment variables for accessing the CDOT Postgres database, the scripts also require the following environment variables to scrape the Weather Stations endpoint and deposit the resulting TIMs:
- CDOT_FEED_ENDPOINT - the CDOT API URL
- CDOT_FEED_API_KEY - the API key for accessing the CDOT Weather Stations data
- TIM_MANAGER_ENDPOINT - the TIM Manager URL where translated TIMs will be submitted
Unit tests are ran with the python pytest module. To run the tests, run the following command from the root of the project:
python -m pytest ./testsAgain, if you are running VSCode there is a task available to run this on your behalf. This can be accessed under Task Explorer -> vscode -> python test and coverage. This task includes a unit test coverage report to indicate how much of the code is covered by unit tests.
Using VSCode, a simple launch.json file has been provided to allow debugging the application. This can be accessed under the Run & Debug tab. The default configuration will run the translator using the functions framework. This runs the translator as a REST service accessed on http://localhost:8084. The translator can be tested by sending a POST request to this endpoint.
The Weather Stations to TIM translator can also be run locally using Docker. The translator Dockerfile can be found under Translators/WeatherStations/. Additionally, there is a docker compose file which builds and runs the translator. Setting the environment variable RUN_LOCAL to true will run the translator REST service as a flask application that can be accessed on http://localhost:8084. Alternatively, leaving RUN_LOCAL blank will run the translator one time immediately after the build has finished.