LAMP is a collection of applications used to measure performance of the MBTA transit system.
LAMP application architecture is managed and described using Terraform
in the MBTA Devops github repository.
Link to Miro Diagram
Install these dependencies from brew
and follow the installation output for any additional configuration.
colima
brew install docker docker-compose colima colima start mkdir -p ${DOCKER_CONFIG:-"$HOME/.docker"}/cli-plugins ln -sfn /opt/homebrew/opt/docker-compose/bin/docker-compose ${DOCKER_CONFIG:-"$HOME/.docker"}/cli-plugins/docker-compose
asdf
To configureasdf plugin add python asdf plugin add direnv asdf plugin add poetry asdf install
direnv
:- Copy
.env.template
into.env
- Hook
direnv
into your shell
- Copy
docker
docker-compose
postgresql
unixodbc
In the base installation, LAMP provides access to performancedata.mbta.com. A fuller featureset is available by connecting to the MBTA's internal s3 storage. For AWS access, also install
awscli
will take you through an interactive CLI and store your AWS Access Key credentials. Associate the AWS Account with the Lamp Team User Group found in the MBTA devops terraform repository.aws configure
poetry env use 3.12.3
poetry env activate
poetry lock
poetry install
If all this worked, you can run the following checks without errors.
- Start up containers for local development
# terminal 1
colima start -f
# terminal 2
docker-compose up seed_metadata
- Run tests
poetry shell
pytest -s
- Query a date range from s3
python runners/run_query_s3_with_date_range.py
Notebook and dev dependencies are installed separately from the app dependencies.
To install these:
poetry install --with investigation
poetry install --with dev
To check dev
installed correctly, run the CI checks.
To check investigation
installed correctly:
poetry run marimo edit
The LAMP ingestion application has a Microsoft SQL Server datasource. To query the Microsoft SQL Server, on Linux, two pre-requisites are required.
- Install the Mirosoft ODBC 18 driver for SQL Server.
- Configure
openssl
to allow TLS V1.0 connections.
Project environmental variables are stored in .env and managed for command line usage with direnv
.
Using direnv
, whenever a shell moves into any project directory, the environmental variables defined in .env are loaded automagically.
Additionally, docker-compose.yml is configured to use .env, so that running containerized applications will load the same environmental variables.
To ensure code quality, linting, type checking, static analysis and unit tests are automatically run via github actions when pull requests are opened.
CI for LAMP python applications can be run locally, in the root project directory, with the following poetry
commands:
# black for Formatting
poetry run black .
# mypy for Type Checking
poetry run mypy .
# pylint for Static Analysis
poetry run pylint src tests
# pytest for Unit Tests
poetry run pytest
Images for LAMP applications are hosted by AWS on the Elastic Container Registry (ECR). Updates to application images are pushed to ECR via automated github actions.
LAMP applications are hosted by AWS and run on Elastic Container Service (ECS) instances. Deployment of LAMP applications, to ECS instances, occur via automated github actions.
LAMP uses docker
and docker-compose
to run local instances of applications for development purposes. Please refer to the README
page of invidiual applications for instructions.